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/22 07:27:07 UTC
svn commit: r191768 -
/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java
Author: elecharny
Date: Tue Jun 21 22:27:07 2005
New Revision: 191768
URL: http://svn.apache.org/viewcvs?rev=191768&view=rev
Log:
- Added a dumpTLV method to help the debugging
- linked TLV with there parents
Modified:
directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java
Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java?rev=191768&r1=191767&r2=191768&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java (original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java Tue Jun 21 22:27:07 2005
@@ -216,6 +216,36 @@
}
/**
+ * Dump the current TLV tree
+ * @param container The container
+ */
+ private void dumpTLVTree( IAsn1Container container )
+ {
+ StringBuffer sb = new StringBuffer();
+ TLV current = container.getCurrentTLV();
+
+ sb.append("TLV").
+ append(StringUtils.dumpByte(current.getTag().getTagBytes()[0])).
+ append("(").
+ append(current.getExpectedLength()).
+ append(")");
+
+ current = current.getParent();
+
+ while (current != null)
+ {
+ sb.append("-TLV").
+ append(StringUtils.dumpByte(current.getTag().getTagBytes()[0])).
+ append("(").
+ append(current.getExpectedLength()).
+ append(")");
+ current = current.getParent();
+ }
+
+ log.debug("TLV Tree : " + sb.toString());
+ }
+
+ /**
* Action to be executed when the Tag has been decoded. Basically, this
* is a debug action. We will log the information that the Tag has been
* decoded.
@@ -231,11 +261,13 @@
if ( DEBUG )
{
-
Tag tag = container.getCurrentTLV().getTag();
log.debug( tag.toString() + " has been decoded" );
}
+ // Create a link between the current TLV with its parent
+ container.getCurrentTLV().setParent(container.getParentTLV());
+
// After having decoded a tag, we have to execute the action
// which controls if this tag is allowed and well formed.
container.getGrammar().executeAction( container );
@@ -454,11 +486,11 @@
{
parentTLV.setExpectedLength(0);
- // deal with the particuliar case where expected length equal
+ // deal with the particular case where expected length equal
// the current length, which means that the parentTLV has been
// completed.
// We also have to check that the current TLV is a constructed
- // one. In this case, we won't change the parent TLV
+ // one.
// In this case, we have to switch from this parent TLV
// to the parent's parent TLV.
if (tlv.getTag().isConstructed())
@@ -472,6 +504,7 @@
}
else
{
+ tlv.setExpectedLength(tlv.getLength().getLength());
// It's over, the parent TLV has been completed.
// Go back to the parent's parent TLV until we find
// a tlv which is not complete.
@@ -496,6 +529,7 @@
{
// Renew the expected Length.
parentTLV.setExpectedLength(expectedLength - currentLength);
+ tlv.setExpectedLength(tlv.getLength().getLength());
if (tlv.getTag().isConstructed())
{
@@ -637,7 +671,11 @@
private boolean treatTLVDoneState( ByteBuffer stream, IAsn1Container container )
throws DecoderException
{
-
+ if (DEBUG)
+ {
+ dumpTLVTree(container);
+ }
+
// First, we have to execute the associated action
container.getGrammar().executeAction( container );