You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/08/23 20:09:38 UTC

svn commit: rev 36767 - incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder

Author: akarasulu
Date: Mon Aug 23 11:09:37 2004
New Revision: 36767

Modified:
   incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/EncoderUtils.java
Log:
Added methods for encoding byte[] at OCTET_STRING or any other tag.


Modified: incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/EncoderUtils.java
==============================================================================
--- incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/EncoderUtils.java	(original)
+++ incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/EncoderUtils.java	Mon Aug 23 11:09:37 2004
@@ -51,13 +51,44 @@
      *
      * @param tag the tag enumeration to use for the Tuple
      * @param octets the String value to encode
-     * @return the TupleNode containing the Tuple for the integer value
+     * @return the TupleNode containing the Tuple for the string value
      */
     public static TupleNode encode( TagEnum tag, String octets )
     {
         Tuple t = new Tuple();
         t.setTag( tag, true );
         ByteBuffer chunk = ByteBuffer.wrap( octets.getBytes() );
+        t.setLength( chunk.remaining() );
+        t.setLastValueChunk( chunk );
+        return new DefaultMutableTupleNode( t );
+    }
+
+
+    /**
+     * Encodes a Java byte[] into a TupleNode.  The tag of the Tuple contained
+     * within the returned TupleNode defaults to a UNIVERSAL OCTET_STRING.
+     *
+     * @param octets the byte[] to encode
+     * @return the TupleNode containing the Tuple for the byte[]
+     */
+    public static TupleNode encode( byte[] octets )
+    {
+        return encode( UniversalTag.OCTET_STRING, octets );
+    }
+
+
+    /**
+     * Encodes a Java byte[] into a TupleNode.
+     *
+     * @param tag the tag enumeration to use for the Tuple
+     * @param octets the byte[] to encode
+     * @return the TupleNode containing the Tuple for the byte[] value
+     */
+    public static TupleNode encode( TagEnum tag, byte[] octets )
+    {
+        Tuple t = new Tuple();
+        t.setTag( tag, true );
+        ByteBuffer chunk = ByteBuffer.wrap( octets );
         t.setLength( chunk.remaining() );
         t.setLastValueChunk( chunk );
         return new DefaultMutableTupleNode( t );