directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r488299 - in /directory/trunks/shared/asn1/src: main/java/org/apache/directory/shared/asn1/ main/java/org/apache/directory/shared/asn1/ber/ test/java/org/apache/directory/shared/asn1/ber/tlv/
Date Mon, 18 Dec 2006 15:07:42 GMT
Author: elecharny
Date: Mon Dec 18 07:07:41 2006
New Revision: 488299

URL: http://svn.apache.org/viewvc?view=rev&rev=488299
Log:
Fixed warnings
Asn1Object is now an interface
Created an AbstractAsn1Object which implements Asn1Object

Added:
    directory/trunks/shared/asn1/src/main/java/org/apache/directory/shared/asn1/AbstractAsn1Object.java
Modified:
    directory/trunks/shared/asn1/src/main/java/org/apache/directory/shared/asn1/Asn1Object.java
    directory/trunks/shared/asn1/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Decoder.java
    directory/trunks/shared/asn1/src/test/java/org/apache/directory/shared/asn1/ber/tlv/ValueTest.java

Added: directory/trunks/shared/asn1/src/main/java/org/apache/directory/shared/asn1/AbstractAsn1Object.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/asn1/src/main/java/org/apache/directory/shared/asn1/AbstractAsn1Object.java?view=auto&rev=488299
==============================================================================
--- directory/trunks/shared/asn1/src/main/java/org/apache/directory/shared/asn1/AbstractAsn1Object.java
(added)
+++ directory/trunks/shared/asn1/src/main/java/org/apache/directory/shared/asn1/AbstractAsn1Object.java
Mon Dec 18 07:07:41 2006
@@ -0,0 +1,160 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  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. 
+ *  
+ */
+package org.apache.directory.shared.asn1;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.asn1.codec.EncoderException;
+
+
+/**
+ * An abstract class which implements basic TLV operations.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class AbstractAsn1Object implements Asn1Object
+{
+    // ~ Instance fields
+    // ----------------------------------------------------------------------------
+
+    /** The object's current length. It is used while decoding PDUs */
+    private transient int currentLength;
+
+    /** The object's expected length. It is used while decoding PDUs */
+    private transient int expectedLength;
+
+    /** The encapsulating Object */
+    protected transient AbstractAsn1Object parent;
+
+
+    // ~ Methods
+    // ------------------------------------------------------------------------------------
+
+    /**
+     * Get the current object length, which is the sum of all inner length
+     * already decoded.
+     * 
+     * @return The current object's length
+     */
+    public int getCurrentLength()
+    {
+        return currentLength;
+    }
+
+
+    /**
+     * Compute the object length, which is the sum of all inner length.
+     * 
+     * @return The object's computed length
+     */
+    public abstract int computeLength();
+
+
+    /**
+     * Encode the object to a PDU.
+     * 
+     * @param buffer
+     *            The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        return null;
+    }
+
+
+    /**
+     * Get the expected object length.
+     * 
+     * @return The expected object's length
+     */
+    public int getExpectedLength()
+    {
+        return expectedLength;
+    }
+
+
+    /**
+     * Add a length to the object
+     * 
+     * @param length
+     *            The length to add.
+     * @throws DecoderException
+     *             Thrown if the current length exceed the expected length
+     */
+    public void addLength( int length ) throws DecoderException
+    {
+        currentLength += length;
+
+        if ( currentLength > expectedLength )
+        {
+            throw new DecoderException( "Current Length is above expected Length" );
+        }
+    }
+
+
+    /**
+     * Set the expected length
+     * 
+     * @param expectedLength
+     *            The expectedLength to set.
+     */
+    public void setExpectedLength( int expectedLength )
+    {
+        this.expectedLength = expectedLength;
+    }
+
+
+    /**
+     * Set the current length
+     * 
+     * @param currentLength
+     *            The currentLength to set.
+     */
+    public void setCurrentLength( int currentLength )
+    {
+        this.currentLength = currentLength;
+    }
+
+
+    /**
+     * Get the parent
+     * 
+     * @return Returns the parent.
+     */
+    public AbstractAsn1Object getParent()
+    {
+        return parent;
+    }
+
+
+    /**
+     * Set the parent
+     * 
+     * @param parent
+     *            The parent to set.
+     */
+    public void setParent( AbstractAsn1Object parent )
+    {
+        this.parent = parent;
+    }
+}

Modified: directory/trunks/shared/asn1/src/main/java/org/apache/directory/shared/asn1/Asn1Object.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/asn1/src/main/java/org/apache/directory/shared/asn1/Asn1Object.java?view=diff&rev=488299&r1=488298&r2=488299
==============================================================================
--- directory/trunks/shared/asn1/src/main/java/org/apache/directory/shared/asn1/Asn1Object.java
(original)
+++ directory/trunks/shared/asn1/src/main/java/org/apache/directory/shared/asn1/Asn1Object.java
Mon Dec 18 07:07:41 2006
@@ -31,34 +31,15 @@
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public abstract class Asn1Object
+public interface Asn1Object
 {
-    // ~ Instance fields
-    // ----------------------------------------------------------------------------
-
-    /** The object's current length. It is used while decoding PDUs */
-    private transient int currentLength;
-
-    /** The object's expected length. It is used while decoding PDUs */
-    private transient int expectedLength;
-
-    /** The encapsulating Object */
-    protected transient Asn1Object parent;
-
-
-    // ~ Methods
-    // ------------------------------------------------------------------------------------
-
     /**
      * Get the current object length, which is the sum of all inner length
      * already decoded.
      * 
      * @return The current object's length
      */
-    public int getCurrentLength()
-    {
-        return currentLength;
-    }
+    int getCurrentLength();
 
 
     /**
@@ -66,7 +47,7 @@
      * 
      * @return The object's computed length
      */
-    public abstract int computeLength();
+    int computeLength();
 
 
     /**
@@ -76,10 +57,7 @@
      *            The buffer where to put the PDU
      * @return The PDU.
      */
-    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
-    {
-        return null;
-    }
+    ByteBuffer encode( ByteBuffer buffer ) throws EncoderException;
 
 
     /**
@@ -87,10 +65,7 @@
      * 
      * @return The expected object's length
      */
-    public int getExpectedLength()
-    {
-        return expectedLength;
-    }
+    int getExpectedLength();
 
 
     /**
@@ -101,15 +76,7 @@
      * @throws DecoderException
      *             Thrown if the current length exceed the expected length
      */
-    public void addLength( int length ) throws DecoderException
-    {
-        currentLength += length;
-
-        if ( currentLength > expectedLength )
-        {
-            throw new DecoderException( "Current Length is above expected Length" );
-        }
-    }
+    void addLength( int length ) throws DecoderException;
 
 
     /**
@@ -118,10 +85,7 @@
      * @param expectedLength
      *            The expectedLength to set.
      */
-    public void setExpectedLength( int expectedLength )
-    {
-        this.expectedLength = expectedLength;
-    }
+    public void setExpectedLength( int expectedLength );
 
 
     /**
@@ -130,10 +94,7 @@
      * @param currentLength
      *            The currentLength to set.
      */
-    public void setCurrentLength( int currentLength )
-    {
-        this.currentLength = currentLength;
-    }
+    public void setCurrentLength( int currentLength );
 
 
     /**
@@ -141,20 +102,5 @@
      * 
      * @return Returns the parent.
      */
-    public Asn1Object getParent()
-    {
-        return parent;
-    }
-
-
-    /**
-     * Set the parent
-     * 
-     * @param parent
-     *            The parent to set.
-     */
-    public void setParent( Asn1Object parent )
-    {
-        this.parent = parent;
-    }
+    public Asn1Object getParent();
 }

Modified: directory/trunks/shared/asn1/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Decoder.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/asn1/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Decoder.java?view=diff&rev=488299&r1=488298&r2=488299
==============================================================================
--- directory/trunks/shared/asn1/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Decoder.java
(original)
+++ directory/trunks/shared/asn1/src/main/java/org/apache/directory/shared/asn1/ber/Asn1Decoder.java
Mon Dec 18 07:07:41 2006
@@ -99,7 +99,7 @@
      * </code> otherwise
      * @throws DecoderException If something went wrong.
      */
-    private boolean treatTagStartState( ByteBuffer stream, IAsn1Container container ) throws
DecoderException, NamingException
+    private boolean treatTagStartState( ByteBuffer stream, IAsn1Container container )
     {
 
         if ( stream.hasRemaining() )
@@ -275,7 +275,7 @@
      * </code> otherwise
      * @throws DecoderException Thrown if anything went wrong
      */
-    private boolean treatLengthPendingState( ByteBuffer stream, IAsn1Container container
) throws DecoderException
+    private boolean treatLengthPendingState( ByteBuffer stream, IAsn1Container container
)
     {
 
         if ( stream.hasRemaining() )
@@ -531,7 +531,7 @@
      * </code> otherwise
      * @throws DecoderException Thrown if anything went wrong
      */
-    private boolean treatValueStartState( ByteBuffer stream, IAsn1Container container ) throws
DecoderException
+    private boolean treatValueStartState( ByteBuffer stream, IAsn1Container container )
     {
 
         TLV currentTlv = container.getCurrentTLV();
@@ -579,7 +579,7 @@
      * more bytes.
      * @throws DecoderException Thrown if anything went wrong
      */
-    private boolean treatValuePendingState( ByteBuffer stream, IAsn1Container container )
throws DecoderException
+    private boolean treatValuePendingState( ByteBuffer stream, IAsn1Container container )
     {
 
         TLV currentTlv = container.getCurrentTLV();

Modified: directory/trunks/shared/asn1/src/test/java/org/apache/directory/shared/asn1/ber/tlv/ValueTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/asn1/src/test/java/org/apache/directory/shared/asn1/ber/tlv/ValueTest.java?view=diff&rev=488299&r1=488298&r2=488299
==============================================================================
--- directory/trunks/shared/asn1/src/test/java/org/apache/directory/shared/asn1/ber/tlv/ValueTest.java
(original)
+++ directory/trunks/shared/asn1/src/test/java/org/apache/directory/shared/asn1/ber/tlv/ValueTest.java
Mon Dec 18 07:07:41 2006
@@ -63,7 +63,7 @@
 
         encoded = Value.getBytes( -27066 );
 
-        Assert.assertEquals( ( byte ) 0x96, ( byte ) encoded[0] );
+        Assert.assertEquals( ( byte ) 0x96, encoded[0] );
         Assert.assertEquals( 0x46, encoded[1] );
 
     }



Mime
View raw message