directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 36830 - incubator/directory/snickers/branches/encoder-redesign/ber-codec/src/java/org/apache/snickers/ber
Date Wed, 25 Aug 2004 01:19:37 GMT
Author: akarasulu
Date: Tue Aug 24 18:19:36 2004
New Revision: 36830

Modified:
   incubator/directory/snickers/branches/encoder-redesign/ber-codec/src/java/org/apache/snickers/ber/DeterminateLengthVisitor.java
Log:
Added code to remove any indeterminate terminator tuples that are found
while descending the 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
Tue Aug 24 18:19:36 2004
@@ -25,9 +25,6 @@
  * A visitor used to transform a TLV tuple tree by altering tuples to use
  * determinate length encodings rather than the indeterminate form.
  *
- * @todo this visitor must check and remove tuple nodes adjacent to an
- * indeterminate length tuple node after transforming it into a determinate
- * length tuple
  * @author <a href="mailto:directory-dev@incubator.apache.org"> Apache Directory
  *         Project</a> $Rev$
  */
@@ -50,8 +47,25 @@
         Iterator children = node.getChildren();
         while ( children.hasNext() )
         {
-            Tuple tlv = ( ( TupleNode ) children.next() ).getTuple() ;
-            length += tlv.size();
+            TupleNode childTuple = ( TupleNode ) children.next();
+            Tuple tlv = childTuple.getTuple() ;
+
+            /*
+             * The tuple node may have child tuple nodes that are indefinate
+             * terminator nodes.  When converting to the definate length form
+             * these tuples must be detached from the tree and NOT factored
+             * into length computations.
+             */
+            if ( tlv.isIndefinateTerminator() )
+            {
+                // setting the parent to null removes it from the
+                // parent's child list
+                ( ( MutableTupleNode ) childTuple ).setParent( null );
+            }
+            else
+            {
+                length += tlv.size();
+            }
         }
 
         node.getTuple().setValueLength( length );

Mime
View raw message