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 2008/05/23 07:42:54 UTC
svn commit: r659436 - in /directory/shared/trunk/asn1/src:
main/java/org/apache/directory/shared/asn1/
main/java/org/apache/directory/shared/asn1/ber/
main/java/org/apache/directory/shared/asn1/ber/grammar/
main/java/org/apache/directory/shared/asn1/be...
Author: elecharny
Date: Thu May 22 22:42:42 2008
New Revision: 659436
URL: http://svn.apache.org/viewvc?rev=659436&view=rev
Log:
o Added some missing Javadoc
o Used Java 5 for loop construction
o Cleaned some code (minor refactoring)
Modified:
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/AbstractAsn1Object.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/Asn1Object.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Decoder.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/GrammarTransition.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/IStates.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/ITLVBerDecoderMBean.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/TLV.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/UniversalTag.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/Value.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/binary/Hex.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/DecoderMonitor.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/DecoderStack.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/EncoderMonitor.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/StatefulDecoder.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/StatefulEncoder.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexDecoder.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexEncoder.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/der/BERConstructedOctetString.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/der/DERObjectIdentifier.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/primitives/BitString.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/primitives/OID.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/BooleanDecoder.java
directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/ber/tlv/ValueTest.java
directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/codec/stateful/DecoderStackTest.java
directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexDecoderTest.java
directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexEncoderTest.java
directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/BitStringTest.java
directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/OIDTest.java
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/AbstractAsn1Object.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/AbstractAsn1Object.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/AbstractAsn1Object.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/AbstractAsn1Object.java Thu May 22 22:42:42 2008
@@ -98,9 +98,9 @@
/**
* Encode the object to a PDU.
*
- * @param buffer
- * The buffer where to put the PDU
+ * @param buffer The buffer where to put the PDU
* @return The PDU.
+ * @throws EncoderException if the buffer can't be encoded
*/
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/Asn1Object.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/Asn1Object.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/Asn1Object.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/Asn1Object.java Thu May 22 22:42:42 2008
@@ -54,9 +54,9 @@
/**
* Encode the object to a PDU.
*
- * @param buffer
- * The buffer where to put the PDU
+ * @param buffer The buffer where to put the PDU
* @return The PDU.
+ * @throws EncoderException if the buffer can't be encoded
*/
ByteBuffer encode( ByteBuffer buffer ) throws EncoderException;
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Decoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Decoder.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Decoder.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Decoder.java Thu May 22 22:42:42 2008
@@ -96,7 +96,6 @@
* the result and other informations.
* @return <code>true</code> if there are more bytes to read, <code>false
* </code> otherwise
- * @throws DecoderException If something went wrong.
*/
private boolean treatTagStartState( ByteBuffer stream, IAsn1Container container )
{
@@ -167,6 +166,7 @@
* 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 )
{
@@ -265,7 +265,6 @@
* the result and other informations.
* @return <code>true</code> if there are more bytes to read, <code>false
* </code> otherwise
- * @throws DecoderException Thrown if anything went wrong
*/
private boolean treatLengthPendingState( ByteBuffer stream, IAsn1Container container )
{
@@ -521,7 +520,6 @@
* the result and other informations.
* @return <code>true</code> if there are more bytes to read, <code>false
* </code> otherwise
- * @throws DecoderException Thrown if anything went wrong
*/
private boolean treatValueStartState( ByteBuffer stream, IAsn1Container container )
{
@@ -569,7 +567,6 @@
* @return <code>MORE</code> if some bytes remain in the buffer when the
* value has been decoded, <code>END</code> if whe still need to get some
* more bytes.
- * @throws DecoderException Thrown if anything went wrong
*/
private boolean treatValuePendingState( ByteBuffer stream, IAsn1Container container )
{
@@ -808,6 +805,9 @@
hasRemaining = false;
break;
+
+ default :
+ break;
}
}
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/GrammarTransition.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/GrammarTransition.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/GrammarTransition.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/GrammarTransition.java Thu May 22 22:42:42 2008
@@ -50,7 +50,9 @@
/**
* Creates a new GrammarTransition object.
*
- * @param currentState The current transition
+ * @param previousState the previous state
+ * @param currentState The current state
+ * @param currentTag the current TLV's tag
* @param action The action to execute. It could be null.
*/
public GrammarTransition( int previousState, int currentState, int currentTag, IAction action )
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/IStates.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/IStates.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/IStates.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/IStates.java Thu May 22 22:42:42 2008
@@ -39,12 +39,27 @@
/** The END_STATE */
int END_STATE = -1;
- /** Get the current state */
+ /**
+ * Get the current state's name
+ *
+ * @param state the current state
+ * @return the associated name for this state
+ */
String getState( int state );
- /** Return the grammar name from a grammar */
+ /**
+ * Return the grammar name of a grammar
+ *
+ * @param grammar the grammar from which we want the name
+ * @return the grammar's name
+ */
String getGrammarName( IGrammar grammar );
- /** Return the grammar name from a grammar number */
+ /**
+ * Return the grammar name from a grammar number
+ *
+ * @param grammar the grammar number from which we want the name
+ * @return the grammar's name
+ */
String getGrammarName( int grammar );
}
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/ITLVBerDecoderMBean.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/ITLVBerDecoderMBean.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/ITLVBerDecoderMBean.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/ITLVBerDecoderMBean.java Thu May 22 22:42:42 2008
@@ -37,8 +37,8 @@
* including the first byte. Max is 127 if the Length use a definite form,
* default is 1
*
- * @param length
- * The number of byte to use
+ * @param length the number of byte to use
+ * @throws DecoderException
*/
void setMaxLengthLength( int length ) throws DecoderException;
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/TLV.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/TLV.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/TLV.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/TLV.java Thu May 22 22:42:42 2008
@@ -104,6 +104,8 @@
/**
* Creates a new TLV object.
+ *
+ * @param id the TLV's id
*/
public TLV( int id )
{
@@ -123,6 +125,7 @@
/**
* Checks to see if the tag is constructed.
*
+ * @param tag the TLV's tag
* @return true if constructed, false if primitive
*/
public static boolean isConstructed( byte tag )
@@ -145,6 +148,7 @@
* Checks to see if the tag represented by this Tag is primitive or
* constructed.
*
+ * @param tag the tag to be checked
* @return true if it is primitive, false if it is constructed
*/
public static boolean isPrimitive( byte tag )
@@ -155,6 +159,7 @@
/**
* Tells if the tag is Universal or not
*
+ * @param tag the tag to be checked
* @return true if it is primitive, false if it is constructed
*/
public static boolean isUniversal( byte tag )
@@ -184,7 +189,9 @@
}
/**
- * @return Returns the tag.
+ * Set a tag value for this TLV.
+ *
+ * @param tag the tag field for this TLV.
*/
public void setTag( byte tag )
{
@@ -373,46 +380,78 @@
}
+ /**
+ * @return the number of bytes necessary to store the TLV's length
+ */
public int getLengthNbBytes()
{
return lengthNbBytes;
}
+ /**
+ * Set the number of bytes we should use to store the TLV's length
+ * @param lengthNbBytes the number of bytes necessary to store the TLV's length
+ */
public void setLengthNbBytes( int lengthNbBytes )
{
this.lengthNbBytes = lengthNbBytes;
}
+ /**
+ * @return the tLV's length
+ */
public int getLength()
{
return length;
}
+ /**
+ * Set the TLV's length
+ *
+ * @param length the TLV's length
+ */
public void setLength( int length )
{
this.length = length;
}
+ /**
+ * @return the currently read TLV's length bytes
+ */
public int getLengthBytesRead()
{
return lengthBytesRead;
}
+ /**
+ * Set the currently read TLV's length bytes.
+ *
+ * @param lengthBytesRead the currently read TLV's length bytes
+ */
public void setLengthBytesRead( int lengthBytesRead )
{
this.lengthBytesRead = lengthBytesRead;
}
+
+ /**
+ * Increment the number of bytes read for this TLV
+ *
+ */
public void incLengthBytesRead()
{
lengthBytesRead++;
}
+
+ /**
+ * @return the TLV's ID
+ */
public int getId()
{
return id;
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/UniversalTag.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/UniversalTag.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/UniversalTag.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/UniversalTag.java Thu May 22 22:42:42 2008
@@ -307,24 +307,34 @@
};
/** ASN.1 primitive tag values */
+ /** Boolean TAG */
public static final byte BOOLEAN_TAG = 0x01;
+ /** Integer TAG */
public static final byte INTEGER_TAG = 0x02;
+ /** BIT_STRING TAG */
public static final byte BIT_STRING_TAG = 0x03;
+ /** OCTET_STRING TAG */
public static final byte OCTET_STRING_TAG = 0x04;
+ /** ENUMERATED TAG */
public static final byte ENUMERATED_TAG = 0x0A;
+ /** UTF8_STRING TAG */
public static final byte UTF8_STRING_TAG = 0x0C;
+ /** GENERALIZED_TIME TAG */
public static final byte GENERALIZED_TIME_TAG = 0x18;
+ /** GENERALIZED_STRING TAG */
public static final byte GENERALIZED_STRING_TAG = 0x1B;
+ /** SEQUENCE TAG */
public static final byte SEQUENCE_TAG = 0x30;
+ /** SET TAG */
public static final byte SET_TAG = 0x31;
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/Value.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/Value.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/Value.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/ber/tlv/Value.java Thu May 22 22:42:42 2008
@@ -36,7 +36,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class Value implements Cloneable, Serializable
+public class Value implements Serializable
{
private static final long serialVersionUID = 1L;
@@ -82,8 +82,10 @@
/**
* The constructor.
+ *
+ * @param value the associated value
*/
- public Value(byte[] value)
+ public Value( byte[] value )
{
// Do a copy of the byte array
data = new byte[value.length];
@@ -125,19 +127,6 @@
/**
- * Clone the Value
- *
- * @return An object that is a copy of this Value
- * @throws CloneNotSupportedException Thrown when the cloning failed
- */
- public Object clone() throws CloneNotSupportedException
- {
-
- return super.clone();
- }
-
-
- /**
* Get the Values'data
*
* @return Returns the data.
@@ -164,12 +153,12 @@
/**
* Append some bytes to the data buffer.
*
- * @param data The data to append.
+ * @param buffer The data to append.
*/
- public void addData( ByteBuffer data )
+ public void addData( ByteBuffer buffer )
{
- int length = data.remaining();
- data.get( this.data, currentPos, length );
+ int length = buffer.remaining();
+ buffer.get( data, currentPos, length );
currentPos += length;
}
@@ -189,12 +178,12 @@
/**
* Append some bytes to the data buffer.
*
- * @param data The data to append.
+ * @param array The data to append.
*/
- public void addData( byte[] data )
+ public void addData( byte[] array )
{
- System.arraycopy( data, 0, this.data, currentPos, data.length );
- currentPos = data.length;
+ System.arraycopy( array, 0, this.data, currentPos, array.length );
+ currentPos = array.length;
}
@@ -339,6 +328,8 @@
*
* @param buffer The PDU in which the value will be put
* @param string The String to be encoded. It is supposed to be UTF-8
+ * @throws EncoderException if the PDU in which the value should be encoded is
+ * two small
*/
public static void encode( ByteBuffer buffer, String string ) throws EncoderException
{
@@ -373,6 +364,8 @@
*
* @param buffer The PDU in which the value will be put
* @param bitString The BitString to be encoded.
+ * @throws EncoderException if the PDU in which the value should be encoded is
+ * two small
*/
public static void encode( ByteBuffer buffer, BitString bitString ) throws EncoderException
{
@@ -407,6 +400,8 @@
*
* @param buffer The PDU in which the value will be put
* @param bytes The bytes to be encoded
+ * @throws EncoderException if the PDU in which the value should be encoded is
+ * two small
*/
public static void encode( ByteBuffer buffer, byte[] bytes ) throws EncoderException
{
@@ -443,6 +438,8 @@
*
* @param buffer The PDU in which the value will be put
* @param oid The OID to be encoded
+ * @throws EncoderException if the PDU in which the value should be encoded is
+ * two small
*/
public static void encode( ByteBuffer buffer, OID oid ) throws EncoderException
{
@@ -475,6 +472,8 @@
*
* @param buffer The PDU in which the value will be put
* @param value The integer to be encoded
+ * @throws EncoderException if the PDU in which the value should be encoded is
+ * two small
*/
public static void encode( ByteBuffer buffer, int value ) throws EncoderException
{
@@ -504,6 +503,8 @@
* @param buffer The PDU in which the value will be put
* @param tag The tag if it's not an UNIVERSAL one
* @param value The integer to be encoded
+ * @throws EncoderException if the PDU in which the value should be encoded is
+ * two small
*/
public static void encode( ByteBuffer buffer, byte tag, int value ) throws EncoderException
{
@@ -532,6 +533,8 @@
*
* @param buffer The PDU in which the value will be put
* @param value The integer to be encoded
+ * @throws EncoderException if the PDU in which the value should be encoded is
+ * two small
*/
public static void encodeEnumerated( ByteBuffer buffer, int value ) throws EncoderException
{
@@ -560,6 +563,8 @@
*
* @param buffer The PDU in which the value will be put
* @param bool The boolean to be encoded
+ * @throws EncoderException if the PDU in which the value should be encoded is
+ * two small
*/
public static void encode( ByteBuffer buffer, boolean bool ) throws EncoderException
{
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/binary/Hex.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/binary/Hex.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/binary/Hex.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/binary/Hex.java Thu May 22 22:42:42 2008
@@ -75,7 +75,7 @@
{
int f = toDigit( data[j], j ) << 4;
j++;
- f = f | toDigit( data[j], j );
+ f |= toDigit( data[j], j );
j++;
out[i] = ( byte ) ( f & 0xFF );
}
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/DecoderMonitor.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/DecoderMonitor.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/DecoderMonitor.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/DecoderMonitor.java Thu May 22 22:42:42 2008
@@ -78,10 +78,9 @@
/**
* Monitors callbacks that deliver a fully decoded object.
*
- * @param decoder
- * the stateful decoder driving the callback
- * @param decoded
- * the object that was decoded
+ * @param decoder the stateful decoder driving the callback
+ * @param cb the callback to call when the decoder has done its job
+ * @param decoded the object that was decoded
*/
void callbackOccured( StatefulDecoder decoder, DecoderCallback cb, Object decoded );
@@ -89,12 +88,9 @@
/**
* Monitors changes to the callback.
*
- * @param decoder
- * the decoder whose callback was set
- * @param oldcb
- * the unset old callback, or null if none was set
- * @param newcb
- * the newly set callback, or null if callback is cleared
+ * @param decoder the decoder whose callback was set
+ * @param oldcb the unset old callback, or null if none was set
+ * @param newcb the newly set callback, or null if callback is cleared
*/
void callbackSet( StatefulDecoder decoder, DecoderCallback oldcb, DecoderCallback newcb );
}
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/DecoderStack.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/DecoderStack.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/DecoderStack.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/DecoderStack.java Thu May 22 22:42:42 2008
@@ -115,10 +115,10 @@
* Decodes an encoded object by calling decode on the decoder at the bottom
* of the stack. Callbacks are chained to feed the output of one decoder
* into the input decode method of another. If the stack is empty then the
- * arguement is delivered without change to this StatefulDecoder's callback.
+ * argument is delivered without change to this StatefulDecoder's callback.
*
- * @see org.apache.directory.shared.asn1.codec.stateful.StatefulDecoder#
- * decode(java.lang.Object)
+ * @param encoded an object representing a piece of encoded data
+ * @throws DecoderException if the encoded element can't be decoded
*/
public synchronized void decode( Object encoded ) throws DecoderException
{
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/EncoderMonitor.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/EncoderMonitor.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/EncoderMonitor.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/EncoderMonitor.java Thu May 22 22:42:42 2008
@@ -77,10 +77,9 @@
/**
* Monitors callbacks that deliver a fully decoded object.
*
- * @param encoder
- * the stateful encoder driving the callback
- * @param decoded
- * the object that was decoded
+ * @param encoder the stateful encoder driving the callback
+ * @param cb the callback to call when the encoder has done its job
+ * @param decoded the object that was decoded
*/
void callbackOccured( StatefulEncoder encoder, EncoderCallback cb, Object decoded );
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/StatefulDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/StatefulDecoder.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/StatefulDecoder.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/StatefulDecoder.java Thu May 22 22:42:42 2008
@@ -39,14 +39,14 @@
public interface StatefulDecoder
{
/**
- * Decodes a peice of encoded data. The nature of this call, synchronous
+ * Decodes a piece of encoded data. The nature of this call, synchronous
* verses asynchonous, with respect to driving the actual decoding of the
* encoded data argument is determined by an implementation. A return from
- * this method does not guarrantee any callbacks: zero or more callbacks may
+ * this method does not guarantee any callbacks: zero or more callbacks may
* occur during this call.
*
- * @param encoded
- * an object representing a peice of encoded data
+ * @param encoded an object representing a piece of encoded data
+ * @throws DecoderException if the encoded element can't be decoded
*/
void decode( Object encoded ) throws DecoderException;
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/StatefulEncoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/StatefulEncoder.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/StatefulEncoder.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/StatefulEncoder.java Thu May 22 22:42:42 2008
@@ -31,12 +31,31 @@
*/
public interface StatefulEncoder
{
+ /**
+ * Encodes a Message object piece by piece often emitting chunks of the
+ * final PDU to the callback if present.
+ *
+ * @param obj the message object to encode into a PDU
+ * @throws EncoderException if there are problems while encoding
+ */
void encode( Object obj ) throws EncoderException;
+ /**
+ * Sets the callback of the underlying implementation. There is no need for
+ * any special callbacks because when encoding we do not need to transform
+ * before a value return as we did in the decoder.
+ *
+ * @param cb the callback to set on the underlying provider specific encoder
+ */
void setCallback( EncoderCallback cb );
+ /**
+ * Sets the monitor of the underlying implementation.
+ *
+ * @param monitor the monitor to set on the underlying implementation
+ */
void setEncoderMonitor( EncoderMonitor monitor );
}
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexDecoder.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexDecoder.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexDecoder.java Thu May 22 22:42:42 2008
@@ -30,7 +30,7 @@
* Document me.
*
* @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
- * $Rev$
+ * @version $Rev$
*/
public class HexDecoder extends AbstractStatefulDecoder
{
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexEncoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexEncoder.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexEncoder.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexEncoder.java Thu May 22 22:42:42 2008
@@ -33,7 +33,7 @@
* Document me.
*
* @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
- * $Rev$
+ * @version $Rev$
*/
public class HexEncoder implements StatefulEncoder
{
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/der/BERConstructedOctetString.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/der/BERConstructedOctetString.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/der/BERConstructedOctetString.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/der/BERConstructedOctetString.java Thu May 22 22:42:42 2008
@@ -55,7 +55,7 @@
/**
* Convert a vector of octet strings into a single byte string.
*/
- static private byte[] toBytes( Vector<DEREncodable> octs )
+ private static byte[] toBytes( Vector<DEREncodable> octs )
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/der/DERObjectIdentifier.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/der/DERObjectIdentifier.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/der/DERObjectIdentifier.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/der/DERObjectIdentifier.java Thu May 22 22:42:42 2008
@@ -62,6 +62,7 @@
default:
objId.append( '2' );
value -= 80;
+ break;
}
first = false;
}
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/primitives/BitString.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/primitives/BitString.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/primitives/BitString.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/primitives/BitString.java Thu May 22 22:42:42 2008
@@ -211,18 +211,18 @@
return;
}
- int nbBytes = bytes.length - 1;
+ int nbb = bytes.length - 1;
- if ( ( nbBytes > DEFAULT_LENGTH ) && ( bytes.length < nbBytes ) )
+ if ( ( nbb > DEFAULT_LENGTH ) && ( bytes.length < nbb ) )
{
// The current size is too small.
// We have to allocate more space
// TODO : implement the streaming
- bytes = new byte[nbBytes];
+ bytes = new byte[nbb];
}
- setBytes( bytes, nbBytes );
+ setBytes( bytes, nbb );
}
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/primitives/OID.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/primitives/OID.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/primitives/OID.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/primitives/OID.java Thu May 22 22:42:42 2008
@@ -91,7 +91,9 @@
/**
* Create a new OID object from a byte array
*
- * @param oid
+ * @param oid the byte array containing the OID
+ * @throws DecoderException if the byte array does not contain a
+ * valid OID
*/
public OID( byte[] oid ) throws DecoderException
{
@@ -104,6 +106,8 @@
* Create a new OID object from a String
*
* @param oid The String which is supposed to be an OID
+ * @throws DecoderException if the byte array does not contain a
+ * valid OID
*/
public OID( String oid ) throws DecoderException
{
@@ -112,25 +116,6 @@
}
- /**
- * Create a new OID object from a String
- *
- * @param oid The String which is supposed to be an OID
- */
- public OID( String oid, boolean safe )
- {
- try
- {
- setOID( oid );
- hash = computeHashCode();
- }
- catch ( DecoderException de )
- {
- // do nothing
- }
- }
-
-
// ~ Methods
// ------------------------------------------------------------------------------------
/**
@@ -138,6 +123,7 @@
* representation.
*
* @param oid The bytes containing the OID
+ * @throws DecoderException if the byte array does not contains a valid OID
*/
public void setOID( byte[] oid ) throws DecoderException
{
@@ -237,6 +223,7 @@
* OID = ( [ '0' | '1' ] '.' [ 0 .. 39 ] | '2' '.' int) ( '.' int )*
*
* @param oid The String containing the OID
+ * @throws DecoderException if the byte array does not contains a valid OID
*/
public void setOID( String oid ) throws DecoderException
{
@@ -247,14 +234,14 @@
}
int nbValues = 1;
- char[] bytes = oid.toCharArray();
+ char[] chars = oid.toCharArray();
boolean dotSeen = false;
// Count the number of int to allocate.
- for ( int i = 0; i < bytes.length; i++ )
+ for ( char c:chars )
{
- if ( bytes[i] == '.' )
+ if ( c == '.' )
{
if ( dotSeen )
@@ -289,7 +276,7 @@
boolean ituOrIso = false;
// The first value
- switch ( bytes[pos] )
+ switch ( chars[pos] )
{
case '0': // itu-t
@@ -298,7 +285,7 @@
// fallthrough
case '2': // joint-iso-itu-t
- oidValues[intPos++] = bytes[pos++] - '0';
+ oidValues[intPos++] = chars[pos++] - '0';
break;
default: // error, this value is not allowed
@@ -306,7 +293,7 @@
}
// We must have a dot
- if ( bytes[pos++] != '.' )
+ if ( chars[pos++] != '.' )
{
throw new DecoderException( "Invalid OID : " + oid );
}
@@ -315,10 +302,10 @@
int value = 0;
- for ( int i = pos; i < bytes.length; i++ )
+ for ( int i = pos; i < chars.length; i++ )
{
- if ( bytes[i] == '.' )
+ if ( chars[i] == '.' )
{
if ( dotSeen )
@@ -342,10 +329,10 @@
oidValues[intPos++] = value;
value = 0;
}
- else if ( ( bytes[i] >= 0x30 ) && ( bytes[i] <= 0x39 ) )
+ else if ( ( chars[i] >= 0x30 ) && ( chars[i] <= 0x39 ) )
{
dotSeen = false;
- value = ( ( value * 10 ) + bytes[i] ) - '0';
+ value = ( ( value * 10 ) + chars[i] ) - '0';
}
else
@@ -356,16 +343,16 @@
}
}
- oidValues[intPos++] = value;
+ oidValues[intPos] = value;
hash = computeHashCode();
}
/**
- * Get an array of int from the OID
+ * Get an array of long from the OID
*
- * @return An array of int representing the OID
+ * @return An array of long representing the OID
*/
public long[] getOIDValues()
{
@@ -526,9 +513,11 @@
/**
- * Compute the hashcode for this object. No need to copute
+ * Compute the hash code for this object. No need to compute
* it live when calling the hashCode() method, as an OID
* never change.
+ *
+ * @return the OID's hash code
*/
private int computeHashCode()
{
@@ -562,10 +551,10 @@
boolean dotSeen = false;
// Count the number of int to allocate.
- for ( int i = 0; i < bytes.length; i++ )
+ for ( byte b:bytes )
{
- if ( bytes[i] == '.' )
+ if ( b == '.' )
{
if ( dotSeen )
@@ -687,15 +676,13 @@
return sb.toString();
}
- /**
- * @see Object#hashCode()
- * @return the instance's hashcode
- */
+
public int hashCode()
{
return hash;
}
-
+
+
public boolean equals( Object oid )
{
if ( this == oid )
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/BooleanDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/BooleanDecoder.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/BooleanDecoder.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/BooleanDecoder.java Thu May 22 22:42:42 2008
@@ -21,7 +21,6 @@
import org.apache.directory.shared.asn1.ber.tlv.Value;
-import org.apache.directory.shared.asn1.codec.DecoderException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,7 +46,7 @@
* @param value
* The byte buffer to parse
* @return A boolean.
- * @throws DecoderException
+ * @throws BooleanDecoderException
* Thrown if the byte stream does not contains a boolean
*/
public static boolean parse( Value value ) throws BooleanDecoderException
Modified: directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/ber/tlv/ValueTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/ber/tlv/ValueTest.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/ber/tlv/ValueTest.java (original)
+++ directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/ber/tlv/ValueTest.java Thu May 22 22:42:42 2008
@@ -245,13 +245,13 @@
-256, -255, -128, -127, -1, 0, 1, 127, 128, 255, 256, 32767, 32768, 65535, 65536, 8388607, 8388608,
16777215, 16777216, Integer.MAX_VALUE };
- for ( int i = 0; i < testedInt.length; i++ )
+ for ( int i:testedInt )
{
- encoded = Value.getBytes( testedInt[i] );
+ encoded = Value.getBytes( i );
int value = new BigInteger( encoded ).intValue();
- Assert.assertEquals( testedInt[i], value );
+ Assert.assertEquals( i, value );
}
}
@@ -264,13 +264,13 @@
-256, -255, -128, -127, -1, 0, 1, 127, 128, 255, 256, 32767, 32768, 65535, 65536, 8388607, 8388608,
16777215, 16777216, Integer.MAX_VALUE };
- for ( int i = 0; i < testedInt.length; i++ )
+ for ( int i:testedInt )
{
- encoded = new BigInteger( Integer.toString( testedInt[i] ) ).toByteArray();
+ encoded = new BigInteger( Integer.toString( i ) ).toByteArray();
int value = IntegerDecoder.parse( new Value( encoded ) );
- Assert.assertEquals( testedInt[i], value );
+ Assert.assertEquals( i, value );
}
}
Modified: directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/codec/stateful/DecoderStackTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/codec/stateful/DecoderStackTest.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/codec/stateful/DecoderStackTest.java (original)
+++ directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/codec/stateful/DecoderStackTest.java Thu May 22 22:42:42 2008
@@ -23,10 +23,6 @@
import junit.framework.TestCase;
import org.apache.directory.shared.asn1.codec.DecoderException;
-import org.apache.directory.shared.asn1.codec.stateful.AbstractStatefulDecoder;
-import org.apache.directory.shared.asn1.codec.stateful.CallbackHistory;
-import org.apache.directory.shared.asn1.codec.stateful.DecoderStack;
-import org.apache.directory.shared.asn1.codec.stateful.StatefulDecoder;
/**
Modified: directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexDecoderTest.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexDecoderTest.java (original)
+++ directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexDecoderTest.java Thu May 22 22:42:42 2008
@@ -29,7 +29,6 @@
import org.apache.directory.shared.asn1.codec.binary.Hex;
import org.apache.directory.shared.asn1.codec.stateful.DecoderCallback;
import org.apache.directory.shared.asn1.codec.stateful.StatefulDecoder;
-import org.apache.directory.shared.asn1.codec.stateful.examples.HexDecoder;
/**
Modified: directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexEncoderTest.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexEncoderTest.java (original)
+++ directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/codec/stateful/examples/HexEncoderTest.java Thu May 22 22:42:42 2008
@@ -29,7 +29,6 @@
import org.apache.directory.shared.asn1.codec.binary.Hex;
import org.apache.directory.shared.asn1.codec.stateful.EncoderCallback;
import org.apache.directory.shared.asn1.codec.stateful.StatefulEncoder;
-import org.apache.directory.shared.asn1.codec.stateful.examples.HexEncoder;
/**
Modified: directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/BitStringTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/BitStringTest.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/BitStringTest.java (original)
+++ directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/BitStringTest.java Thu May 22 22:42:42 2008
@@ -24,7 +24,6 @@
import junit.framework.TestCase;
import org.apache.directory.shared.asn1.codec.DecoderException;
-import org.apache.directory.shared.asn1.primitives.BitString;
import org.apache.directory.shared.asn1.util.Asn1StringUtils;
Modified: directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/OIDTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/OIDTest.java?rev=659436&r1=659435&r2=659436&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/OIDTest.java (original)
+++ directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/OIDTest.java Thu May 22 22:42:42 2008
@@ -24,7 +24,6 @@
import junit.framework.TestCase;
import org.apache.directory.shared.asn1.codec.DecoderException;
-import org.apache.directory.shared.asn1.primitives.OID;
/**