directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1235383 - in /directory/shared/trunk/asn1/api/src: main/java/org/apache/directory/shared/asn1/ main/java/org/apache/directory/shared/asn1/util/ test/java/org/apache/directory/shared/asn1/util/
Date Tue, 24 Jan 2012 18:06:40 GMT
Author: elecharny
Date: Tue Jan 24 18:06:39 2012
New Revision: 1235383

URL: http://svn.apache.org/viewvc?rev=1235383&view=rev
Log:
o Added some missing Javadoc
o Cleaned up the Javadoc
o Removed a useless abstract method

Modified:
    directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/AbstractAsn1Object.java
    directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/Asn1Object.java
    directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/Encoder.java
    directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/EncoderException.java
    directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java
    directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/util/BitString.java
    directory/shared/trunk/asn1/api/src/test/java/org/apache/directory/shared/asn1/util/BitStringTest.java
    directory/shared/trunk/asn1/api/src/test/java/org/apache/directory/shared/asn1/util/OidTest.java

Modified: directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/AbstractAsn1Object.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/AbstractAsn1Object.java?rev=1235383&r1=1235382&r2=1235383&view=diff
==============================================================================
--- directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/AbstractAsn1Object.java
(original)
+++ directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/AbstractAsn1Object.java
Tue Jan 24 18:06:39 2012
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ * 
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ * 
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ * 
  */
 package org.apache.directory.shared.asn1;
 
@@ -46,7 +46,7 @@ public abstract class AbstractAsn1Object
 
 
     /**
-     * Constructor associated with a TLV identifier. Used when 
+     * Constructor associated with a TLV identifier. Used when
      * decoded a TLV, we create an association between the decode
      * Asn1Object and the TLV which is the encoded form.
      * 
@@ -69,31 +69,21 @@ public abstract class AbstractAsn1Object
 
 
     /**
-     * Get the current object length, which is the sum of all inner length
-     * already decoded.
-     * 
-     * @return The current object's length
+     * {@inheritDoc}
      */
-    public int getCurrentLength()
+    public void addLength( int length ) throws DecoderException
     {
-        return currentLength;
-    }
-
+        currentLength += length;
 
-    /**
-     * Compute the object length, which is the sum of all inner length.
-     * 
-     * @return The object's computed length
-     */
-    public abstract int computeLength();
+        if ( currentLength > expectedLength )
+        {
+            throw new DecoderException( I18n.err( I18n.ERR_00041_CURRENT_LENGTH_EXCEED_EXPECTED_LENGTH
) );
+        }
+    }
 
 
     /**
-     * Encode the object to a PDU.
-     * 
-     * @param buffer The buffer where to put the PDU
-     * @return The PDU.
-     * @throws EncoderException if the buffer can't be encoded
+     * {@inheritDoc}
      */
     public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
     {
@@ -102,59 +92,43 @@ public abstract class AbstractAsn1Object
 
 
     /**
-     * Get the expected object length.
-     * 
-     * @return The expected object's length
+     * {@inheritDoc}
      */
-    public int getExpectedLength()
+    public int getCurrentLength()
     {
-        return expectedLength;
+        return currentLength;
     }
 
 
     /**
-     * Add a length to the object
-     * 
-     * @param length The length to add.
-     * @throws DecoderException Thrown if the current length exceed the expected length
+     * {@inheritDoc}
      */
-    public void addLength( int length ) throws DecoderException
+    public void setCurrentLength( int currentLength )
     {
-        currentLength += length;
-
-        if ( currentLength > expectedLength )
-        {
-            throw new DecoderException( I18n.err( I18n.ERR_00041_CURRENT_LENGTH_EXCEED_EXPECTED_LENGTH
) );
-        }
+        this.currentLength = currentLength;
     }
 
 
     /**
-     * Set the expected length
-     * 
-     * @param expectedLength The expectedLength to set.
+     * {@inheritDoc}
      */
-    public void setExpectedLength( int expectedLength )
+    public int getExpectedLength()
     {
-        this.expectedLength = expectedLength;
+        return expectedLength;
     }
 
 
     /**
-     * Set the current length
-     * 
-     * @param currentLength The currentLength to set.
+     * {@inheritDoc}
      */
-    public void setCurrentLength( int currentLength )
+    public void setExpectedLength( int expectedLength )
     {
-        this.currentLength = currentLength;
+        this.expectedLength = expectedLength;
     }
 
 
     /**
-     * Get the parent
-     * 
-     * @return Returns the parent.
+     * {@inheritDoc}
      */
     public AbstractAsn1Object getParent()
     {
@@ -163,7 +137,7 @@ public abstract class AbstractAsn1Object
 
 
     /**
-     * Set the parent
+     * Sets the parent
      * 
      * @param parent The parent to set.
      */

Modified: directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/Asn1Object.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/Asn1Object.java?rev=1235383&r1=1235382&r2=1235383&view=diff
==============================================================================
--- directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/Asn1Object.java
(original)
+++ directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/Asn1Object.java
Tue Jan 24 18:06:39 2012
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ * 
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ * 
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ * 
  */
 package org.apache.directory.shared.asn1;
 
@@ -31,12 +31,12 @@ import java.nio.ByteBuffer;
 public interface Asn1Object
 {
     /**
-     * Get the current object length, which is the sum of all inner length
-     * already decoded.
+     * Add a length to the object
      * 
-     * @return The current object's length
+     * @param length The length to add.
+     * @throws DecoderException Thrown if the current length exceed the expected length
      */
-    int getCurrentLength();
+    void addLength( int length ) throws DecoderException;
 
 
     /**
@@ -51,35 +51,35 @@ public interface Asn1Object
      * Encode the object to a PDU.
      * 
      * @param buffer The buffer where to put the PDU
-     * @return The PDU.
+     * @return The encoded PDU.
      * @throws EncoderException if the buffer can't be encoded
      */
     ByteBuffer encode( ByteBuffer buffer ) throws EncoderException;
 
 
     /**
-     * Get the expected object length.
+     * Get the current object length, which is the sum of all inner length
+     * already decoded.
      * 
-     * @return The expected object's length
+     * @return The current object's length
      */
-    int getExpectedLength();
+    int getCurrentLength();
 
 
     /**
-     * Add a length to the object
+     * Get the expected object length.
      * 
-     * @param length The length to add.
-     * @throws DecoderException Thrown if the current length exceed the expected length
+     * @return The expected object's length
      */
-    void addLength( int length ) throws DecoderException;
+    int getExpectedLength();
 
 
     /**
-     * Set the expected length
+     * Get the parent
      * 
-     * @param expectedLength The expectedLength to set.
+     * @return Returns the parent.
      */
-    void setExpectedLength( int expectedLength );
+    Asn1Object getParent();
 
 
     /**
@@ -91,9 +91,9 @@ public interface Asn1Object
 
 
     /**
-     * Get the parent
+     * Set the expected length
      * 
-     * @return Returns the parent.
+     * @param expectedLength The expectedLength to set.
      */
-    Asn1Object getParent();
+    void setExpectedLength( int expectedLength );
 }

Modified: directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/Encoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/Encoder.java?rev=1235383&r1=1235382&r2=1235383&view=diff
==============================================================================
--- directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/Encoder.java
(original)
+++ directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/Encoder.java
Tue Jan 24 18:06:39 2012
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ * 
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ * 
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ * 
  */
 
 package org.apache.directory.shared.asn1;
@@ -34,13 +34,12 @@ package org.apache.directory.shared.asn1
  */
 public interface Encoder
 {
-
     /**
      * Encodes an "Object" and returns the encoded content as an Object. The
      * Objects here may just be <code>byte[]</code> or <code>String</code>s
      * depending on the implementation used.
      * 
-     * @param object An object ot encode
+     * @param object An object to encode
      * @return An "encoded" Object
      * @throws EncoderException an encoder exception is thrown if the encoder experiences
a
      * failure condition during the encoding process.

Modified: directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/EncoderException.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/EncoderException.java?rev=1235383&r1=1235382&r2=1235383&view=diff
==============================================================================
--- directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/EncoderException.java
(original)
+++ directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/EncoderException.java
Tue Jan 24 18:06:39 2012
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ * 
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ * 
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ * 
  */
 
 package org.apache.directory.shared.asn1;
@@ -31,7 +31,6 @@ package org.apache.directory.shared.asn1
  */
 public class EncoderException extends Exception
 {
-
     /** Declares the Serial Version Uid */
     private static final long serialVersionUID = 1L;
 

Modified: directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java?rev=1235383&r1=1235382&r2=1235383&view=diff
==============================================================================
--- directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java
(original)
+++ directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java
Tue Jan 24 18:06:39 2012
@@ -24,7 +24,7 @@ import java.io.UnsupportedEncodingExcept
 
 
 /**
- * Little helper class.
+ * Little helper class for the asn1 package.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -98,8 +98,7 @@ public final class Asn1StringUtils
         }
         catch ( UnsupportedEncodingException uee )
         {
-            return new byte[]
-                {};
+            return EMPTY_BYTES;
         }
     }
 

Modified: directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/util/BitString.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/util/BitString.java?rev=1235383&r1=1235382&r2=1235383&view=diff
==============================================================================
--- directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/util/BitString.java
(original)
+++ directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/shared/asn1/util/BitString.java
Tue Jan 24 18:06:39 2012
@@ -78,7 +78,7 @@ public class BitString
 
 
     /**
-     * Creates a BitString from a byte[]. As the first byteis the number of unused bits
+     * Creates a BitString from a byte[]. As the first byte is the number of unused bits
      * in the last byte, we have to ignore it.
      *
      * @param bytes The value to store. The first byte contains the number of

Modified: directory/shared/trunk/asn1/api/src/test/java/org/apache/directory/shared/asn1/util/BitStringTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/api/src/test/java/org/apache/directory/shared/asn1/util/BitStringTest.java?rev=1235383&r1=1235382&r2=1235383&view=diff
==============================================================================
--- directory/shared/trunk/asn1/api/src/test/java/org/apache/directory/shared/asn1/util/BitStringTest.java
(original)
+++ directory/shared/trunk/asn1/api/src/test/java/org/apache/directory/shared/asn1/util/BitStringTest.java
Tue Jan 24 18:06:39 2012
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ * 
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ * 
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ * 
  */
 package org.apache.directory.shared.asn1.util;
 
@@ -41,9 +41,6 @@ import com.mycila.junit.concurrent.Concu
 @Concurrency()
 public class BitStringTest
 {
-    // ~ Methods
-    // ------------------------------------------------------------------------------------
-
     /**
      * Test a null BitString
      */

Modified: directory/shared/trunk/asn1/api/src/test/java/org/apache/directory/shared/asn1/util/OidTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/api/src/test/java/org/apache/directory/shared/asn1/util/OidTest.java?rev=1235383&r1=1235382&r2=1235383&view=diff
==============================================================================
--- directory/shared/trunk/asn1/api/src/test/java/org/apache/directory/shared/asn1/util/OidTest.java
(original)
+++ directory/shared/trunk/asn1/api/src/test/java/org/apache/directory/shared/asn1/util/OidTest.java
Tue Jan 24 18:06:39 2012
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ * 
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ * 
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ * 
  */
 package org.apache.directory.shared.asn1.util;
 
@@ -42,9 +42,6 @@ import com.mycila.junit.concurrent.Concu
 @Concurrency()
 public class OidTest
 {
-    // ~ Methods
-    // ------------------------------------------------------------------------------------
-
     /**
      * Test a null Oid
      */



Mime
View raw message