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:39:44 UTC

svn commit: r992819 - in /directory/shared/trunk: asn1/src/main/java/org/apache/directory/shared/asn1/codec/ asn1/src/main/java/org/apache/directory/shared/asn1/codec/binary/ i18n/src/main/java/org/apache/directory/shared/i18n/ i18n/src/main/resources/...

Author: elecharny
Date: Sun Sep  5 16:39:44 2010
New Revision: 992819

URL: http://svn.apache.org/viewvc?rev=992819&view=rev
Log:
o Reviewed some asn1 files
o Fixed some error messages
o Removed useless class

Removed:
    directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/binary/BinaryCodec.java
Modified:
    directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/BinaryDecoder.java
    directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/BinaryEncoder.java
    directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/Decoder.java
    directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/DecoderException.java
    directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/Encoder.java
    directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/EncoderException.java
    directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/binary/Hex.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/codec/BinaryDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/BinaryDecoder.java?rev=992819&r1=992818&r2=992819&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/BinaryDecoder.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/BinaryDecoder.java Sun Sep  5 16:39:44 2010
@@ -28,17 +28,14 @@ package org.apache.directory.shared.asn1
  */
 public interface BinaryDecoder extends Decoder
 {
-
     /**
      * Decodes a byte array and returns the results as a byte array.
      * 
-     * @param pArray
-     *            A byte array which has been encoded with the appropriate
-     *            encoder
+     * @param array A byte array which has been encoded with the appropriate encoder
      * @return a byte array that contains decoded content
      * @throws org.apache.directory.shared.asn1.codec.DecoderException
-     *             A decoder exception is thrown if a Decoder encounters a
-     *             failure condition during the decode process.
+     * A decoder exception is thrown if a Decoder encounters a
+     * failure condition during the decode process.
      */
-    byte[] decode( byte[] pArray ) throws DecoderException;
+    byte[] decode( byte[] array ) throws DecoderException;
 }

Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/BinaryEncoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/BinaryEncoder.java?rev=992819&r1=992818&r2=992819&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/BinaryEncoder.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/BinaryEncoder.java Sun Sep  5 16:39:44 2010
@@ -32,12 +32,10 @@ public interface BinaryEncoder extends E
     /**
      * Encodes a byte array and return the encoded data as a byte array.
      * 
-     * @param pArray
-     *            Data to be encoded
+     * @param array Data to be encoded
      * @return A byte array containing the encoded data
-     * @throws EncoderException
-     *             thrown if the Encoder encounters a failure condition during
-     *             the encoding process.
+     * @throws EncoderException thrown if the Encoder encounters a failure condition during
+     * the encoding process.
      */
-    byte[] encode( byte[] pArray ) throws EncoderException;
+    byte[] encode( byte[] array ) throws EncoderException;
 }

Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/Decoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/Decoder.java?rev=992819&r1=992818&r2=992819&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/Decoder.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/Decoder.java Sun Sep  5 16:39:44 2010
@@ -47,14 +47,11 @@ public interface Decoder
      * {@link java.lang.ClassCastException} occurs this decode method will throw
      * a DecoderException.
      * 
-     * @param pObject
-     *            an object to "decode"
+     * @param object an object to "decode"
      * @return a 'decoded" object
-     * @throws DecoderException
-     *             a decoder exception can be thrown for any number of reasons.
-     *             Some good candidates are that the parameter passed to this
-     *             method is null, a param cannot be cast to the appropriate
-     *             type for a specific encoder.
+     * @throws DecoderException a decoder exception can be thrown for any number of reasons.
+     * Some good candidates are that the parameter passed to this method is null, a param 
+     * cannot be cast to the appropriate type for a specific encoder.
      */
-    Object decode( Object pObject ) throws DecoderException;
+    Object decode( Object object ) throws DecoderException;
 }

Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/DecoderException.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/DecoderException.java?rev=992819&r1=992818&r2=992819&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/DecoderException.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/DecoderException.java Sun Sep  5 16:39:44 2010
@@ -28,24 +28,16 @@ package org.apache.directory.shared.asn1
  */
 public class DecoderException 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 DecoderException
      * 
-     * @param message
-     *            A message with meaning to a human
+     * @param message A message with meaning to a human
      */
-    public DecoderException(String message)
+    public DecoderException( String message )
     {
         super( message );
     }
@@ -54,14 +46,11 @@ public class DecoderException extends Ex
     /**
      * Creates a DecoderException
      * 
-     * @param message
-     *            A message with meaning to a human
-     * @param cause
-     *            The Exception which caused the error
+     * @param message A message with meaning to a human
+     * @param cause The Exception which caused the error
      */
-    public DecoderException(String message, Throwable cause)
+    public DecoderException( String message, Throwable cause )
     {
         super( message, cause );
     }
-
 }

Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/Encoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/Encoder.java?rev=992819&r1=992818&r2=992819&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/Encoder.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/Encoder.java Sun Sep  5 16:39:44 2010
@@ -40,12 +40,10 @@ public interface Encoder
      * Objects here may just be <code>byte[]</code> or <code>String</code>s
      * depending on the implementation used.
      * 
-     * @param pObject
-     *            An object ot encode
+     * @param object An object ot encode
      * @return An "encoded" Object
-     * @throws EncoderException
-     *             an encoder exception is thrown if the encoder experiences a
-     *             failure condition during the encoding process.
+     * @throws EncoderException an encoder exception is thrown if the encoder experiences a
+     * failure condition during the encoding process.
      */
-    Object encode( Object pObject ) throws EncoderException;
+    Object encode( Object object ) throws EncoderException;
 }

Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/EncoderException.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/EncoderException.java?rev=992819&r1=992818&r2=992819&view=diff
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/EncoderException.java (original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/codec/EncoderException.java Sun Sep  5 16:39:44 2010
@@ -32,24 +32,17 @@ package org.apache.directory.shared.asn1
 public class EncoderException 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 new instance of this exception with an useful message.
      * 
-     * @param pMessage
-     *            a useful message relating to the encoder specific error.
+     * @param message a useful message relating to the encoder specific error.
      */
-    public EncoderException(String pMessage)
+    public EncoderException( String message )
     {
-        super( pMessage );
+        super( message );
     }
 }

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=992819&r1=992818&r2=992819&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 Sun Sep  5 16:39:44 2010
@@ -31,15 +31,11 @@ import org.apache.directory.shared.i18n.
 /**
  * Hex encoder and decoder.
  * 
- * @since 1.1
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class Hex implements BinaryEncoder, BinaryDecoder
 {
-
-    /**
-     * Used to build output as Hex
-     */
+    /** Used to build output as Hex */
     private static final char[] DIGITS =
         { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
 
@@ -51,21 +47,18 @@ public class Hex implements BinaryEncode
      * given byte. An exception is thrown if the passed char array has an odd
      * number of elements.
      * 
-     * @param data
-     *            An array of characters containing hexidecimal digits
+     * @param data An array of characters containing hexidecimal digits
      * @return A byte array containing binary data decoded from the supplied
-     *         char array.
-     * @throws DecoderException
-     *             Thrown if an odd number or illegal of characters is supplied
+     * char array.
+     * @throws DecoderException Thrown if an odd number or illegal of characters is supplied
      */
     public static byte[] decodeHex( char[] data ) throws DecoderException
     {
-
         int len = data.length;
 
         if ( ( len & 0x01 ) != 0 )
         {
-            throw new DecoderException( I18n.err( I18n.ERR_00013 ) );
+            throw new DecoderException( I18n.err( I18n.ERR_ODD_NUM_OF_CHARS_00013 ) );
         }
 
         byte[] out = new byte[len >> 1];
@@ -87,21 +80,20 @@ public class Hex implements BinaryEncode
     /**
      * Converts a hexadecimal character to an integer.
      * 
-     * @param ch
-     *            A character to convert to an integer digit
-     * @param index
-     *            The index of the character in the source
+     * @param ch A character to convert to an integer digit
+     * @param index The index of the character in the source
      * @return An integer
-     * @throws DecoderException
-     *             Thrown if ch is an illegal hex character
+     * @throws DecoderException Thrown if ch is an illegal hex character
      */
-    protected static int toDigit( char ch, int index ) throws DecoderException
+    private static int toDigit( char ch, int index ) throws DecoderException
     {
         int digit = Character.digit( ch, 16 );
+
         if ( digit == -1 )
         {
-            throw new DecoderException( I18n.err( I18n.ERR_00014, ch, index ) );
+            throw new DecoderException( I18n.err( I18n.ERR_ILLEGAL_HEX_CHAR_00014, ch, index ) );
         }
+
         return digit;
     }
 
@@ -112,13 +104,11 @@ public class Hex implements BinaryEncode
      * double the length of the passed array, as it takes two characters to
      * represent any given byte.
      * 
-     * @param data
-     *            a byte[] to convert to Hex characters
+     * @param data a byte[] to convert to Hex characters
      * @return A char[] containing hexidecimal characters
      */
     public static char[] encodeHex( byte[] data )
     {
-
         int l = data.length;
 
         char[] out = new char[l << 1];
@@ -141,13 +131,11 @@ public class Hex implements BinaryEncode
      * any given byte. An exception is thrown if the passed char array has an
      * odd number of elements.
      * 
-     * @param array
-     *            An array of character bytes containing hexidecimal digits
+     * @param array An array of character bytes containing hexidecimal digits
      * @return A byte array containing binary data decoded from the supplied
-     *         byte array (representing characters).
-     * @throws DecoderException
-     *             Thrown if an odd number of characters is supplied to this
-     *             function
+     * byte array (representing characters).
+     * @throws DecoderException Thrown if an odd number of characters is supplied to this
+     * function
      * @see #decodeHex(char[])
      */
     public byte[] decode( byte[] array ) throws DecoderException
@@ -163,21 +151,29 @@ public class Hex implements BinaryEncode
      * characters to represent any given byte. An exception is thrown if the
      * passed char array has an odd number of elements.
      * 
-     * @param object
-     *            A String or, an array of character bytes containing
-     *            hexidecimal digits
+     * @param object A String or, an array of character bytes containing
+     * hexadecimal digits
      * @return A byte array containing binary data decoded from the supplied
-     *         byte array (representing characters).
-     * @throws DecoderException
-     *             Thrown if an odd number of characters is supplied to this
-     *             function or the object is not a String or char[]
+     * byte array (representing characters).
+     * @throws DecoderException Thrown if an odd number of characters is supplied to this
+     * function or the object is not a String or char[]
      * @see #decodeHex(char[])
      */
     public Object decode( Object object ) throws DecoderException
     {
         try
         {
-            char[] charArray = object instanceof String ? ( ( String ) object ).toCharArray() : ( char[] ) object;
+            char[] charArray = null;
+
+            if ( object instanceof String )
+            {
+                charArray = ( ( String ) object ).toCharArray();
+            }
+            else
+            {
+                charArray = ( char[] ) object;
+            }
+
             return decodeHex( charArray );
         }
         catch ( ClassCastException e )
@@ -193,8 +189,7 @@ public class Hex implements BinaryEncode
      * array will be double the length of the passed array, as it takes two
      * characters to represent any given byte.
      * 
-     * @param array
-     *            a byte[] to convert to Hex characters
+     * @param array a byte[] to convert to Hex characters
      * @return A byte[] containing the bytes of the hexidecimal characters
      * @see #encodeHex(byte[])
      */
@@ -210,18 +205,26 @@ public class Hex implements BinaryEncode
      * array will be double the length of the passed String or array, as it
      * takes two characters to represent any given byte.
      * 
-     * @param object
-     *            a String, or byte[] to convert to Hex characters
+     * @param object a String, or byte[] to convert to Hex characters
      * @return A char[] containing hexidecimal characters
-     * @throws EncoderException
-     *             Thrown if the given object is not a String or byte[]
+     * @throws EncoderException Thrown if the given object is not a String or byte[]
      * @see #encodeHex(byte[])
      */
     public Object encode( Object object ) throws EncoderException
     {
         try
         {
-            byte[] byteArray = object instanceof String ? ( ( String ) object ).getBytes() : ( byte[] ) object;
+            byte[] byteArray = null;
+
+            if ( object instanceof String )
+            {
+                byteArray = ( ( String ) object ).getBytes();
+            }
+            else
+            {
+                byteArray = ( byte[] ) object;
+            }
+
             return encodeHex( byteArray );
         }
         catch ( ClassCastException e )
@@ -229,5 +232,4 @@ public class Hex implements BinaryEncode
             throw new EncoderException( e.getMessage() );
         }
     }
-
 }

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=992819&r1=992818&r2=992819&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:39:44 2010
@@ -47,8 +47,8 @@ public enum I18n
     ERR_TRUNCATED_PDU_00010( "ERR_TRUNCATED_PDU_00010" ),
     ERR_LENGTH_TOO_LONG_FOR_DEFINITE_FORM_00011( "ERR_LENGTH_TOO_LONG_FOR_DEFINITE_FORM_00011" ),
     ERR_00012( "ERR_00012" ),
-    ERR_00013( "ERR_00013" ),
-    ERR_00014( "ERR_00014" ),
+    ERR_ODD_NUM_OF_CHARS_00013( "ERR_ODD_NUM_OF_CHARS_00013" ),
+    ERR_ILLEGAL_HEX_CHAR_00014( "ERR_ILLEGAL_HEX_CHAR_00014" ),
     ERR_00015( "ERR_00015" ),
     ERR_00016( "ERR_00016" ),
     ERR_00017( "ERR_00017" ),

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=992819&r1=992818&r2=992819&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:39:44 2010
@@ -31,8 +31,8 @@ ERR_MORE_TLV_EXPECTED_00009=The PDU is d
 ERR_TRUNCATED_PDU_00010=Truncated PDU. Some elements are lacking, accordingly to the grammar
 ERR_LENGTH_TOO_LONG_FOR_DEFINITE_FORM_00011=Length above 126 bytes are not allowed for a definite form Length
 ERR_00012=argument not a byte array
-ERR_00013=Odd number of characters.
-ERR_00014=Illegal hexadecimal character {0} at index {1}
+ERR_ODD_NUM_OF_CHARS_00013=Odd number of characters.
+ERR_ILLEGAL_HEX_CHAR_00014=Illegal hexadecimal character {0} at index {1}
 ERR_00015=non-hex character ''{0}'' encountered
 ERR_00016=End of stream.
 ERR_00017=EOF found when length expected.