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 2010/09/05 18:19:36 UTC
svn commit: r992813 - in /directory/shared/trunk:
asn1/src/main/java/org/apache/directory/shared/asn1/
asn1/src/main/java/org/apache/directory/shared/asn1/util/
i18n/src/main/java/org/apache/directory/shared/i18n/
i18n/src/main/resources/org/apache/dir...
Author: elecharny
Date: Sun Sep 5 16:19:36 2010
New Revision: 992813
URL: http://svn.apache.org/viewvc?rev=992813&view=rev
Log:
o Reviewed some asn1 files
o Fixed some error messages
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/util/Asn1StringUtils.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/BooleanDecoder.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/BooleanDecoderException.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/IntegerDecoder.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/IntegerDecoderException.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/LongDecoder.java
directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/LongDecoderException.java
directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
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=992813&r1=992812&r2=992813&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 Sun Sep 5 16:19:36 2010
@@ -126,7 +126,7 @@ public abstract class AbstractAsn1Object
if ( currentLength > expectedLength )
{
- throw new DecoderException( I18n.err( I18n.ERR_00041 ) );
+ throw new DecoderException( I18n.err( I18n.ERR_CURRENT_LENGTH_EXCEED_EXPECTED_LENGTH_00041 ) );
}
}
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java?rev=992813&r1=992812&r2=992813&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java Sun Sep 5 16:19:36 2010
@@ -30,9 +30,6 @@ import java.io.UnsupportedEncodingExcept
*/
public class Asn1StringUtils
{
- // ~ Static fields/initializers
- // -----------------------------------------------------------------
-
/** Hex chars */
private static final byte[] HEX_CHAR = new byte[]
{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
@@ -43,14 +40,20 @@ public class Asn1StringUtils
public static final byte[] EMPTY_BYTES = new byte[]
{};
- // ~ Methods
- // ------------------------------------------------------------------------------------
+
+ /**
+ * This is a helper class, there is no reason to define a public constructor for it.
+ */
+ private Asn1StringUtils()
+ {
+ // Do nothing
+ }
+
/**
* Helper function that dump a byte in hex form
*
- * @param octet
- * The byte to dump
+ * @param octet The byte to dump
* @return A string representation of the byte
*/
public static String dumpByte( byte octet )
@@ -63,8 +66,7 @@ public class Asn1StringUtils
/**
* Helper function that dump an array of bytes in hex form
*
- * @param buffer
- * The bytes array to dump
+ * @param buffer The bytes array to dump
* @return A string representation of the array of bytes
*/
public static String dumpBytes( byte[] buffer )
@@ -76,7 +78,7 @@ public class Asn1StringUtils
StringBuffer sb = new StringBuffer();
- for ( byte b:buffer )
+ for ( byte b : buffer )
{
sb.append( "0x" ).append( ( char ) ( HEX_CHAR[( b & 0x00F0 ) >> 4] ) ).append(
( char ) ( HEX_CHAR[b & 0x000F] ) ).append( " " );
@@ -89,8 +91,7 @@ public class Asn1StringUtils
/**
* Return UTF-8 encoded byte[] representation of a String
*
- * @param string
- * The string to be transformed to a byte array
+ * @param string The string to be transformed to a byte array
* @return The transformed byte array
*/
public static byte[] getBytesUtf8( String string )
@@ -111,8 +112,9 @@ public class Asn1StringUtils
}
}
+
/**
- * Thansform a string to an array of ASCII bytes, where the byte array will contain
+ * Transform a string to an array of ASCII bytes, where the byte array will contain
* only values in [0, 127].
*
* @param string The byte array to transform
@@ -124,14 +126,14 @@ public class Asn1StringUtils
{
return EMPTY_BYTES;
}
-
+
byte[] result = new byte[string.length()];
-
+
for ( int i = 0; i < result.length; i++ )
{
- result[i] = (byte)string.charAt( i );
+ result[i] = ( byte ) string.charAt( i );
}
-
+
return result;
}
}
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=992813&r1=992812&r2=992813&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 Sun Sep 5 16:19:36 2010
@@ -34,20 +34,24 @@ import org.slf4j.LoggerFactory;
public class BooleanDecoder
{
/** The logger */
- private static final Logger log = LoggerFactory.getLogger( BooleanDecoder.class );
+ private static final Logger LOG = LoggerFactory.getLogger( BooleanDecoder.class );
- // ~ Methods
- // ------------------------------------------------------------------------------------
+ /**
+ * This is a helper class, there is no reason to define a public constructor for it.
+ */
+ private BooleanDecoder()
+ {
+ // Do nothing
+ }
+
/**
* Parse a byte buffer and send back a booelan.
*
- * @param value
- * The byte buffer to parse
+ * @param value The byte buffer to parse
* @return A boolean.
- * @throws BooleanDecoderException
- * Thrown if the byte stream does not contains a boolean
+ * @throws BooleanDecoderException Thrown if the byte stream does not contains a boolean
*/
public static boolean parse( Value value ) throws BooleanDecoderException
{
@@ -55,17 +59,17 @@ public class BooleanDecoder
if ( ( bytes == null ) || ( bytes.length == 0 ) )
{
- throw new BooleanDecoderException( I18n.err( I18n.ERR_00034 ) );
+ throw new BooleanDecoderException( I18n.err( I18n.ERR_0_BYTES_LONG_BOOLEAN_00034 ) );
}
if ( bytes.length != 1 )
{
- throw new BooleanDecoderException( I18n.err( I18n.ERR_00035 ) );
+ throw new BooleanDecoderException( I18n.err( I18n.ERR_N_BYTES_LONG_BOOLEAN_00035 ) );
}
if ( ( bytes[0] != 0 ) && ( bytes[0] != ( byte ) 0xFF ) )
{
- log.warn( "A boolean must be encoded with a 0x00 or a 0xFF value" );
+ LOG.warn( "A boolean must be encoded with a 0x00 or a 0xFF value" );
}
return bytes[0] != 0;
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/BooleanDecoderException.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/BooleanDecoderException.java?rev=992813&r1=992812&r2=992813&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/BooleanDecoderException.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/BooleanDecoderException.java Sun Sep 5 16:19:36 2010
@@ -29,26 +29,18 @@ package org.apache.directory.shared.asn1
*/
public class BooleanDecoderException extends Exception
{
-
- /**
- * Declares the Serial Version Uid.
- *
- * @see <a
- * href="http://c2.com/cgi/wiki?AlwaysDeclareSerialVersionUid">Always
- * Declare Serial Version Uid</a>
- */
+ /** Declares the Serial Version Uid */
private static final long serialVersionUID = 1L;
/**
* Creates a BooleanDecoderException
*
- * @param pMessage
- * A message with meaning to a human
+ * @param message A message with meaning to a human
*/
- public BooleanDecoderException(String pMessage)
+ public BooleanDecoderException( String message )
{
- super( pMessage );
+ super( message );
}
}
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/IntegerDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/IntegerDecoder.java?rev=992813&r1=992812&r2=992813&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/IntegerDecoder.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/IntegerDecoder.java Sun Sep 5 16:19:36 2010
@@ -31,26 +31,29 @@ import org.apache.directory.shared.i18n.
*/
public class IntegerDecoder
{
+ /** A mask used to get only the necessary bytes */
private static final int[] MASK = new int[]
{ 0x000000FF, 0x0000FFFF, 0x00FFFFFF, 0xFFFFFFFF };
- // ~ Methods
- // ------------------------------------------------------------------------------------
+ /**
+ * This is a helper class, there is no reason to define a public constructor for it.
+ */
+ private IntegerDecoder()
+ {
+ // Do nothing
+ }
+
/**
- * Parse a byte buffer and send back an integer, controling that this number
+ * Parse a byte buffer and send back an integer, controlling that this number
* is in a specified interval.
*
- * @param value
- * The byte buffer to parse
- * @param min
- * Lowest value allowed, included
- * @param max
- * Highest value allowed, included
+ * @param value The byte buffer to parse
+ * @param min Lowest value allowed, included
+ * @param max Highest value allowed, included
* @return An integer
- * @throws IntegerDecoderException
- * Thrown if the byte stream does not contains an integer
+ * @throws IntegerDecoderException Thrown if the byte stream does not contains an integer
*/
public static int parse( Value value, int min, int max ) throws IntegerDecoderException
{
@@ -61,12 +64,12 @@ public class IntegerDecoder
if ( ( bytes == null ) || ( bytes.length == 0 ) )
{
- throw new IntegerDecoderException( I18n.err( I18n.ERR_00036 ) );
+ throw new IntegerDecoderException( I18n.err( I18n.ERR_0_BYTES_LONG_INTEGER_00036 ) );
}
if ( bytes.length > 4 )
{
- throw new IntegerDecoderException( I18n.err( I18n.ERR_00037 ) );
+ throw new IntegerDecoderException( I18n.err( I18n.ERR_ABOVE_4_BYTES_INTEGER_00037 ) );
}
for ( int i = 0; ( i < bytes.length ) && ( i < 5 ); i++ )
@@ -85,7 +88,7 @@ public class IntegerDecoder
}
else
{
- throw new IntegerDecoderException( I18n.err( I18n.ERR_00038, min, max ) );
+ throw new IntegerDecoderException( I18n.err( I18n.ERR_VALUE_NOT_IN_RANGE_00038, min, max ) );
}
}
@@ -93,11 +96,9 @@ public class IntegerDecoder
/**
* Parse a byte buffer and send back an integer
*
- * @param value
- * The byte buffer to parse
+ * @param value The byte buffer to parse
* @return An integer
- * @throws IntegerDecoderException
- * Thrown if the byte stream does not contains an integer
+ * @throws IntegerDecoderException Thrown if the byte stream does not contains an integer
*/
public static int parse( Value value ) throws IntegerDecoderException
{
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/IntegerDecoderException.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/IntegerDecoderException.java?rev=992813&r1=992812&r2=992813&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/IntegerDecoderException.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/IntegerDecoderException.java Sun Sep 5 16:19:36 2010
@@ -29,26 +29,17 @@ package org.apache.directory.shared.asn1
*/
public class IntegerDecoderException extends Exception
{
-
- /**
- * Declares the Serial Version Uid.
- *
- * @see <a
- * href="http://c2.com/cgi/wiki?AlwaysDeclareSerialVersionUid">Always
- * Declare Serial Version Uid</a>
- */
+ /** Declares the Serial Version Uid */
private static final long serialVersionUID = 1L;
/**
* Creates a IntegerDecoderException
*
- * @param pMessage
- * A message with meaning to a human
+ * @param message A message with meaning to a human
*/
- public IntegerDecoderException(String pMessage)
+ public IntegerDecoderException( String message )
{
- super( pMessage );
+ super( message );
}
-
}
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/LongDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/LongDecoder.java?rev=992813&r1=992812&r2=992813&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/LongDecoder.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/LongDecoder.java Sun Sep 5 16:19:36 2010
@@ -31,21 +31,20 @@ import org.apache.directory.shared.i18n.
*/
public class LongDecoder
{
+ /** A mask used to get only the necessary bytes */
private static final long[] MASK = new long[]
- {
- 0x00000000000000FFL,
- 0x000000000000FFFFL,
- 0x0000000000FFFFFFL,
- 0x00000000FFFFFFFFL,
- 0x000000FFFFFFFFFFL,
- 0x0000FFFFFFFFFFFFL,
- 0x00FFFFFFFFFFFFFFL,
- 0xFFFFFFFFFFFFFFFFL
- };
+ { 0x00000000000000FFL, 0x000000000000FFFFL, 0x0000000000FFFFFFL, 0x00000000FFFFFFFFL, 0x000000FFFFFFFFFFL,
+ 0x0000FFFFFFFFFFFFL, 0x00FFFFFFFFFFFFFFL, 0xFFFFFFFFFFFFFFFFL };
- // ~ Methods
- // ------------------------------------------------------------------------------------
+ /**
+ * This is a helper class, there is no reason to define a public constructor for it.
+ */
+ private LongDecoder()
+ {
+ // Do nothing
+ }
+
/**
* Parse a byte buffer and send back an long, controlling that this number
@@ -55,24 +54,22 @@ public class LongDecoder
* @param min Lowest value allowed, included
* @param max Highest value allowed, included
* @return An integer
- * @throws LongDecoderException
- * Thrown if the byte stream does not contains an integer
+ * @throws LongDecoderException Thrown if the byte stream does not contains an integer
*/
public static long parse( Value value, long min, long max ) throws LongDecoderException
{
-
long result = 0;
byte[] bytes = value.getData();
if ( ( bytes == null ) || ( bytes.length == 0 ) )
{
- throw new LongDecoderException( I18n.err( I18n.ERR_00039 ) );
+ throw new LongDecoderException( I18n.err( I18n.ERR_0_BYTES_LONG_LONG_00039 ) );
}
if ( bytes.length > 8 )
{
- throw new LongDecoderException( I18n.err( I18n.ERR_00039 ) );
+ throw new LongDecoderException( I18n.err( I18n.ERR_0_BYTES_LONG_LONG_00039 ) );
}
for ( int i = 0; ( i < bytes.length ) && ( i < 9 ); i++ )
@@ -91,7 +88,7 @@ public class LongDecoder
}
else
{
- throw new LongDecoderException( I18n.err( I18n.ERR_00038, min, max ) );
+ throw new LongDecoderException( I18n.err( I18n.ERR_VALUE_NOT_IN_RANGE_00038, min, max ) );
}
}
@@ -101,8 +98,7 @@ public class LongDecoder
*
* @param value The byte buffer to parse
* @return An integer
- * @throws IntegerDecoderException
- * Thrown if the byte stream does not contains an integer
+ * @throws LongDecoderException Thrown if the byte stream does not contains an integer
*/
public static long parse( Value value ) throws LongDecoderException
{
Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/LongDecoderException.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/LongDecoderException.java?rev=992813&r1=992812&r2=992813&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/LongDecoderException.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/util/LongDecoderException.java Sun Sep 5 16:19:36 2010
@@ -30,13 +30,7 @@ package org.apache.directory.shared.asn1
public class LongDecoderException extends Exception
{
- /**
- * Declares the Serial Version Uid.
- *
- * @see <a
- * href="http://c2.com/cgi/wiki?AlwaysDeclareSerialVersionUid">Always
- * Declare Serial Version Uid</a>
- */
+ /** Declares the Serial Version Uid */
private static final long serialVersionUID = 1L;
@@ -45,9 +39,8 @@ public class LongDecoderException extend
*
* @param message A message with meaning to a human
*/
- public LongDecoderException(String message)
+ public LongDecoderException( String message )
{
super( message );
}
-
}
Modified: directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java?rev=992813&r1=992812&r2=992813&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java (original)
+++ directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java Sun Sep 5 16:19:36 2010
@@ -68,14 +68,13 @@ public enum I18n
ERR_CANNOT_FIND_BIT_00031( "ERR_CANNOT_FIND_BIT_00031" ),
ERR_NULL_OID_00032( "ERR_NULL_OID_00032" ),
ERR_INVALID_OID_00033( "ERR_INVALID_OID_00033" ),
- ERR_00034( "ERR_00034" ),
- ERR_00035( "ERR_00035" ),
- ERR_00036( "ERR_00036" ),
- ERR_00037( "ERR_00037" ),
- ERR_00038( "ERR_00038" ),
- ERR_00039( "ERR_00039" ),
- ERR_00040( "ERR_00040" ),
- ERR_00041( "ERR_00041" ),
+ ERR_0_BYTES_LONG_BOOLEAN_00034( "ERR_0_BYTES_LONG_BOOLEAN_00034" ),
+ ERR_N_BYTES_LONG_BOOLEAN_00035( "ERR_N_BYTES_LONG_BOOLEAN_00035" ),
+ ERR_0_BYTES_LONG_INTEGER_00036( "ERR_0_BYTES_LONG_INTEGER_00036" ),
+ ERR_ABOVE_4_BYTES_INTEGER_00037( "ERR_ABOVE_4_BYTES_INTEGER_00037" ),
+ ERR_VALUE_NOT_IN_RANGE_00038( "ERR_VALUE_NOT_IN_RANGE_00038" ),
+ ERR_0_BYTES_LONG_LONG_00039( "ERR_0_BYTES_LONG_LONG_00039" ),
+ ERR_CURRENT_LENGTH_EXCEED_EXPECTED_LENGTH_00041( "ERR_CURRENT_LENGTH_EXCEED_EXPECTED_LENGTH_00041" ),
ERR_PDU_SIZE_TOO_LONG_00042( "ERR_PDU_SIZE_TOO_LONG_00042" ),
ERR_REMAINING_BYTES_FOR_DECODED_PDU_00043( "ERR_REMAINING_BYTES_FOR_DECODED_PDU_00043" ),
Modified: directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties?rev=992813&r1=992812&r2=992813&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties (original)
+++ directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties Sun Sep 5 16:19:36 2010
@@ -52,14 +52,13 @@ ERR_BIT_NUMBER_OUT_OF_BOUND_00030=Bad bi
ERR_CANNOT_FIND_BIT_00031=Cannot get a bit at position {0} when the BitString contains only {1} ints
ERR_NULL_OID_00032=Null OID
ERR_INVALID_OID_00033=Invalid OID : {0}
-ERR_00034=The value is 0 byte long. This is not allowed for a boolean
-ERR_00035=The value is not 1 byte long. This is not allowed for a boolean
-ERR_00036=The value is 0 byte long. This is not allowed for an integer
-ERR_00037=The value is more than 4 bytes long. This is not allowed for an integer
-ERR_00038=The value is not in the range [{0}, {1}]
-ERR_00039=The value is 0 byte long. This is not allowed for a long
-ERR_00040=The value is more than 4 bytes long. This is not allowed for a long
-ERR_00041=Current Length is above expected Length
+ERR_0_BYTES_LONG_BOOLEAN_00034=The value is 0 byte long. This is not allowed for a boolean
+ERR_N_BYTES_LONG_BOOLEAN_00035=The value is not 1 byte long. This is not allowed for a boolean
+ERR_0_BYTES_LONG_INTEGER_00036=The value is 0 byte long. This is not allowed for an integer
+ERR_ABOVE_4_BYTES_INTEGER_00037=The value is more than 4 bytes long. This is not allowed for an integer
+ERR_VALUE_NOT_IN_RANGE_00038=The value is not in the range [{0}, {1}]
+ERR_0_BYTES_LONG_LONG_00039=The value is 0 byte long. This is not allowed for a long
+ERR_CURRENT_LENGTH_EXCEED_EXPECTED_LENGTH_00041=Current Length is above expected Length
ERR_PDU_SIZE_TOO_LONG_00042=The PDU current size ({1}) exceeds the maximum allowed PDU size ({2})
ERR_REMAINING_BYTES_FOR_DECODED_PDU_00043=The PDU has been fully decoded but there are still bytes in the buffer.