directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r151191 - in incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1: BufferConsumer.java MessageConsumer.java MessageProducer.java TupleConsumer.java TupleProducer.java ber/TagOctetCollector.java decoders/ decoders/TagDecoder.java
Date Thu, 03 Feb 2005 17:36:05 GMT
Author: akarasulu
Date: Thu Feb  3 09:35:59 2005
New Revision: 151191

URL: http://svn.apache.org/viewcvs?view=rev&rev=151191
Log:
adding some interfaces to play with

Added:
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/BufferConsumer.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/MessageConsumer.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/MessageProducer.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/TupleConsumer.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/TupleProducer.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/decoders/
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/decoders/TagDecoder.java
Modified:
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TagOctetCollector.java

Added: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/BufferConsumer.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/BufferConsumer.java?view=auto&rev=151191
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/BufferConsumer.java
(added)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/BufferConsumer.java
Thu Feb  3 09:35:59 2005
@@ -0,0 +1,52 @@
+/*
+ *   Copyright 2004 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.asn1;
+
+
+import java.nio.ByteBuffer;
+import java.util.List;
+
+
+/**
+ * A ByteBuffer consumer.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface BufferConsumer
+{
+    /**
+     * Consumes a list of ByteBuffers.
+     *
+     * @param bbs a list containing ByteBuffers
+     */
+    void consume( List bbs );
+
+    /**
+     * Consumes a ByteBuffer.
+     *
+     * @param bb the ByteBuffer to consume
+     */
+    void consume( ByteBuffer bb );
+
+    /**
+     * Consumes an array of ByteBuffers.
+     *
+     * @param bbs an array of ByteBuffers
+     */
+    void consume( ByteBuffer[] bbs );
+}

Added: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/MessageConsumer.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/MessageConsumer.java?view=auto&rev=151191
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/MessageConsumer.java
(added)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/MessageConsumer.java
Thu Feb  3 09:35:59 2005
@@ -0,0 +1,29 @@
+/*
+ *   Copyright 2004 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.asn1;
+
+
+/**
+ * Document this class.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface MessageConsumer
+{
+    void consume( Object msg );
+}

Added: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/MessageProducer.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/MessageProducer.java?view=auto&rev=151191
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/MessageProducer.java
(added)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/MessageProducer.java
Thu Feb  3 09:35:59 2005
@@ -0,0 +1,29 @@
+/*
+ *   Copyright 2004 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.asn1;
+
+
+/**
+ * A PDU message producer.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface MessageProducer
+{
+    void connect( MessageConsumer consumer );
+}

Added: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/TupleConsumer.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/TupleConsumer.java?view=auto&rev=151191
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/TupleConsumer.java
(added)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/TupleConsumer.java
Thu Feb  3 09:35:59 2005
@@ -0,0 +1,29 @@
+/*
+ *   Copyright 2004 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.asn1;
+
+
+/**
+ * A Tuple consumer.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface TupleConsumer
+{
+    void consume( Tuple tuple );
+}

Added: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/TupleProducer.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/TupleProducer.java?view=auto&rev=151191
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/TupleProducer.java
(added)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/TupleProducer.java
Thu Feb  3 09:35:59 2005
@@ -0,0 +1,29 @@
+/*
+ *   Copyright 2004 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.asn1;
+
+
+/**
+ * An object that generates Tuple objects.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface TupleProducer
+{
+    void connect( TupleConsumer consumer );
+}

Modified: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TagOctetCollector.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TagOctetCollector.java?view=diff&r1=151190&r2=151191
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TagOctetCollector.java
(original)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TagOctetCollector.java
Thu Feb  3 09:35:59 2005
@@ -23,18 +23,18 @@
 
 
 /**
- * Collects up to 4 tag octets.
+ * Collects up to 4 tag octets max.
  *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
 public class TagOctetCollector
 {
     /** the int used to store the tag octets */
     private int intValue = 0 ;
+
     /** the number of octets currently stored */
-    private int _size = 0 ;
+    private int size = 0 ;
     
     
     /**
@@ -44,25 +44,42 @@
      */
     public void put( byte octet )
     {
-        switch( _size )
+        switch( size )
         {
             case(0):
+
                 intValue = octet << 24 ;
-                _size = 1 ;
+
+                size = 1 ;
+
                 break ;
+
             case(1):
+
                 intValue |= ( octet << 16 ) & 0x00FF0000 ;
-                _size = 2 ;
+
+                size = 2 ;
+
                 break ;
+
             case(2):
+
                 intValue |= ( octet << 8 ) & 0x0000FF00 ;
-                _size = 3 ;
+
+                size = 3 ;
+
                 break ;
+
             case(3):
+
                 intValue |= octet ;
-                _size = 4 ;
+
+                size = 4 ;
+
                 break ;
+
             default:
+
                 throw new BufferOverflowException() ;
         }
     }
@@ -74,7 +91,8 @@
     public void clear()
     {
         intValue = 0 ;
-        _size = 0 ;
+
+        size = 0 ;
     }
     
     
@@ -85,7 +103,7 @@
      */
     public int size()
     {
-        return _size ;
+        return size ;
     }
     
     
@@ -107,34 +125,55 @@
      */
     public byte[] toArray()
     {
-        byte[] octets = new byte[_size] ;
+        byte[] octets = new byte[size] ;
         
-        switch( _size )
+        switch( size )
         {
             case(0):
+
                 octets = ArrayUtils.EMPTY_BYTE_ARRAY ;
+
                 break ;
+
             case(1):
+
                 octets[0] = ( byte ) ( ( intValue & 0xff000000 ) >> 24 ) ;
+
                 break ;
+
             case(2):
+
                 octets[0] = ( byte ) ( ( intValue & 0xff000000 ) >> 24 ) ;
+
                 octets[1] = ( byte ) ( ( intValue & 0x00ff0000 ) >> 16 ) ;
+
                 break ;
+
             case(3):
+
                 octets[0] = ( byte ) ( ( intValue & 0xff000000 ) >> 24 ) ;
+
                 octets[1] = ( byte ) ( ( intValue & 0x00ff0000 ) >> 16 ) ;
+
                 octets[2] = ( byte ) ( ( intValue & 0x0000ff00 ) >>  8 ) ;
+
                 break ;
+
             case(4):
+
                 octets[0] = ( byte ) ( ( intValue & 0xff000000 ) >> 24 ) ;
+
                 octets[1] = ( byte ) ( ( intValue & 0x00ff0000 ) >> 16 ) ;
+
                 octets[2] = ( byte ) ( ( intValue & 0x0000ff00 ) >>  8 ) ;
+
                 octets[3] = ( byte )   ( intValue & 0x000000ff ) ;
+
                 break ;
+
             default:
-                throw new IllegalArgumentException( 
-                        "Cannot support more than 4 octets" ) ;
+
+                throw new IllegalArgumentException( "Cannot support more than 4 octets" )
;
         }
         
         return octets ;
@@ -152,29 +191,40 @@
     {
         byte octet ;
         
-        if ( index >= _size )
+        if ( index >= size )
         {
-            throw new IndexOutOfBoundsException( "accesing index " + index
-                    + " with a size of " + _size ) ;
+            throw new IndexOutOfBoundsException( "accesing index " + index + " with a size
of " + size ) ;
         }
 
         switch( index )
         {
             case(0):
+
                 octet = ( byte ) ( ( intValue & 0xff000000 ) >> 24 ) ;
+
                 break ;
+
             case(1):
+
                 octet = ( byte ) ( ( intValue & 0x00ff0000 ) >> 16 ) ;
+
                 break ;
+
             case(2):
+
                 octet = ( byte ) ( ( intValue & 0x0000ff00 ) >>  8 ) ;
+
                 break ;
+
             case(3):
+
                 octet = ( byte )   ( intValue & 0x000000ff ) ;
+
                 break ;
+
             default:
-                throw new IllegalArgumentException( 
-                        "Cannot support more than 4 octets" ) ;
+
+                throw new IllegalArgumentException( "Cannot support more than 4 octets" )
;
         }
         
         return octet ;

Added: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/decoders/TagDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/decoders/TagDecoder.java?view=auto&rev=151191
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/decoders/TagDecoder.java
(added)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/decoders/TagDecoder.java
Thu Feb  3 09:35:59 2005
@@ -0,0 +1,47 @@
+/*
+ *   Copyright 2004 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.asn1.decoders;
+
+
+import java.util.List;
+import java.nio.ByteBuffer;
+
+import org.apache.asn1.BufferConsumer;
+
+
+/**
+ * Document this class.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class TagDecoder implements BufferConsumer
+{
+    public void consume( List bbs )
+    {
+    }
+
+
+    public void consume( ByteBuffer bb )
+    {
+    }
+
+
+    public void consume( ByteBuffer[] bbs )
+    {
+    }
+}



Mime
View raw message