directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r234317 - in /directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new: Asn1Object.java DecoderException.java EncoderException.java
Date Sun, 21 Aug 2005 18:55:53 GMT
Author: elecharny
Date: Sun Aug 21 11:55:49 2005
New Revision: 234317

URL: http://svn.apache.org/viewcvs?rev=234317&view=rev
Log:
MIA back to the base ...

Added:
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/Asn1Object.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/DecoderException.java
  (with props)
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/EncoderException.java

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/Asn1Object.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/Asn1Object.java?rev=234317&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/Asn1Object.java
(added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/Asn1Object.java
Sun Aug 21 11:55:49 2005
@@ -0,0 +1,135 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.asn1new;
+
+import java.nio.ByteBuffer;
+
+
+/**
+ * An abstract class which implements basic TLV operations.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class 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;
+    }
+
+    /**
+     * 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 Asn1Object getParent()
+    {
+        return parent;
+    }
+
+    /**
+     * Set the parent
+     *
+     * @param parent The parent to set.
+     */
+    public void setParent( Asn1Object parent )
+    {
+        this.parent = parent;
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/DecoderException.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/DecoderException.java?rev=234317&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/DecoderException.java
(added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/DecoderException.java
Sun Aug 21 11:55:49 2005
@@ -0,0 +1,38 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.asn1new;
+
+/**
+ * Thrown when a Decoder has encountered a failure condition during a decode. 
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DecoderException extends Exception
+{
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a DecoderException
+     * 
+     * @param message A message with meaning to a human
+     */
+    public DecoderException(  String message )
+    {
+        super(  message );
+    }
+
+}

Propchange: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/DecoderException.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/EncoderException.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/EncoderException.java?rev=234317&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/EncoderException.java
(added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/EncoderException.java
Sun Aug 21 11:55:49 2005
@@ -0,0 +1,38 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.asn1new;
+
+/**
+ * Thrown when an Encoder has encountered a failure condition during an encoding. 
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class EncoderException extends Exception
+{
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a EncoderException
+     * 
+     * @param message A message with meaning to a human
+     */
+    public EncoderException(  String message )
+    {
+        super(  message );
+    }
+
+}



Mime
View raw message