directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r263921 - /directory/asn1/branches/asn1-new-ber/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
Date Sun, 28 Aug 2005 21:02:25 GMT
Author: elecharny
Date: Sun Aug 28 14:02:21 2005
New Revision: 263921

URL: http://svn.apache.org/viewcvs?rev=263921&view=rev
Log:
Added an encode method which accept byte[]

Modified:
    directory/asn1/branches/asn1-new-ber/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java

Modified: directory/asn1/branches/asn1-new-ber/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
URL: http://svn.apache.org/viewcvs/directory/asn1/branches/asn1-new-ber/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java?rev=263921&r1=263920&r2=263921&view=diff
==============================================================================
--- directory/asn1/branches/asn1-new-ber/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
(original)
+++ directory/asn1/branches/asn1-new-ber/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
Sun Aug 28 14:02:21 2005
@@ -300,6 +300,37 @@
     }
 
     /**
+     * Encode an OctetString value 
+     * 
+     * @param buffer The PDU in which the value will be put
+     * @param byte[] The bytes to be encoded
+     */
+    public static void encode( ByteBuffer buffer, byte[] bytes ) throws EncoderException
+    {
+        if ( buffer == null )
+        {
+            throw new EncoderException( "Cannot put a PDU in a null buffer !" );
+        }
+
+        try 
+        {
+            buffer.put( UniversalTag.OCTET_STRING_TAG );
+            buffer.put( Length.getBytes( bytes.length ) );
+    
+            if ( bytes.length != 0 )
+            {
+                buffer.put( bytes );
+            }
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+
+        return;
+    }
+
+    /**
      * Encode an OID value 
      * 
      * @param buffer The PDU in which the value will be put



Mime
View raw message