You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2005/06/21 02:34:46 UTC
svn commit: r191596 -
/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/tlv/TLV.java
Author: elecharny
Date: Mon Jun 20 17:34:45 2005
New Revision: 191596
URL: http://svn.apache.org/viewcvs?rev=191596&view=rev
Log:
Added a link to the parent TLV, and added a member to store the current TLV length. This member is
used while decoding a PDU.
Modified:
directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/tlv/TLV.java
Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/tlv/TLV.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/tlv/TLV.java?rev=191596&r1=191595&r2=191596&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/tlv/TLV.java (original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/tlv/TLV.java Mon Jun 20 17:34:45 2005
@@ -37,11 +37,15 @@
/** The current Value being processed */
private Value value;
- /** The expected Length is the addition of the Tag length, the Length
- * length and the expected Value length.
- * The TLV size is calculated by adding the Tag's size, the Length's
- * size and the Value's size, if any */
- private int size;
+ /** Reference the TLV which contains the current TLV, if any.
+ * As the enclosing TLV of a PDU does not have parent, it can be
+ * null in this case. Otherwise, it must point to a constructed TLV */
+ private TLV parent;
+
+ /** The expected length of the TLV's elements, if the current TLV is
+ * a constructed TLV.
+ */
+ private int expectedLength;
//~ Constructors -------------------------------------------------------------------------------
@@ -51,10 +55,10 @@
public TLV()
{
tag = new Tag();
-
length = new Length();
value = new Value();
- size = 0;
+
+ expectedLength = 0;
}
//~ Methods ------------------------------------------------------------------------------------
@@ -67,7 +71,8 @@
tag.reset();
length.reset();
value.reset();
- size = 0;
+
+ expectedLength = 0;
}
/**
@@ -83,14 +88,11 @@
*
* @param length The length to set.
*/
- public void setLength1( Length length )
+ public void setLength( Length length )
{
this.length = length;
- // The TLV size will be equal to this sum :
- // Tag size + Length size
- // + Value size which is given by the Length length.
- size += length.getSize() + length.getLength();
+ expectedLength = length.getLength();
}
/**
@@ -123,16 +125,53 @@
sb.append( tag.toString() ).append( ", " );
sb.append( length.toString() ).append( ", " );
sb.append( value.toString() );
-
sb.append( "]" );
return sb.toString();
}
/**
+ * The TLV size is calculated by adding the Tag's size, the Length's
+ * size and the Value's length, if any.
+ *
* @return Returns the size of the TLV.
*/
public int getSize() {
return tag.getSize() + length.getSize() + length.getLength();
}
+
+ /**
+ * @return Returns the parent.
+ */
+ public TLV getParent()
+ {
+ return parent;
+ }
+
+ /**
+ * @param parent The parent to set.
+ */
+ public void setParent(TLV parent)
+ {
+ this.parent = parent;
+ }
+
+ /**
+ * Get the TLV expected length.
+ *
+ * @return Returns the expectedLength.
+ */
+ public int getExpectedLength()
+ {
+ return expectedLength;
+ }
+
+ /**
+ * Set the new expected length of the current TLV.
+ * @param expectedLength The expectedLength to set.
+ */
+ public void setExpectedLength(int expectedLength)
+ {
+ this.expectedLength = expectedLength;
+ }
}