directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 36705 - incubator/directory/snickers/branches/encoder-redesign/ber-codec/src/java/org/apache/snickers/ber
Date Sun, 22 Aug 2004 23:21:56 GMT
Author: akarasulu
Date: Sun Aug 22 16:21:55 2004
New Revision: 36705

Modified:
   incubator/directory/snickers/branches/encoder-redesign/ber-codec/src/java/org/apache/snickers/ber/DeterminateLengthVisitor.java
Log:
Completed the visit method of this determinate length visitor which converts 
tlv trees with indeterminate length nodes into definate length tuples be 
decscending the tree in postfix order (depth first) to compute the child lengths
then finally the lengths of parents and ancestors in an indeterminate length 
tree. 


Modified: incubator/directory/snickers/branches/encoder-redesign/ber-codec/src/java/org/apache/snickers/ber/DeterminateLengthVisitor.java
==============================================================================
--- incubator/directory/snickers/branches/encoder-redesign/ber-codec/src/java/org/apache/snickers/ber/DeterminateLengthVisitor.java
(original)
+++ incubator/directory/snickers/branches/encoder-redesign/ber-codec/src/java/org/apache/snickers/ber/DeterminateLengthVisitor.java
Sun Aug 22 16:21:55 2004
@@ -17,6 +17,7 @@
 package org.apache.snickers.ber;
 
 
+import java.util.Iterator;
 import java.util.ArrayList;
 
 
@@ -36,6 +37,21 @@
      */
     public void visit( TupleNode node )
     {
+        /*
+         * Because of a recursive depth first descent driving the
+         * calculation of indeterminate child sizes we just need to
+         * add the sizes of all the child nodes to find the determinate
+         * length and set it for the tuple.
+         */
+        int length = 0;
+        Iterator children = node.getChildren();
+        while ( children.hasNext() )
+        {
+            Tuple tlv = ( ( TupleNode ) children.next() ).getTuple() ;
+            length += tlv.size();
+        }
+
+        node.getTuple().setValueLength( length );
         System.out.println( node );
     }
 
@@ -48,7 +64,7 @@
      */
     public boolean canVisit( TupleNode node )
     {
-        return true;
+        return node.getTuple().isIndefinate();
     }
 
 

Mime
View raw message