/** * A debug function used to dump the expected length stack. * * @param tlv The current TLV. * @return A string which represent the expected length stack. */ private String getParentLength( TLV tlv ) { StringBuffer buffer = new StringBuffer(); buffer.append( "TLV expected length stack : " ); while ( true ) { if ( tlv == null ) { buffer.append( " - null" ); break; } else { buffer.append( " - " ).append( tlv.getExpectedLength() ); } tlv = tlv.getParent(); } return buffer.toString(); }
/** * 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( Asn1StringUtils.dumpByte( current.getTag() ) ).append( "(" ) .append( current.getExpectedLength() ).append( ")" ); current = current.getParent(); while ( current != null ) { sb.append( "-TLV" ).append( Asn1StringUtils.dumpByte( current.getTag() ) ).append( "(" ) .append( current.getExpectedLength() ).append( ")" ); current = current.getParent(); } if ( IS_DEBUG ) { LOG.debug( "TLV Tree : {}", sb.toString() ); } }
/** * Check if the TLV tree is fully decoded * * @param container The container * @return <code>true</code> if the TLV has been decoded */ private boolean isTLVDecoded( IAsn1Container container ) { TLV current = container.getCurrentTLV(); TLV parent = current.getParent(); while ( parent != null ) { if ( parent.getExpectedLength() != 0 ) { return false; } parent = parent.getParent(); } Value value = current.getValue(); if ( ( value != null ) && ( value.getData() != null ) ) { return ( current.getExpectedLength() == value.getData().length ); } else { return current.getExpectedLength() == 0; } }