directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 36767 - incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder
Date Mon, 23 Aug 2004 18:09:38 GMT
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 );

Mime
View raw message