directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 9382 - in incubator/directory/snickers/trunk/ber: . src/java/org/apache/snickers/ber
Date Fri, 12 Mar 2004 07:22:09 GMT
Author: akarasulu
Date: Thu Mar 11 23:22:08 2004
New Revision: 9382

Added:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/DefaultMutableTupleNode.java
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/MutableTupleNode.java
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleNode.java
Modified:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/Tuple.java
   incubator/directory/snickers/trunk/ber/todo.txt
Log:
setting up for tlv tree generation

Added: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/DefaultMutableTupleNode.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/DefaultMutableTupleNode.java
Thu Mar 11 23:22:08 2004
@@ -0,0 +1,190 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ber ;
+
+
+import java.util.Iterator ;
+import java.util.ArrayList ;
+import java.util.Collections ;
+
+import org.apache.commons.lang.NotImplementedException;
+
+
+/**
+ * The default mutable tuple node.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DefaultMutableTupleNode implements MutableTupleNode
+{
+    private Tuple tuple ;
+    private ArrayList children ;
+    private MutableTupleNode parent ;
+    
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.MutableTupleNode#insert(
+     * org.apache.snickers.ber.MutableTupleNode, int)
+     */
+    public void insert( MutableTupleNode child, int index )
+    {
+        children.add( index, child ) ; 
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.MutableTupleNode#remove(int)
+     */
+    public void remove( int index )
+    {
+        children.remove( index ) ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.MutableTupleNode#remove(
+     * org.apache.snickers.ber.MutableTupleNode)
+     */
+    public void remove( MutableTupleNode node )
+    {
+        children.remove( node ) ;
+    }
+    
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.MutableTupleNode#removeFromParent()
+     */
+    public void removeFromParent()
+    {
+        parent.remove( this ) ;
+        parent = null ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.MutableTupleNode#setParent(
+     * org.apache.snickers.ber.MutableTupleNode)
+     */
+    public void setParent( MutableTupleNode newParent )
+    {
+        parent.remove( this ) ;
+        newParent.insert( this, 0 ) ;
+        parent = newParent ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.MutableTupleNode#setTuple(
+     * org.apache.snickers.ber.Tuple)
+     */
+    public void setTuple(Tuple t)
+    {
+        tuple = t ;
+    }
+    
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.TupleNode#getParent()
+     */
+    public TupleNode getParent()
+    {
+        return parent ;
+    }
+    
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.TupleNode#children()
+     */
+    public Iterator children()
+    {
+        return Collections.unmodifiableList( children ).iterator() ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.TupleNode#getChildAt()
+     */
+    public TupleNode getChildAt( int index )
+    {
+        return ( TupleNode ) children.get( index ) ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.TupleNode#getIndex(
+     * org.apache.snickers.ber.TupleNode)
+     */
+    public int getIndex( TupleNode node )
+    {
+        return children.indexOf( node ) ;
+    }
+    
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.TupleNode#getChildCount()
+     */
+    public int getChildCount()
+    {
+        return children.size() ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.TupleNode#size()
+     */
+    public int size()
+    {
+        if ( tuple.isPrimitive() )
+        {
+            return tuple.size() ;
+        }
+        else
+        {
+            int size = tuple.size() ;
+            
+            for ( int ii = 0; ii < children.size(); ii++ )
+            {
+                TupleNode node = ( TupleNode ) children.get( ii ) ;
+                size += node.getTuple().size() ;
+            }
+
+            return size ;
+        }
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.TupleNode#getTuple()
+     */
+    public Tuple getTuple()
+    {
+        return tuple ;
+    }
+    
+    
+    /**
+     * Depth first generation of this tlv tuple node's encoded image.
+     * 
+     * @see org.apache.snickers.ber.TupleNode#encode()
+     */
+    public byte[] encode()
+    {
+        throw new NotImplementedException( "STUB" ) ;
+    }
+}

Added: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/MutableTupleNode.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/MutableTupleNode.java
Thu Mar 11 23:22:08 2004
@@ -0,0 +1,70 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ber ;
+
+
+/**
+ * A mutable TupleNode used for building TLV Tuple trees.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface MutableTupleNode extends TupleNode
+{
+    /**
+     * Adds child to the receiver at index.
+     * 
+     * @param child
+     * @param index
+     */
+    void insert( MutableTupleNode child, int index ) ; 
+              
+    /**
+     * Removes the child at index from the receiver.
+     * 
+     * @param index
+     */
+    void remove( int index ) ;
+              
+    /**
+     * Removes node from the receiver. 
+     * 
+     * @param node
+     */
+     void remove( MutableTupleNode node ) ; 
+              
+     /**
+      * Removes the receiver from its parent.
+      */
+     void removeFromParent() ; 
+               
+     /**
+      * Sets the parent of the receiver to newParent.
+      * 
+      * @param newParent
+      */
+     void setParent( MutableTupleNode newParent ) ; 
+              
+     /**
+      * Resets the Tuple of the receiver object.
+      * 
+      * @param t
+      */
+     void setTuple( Tuple t ) ;  
+               
+}

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/Tuple.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/Tuple.java	(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/Tuple.java	Thu
Mar 11 23:22:08 2004
@@ -262,7 +262,14 @@
      */
     public int size()
     {
-        return getTagLength() + getLengthLength() + length ;
+        if ( this.length == BERDecoder.INDEFINATE )
+        {    
+            return getTagLength() + getLengthLength() ;
+        }
+        else
+        {
+            return getTagLength() + getLengthLength() + length ;
+        }
     }
     
     

Added: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleNode.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleNode.java
Thu Mar 11 23:22:08 2004
@@ -0,0 +1,40 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ber ;
+
+
+import java.util.Iterator ;
+
+
+/**
+ * A TLV Tuple tree node.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface TupleNode
+{
+    TupleNode getParent() ;
+    Iterator children() ;
+    TupleNode getChildAt( int index ) ;
+    int getIndex( TupleNode node ) ;
+    int getChildCount() ;
+    int size() ;
+    Tuple getTuple() ;
+    byte[] encode() ;
+}

Modified: incubator/directory/snickers/trunk/ber/todo.txt
==============================================================================
--- incubator/directory/snickers/trunk/ber/todo.txt	(original)
+++ incubator/directory/snickers/trunk/ber/todo.txt	Thu Mar 11 23:22:08 2004
@@ -3,8 +3,6 @@
                                 T O D O   L I S T 
                                 =================
 
-* Create a TupleNode interface to nest TLV's to easily generate constructed
-  TLV's.
 
 * Write a TupleNode tree generator that implements the decoder callback.  This
   is where the DOM like functionality comes in.  We want tuple node 
@@ -43,7 +41,7 @@
 * It will be worth while taking a good look at the way digester works to get 
   some ideas here.
   
-* Also we need to need the Sample Neufeld papper to make sure we're decoding
+* Also we need to read the Sample Neufeld papper to make sure we're decoding
   appropriately.
   
   

Mime
View raw message