directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r307387 - /directory/asn1/trunk/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
Date Sun, 09 Oct 2005 10:57:08 GMT
Author: elecharny
Date: Sun Oct  9 03:57:03 2005
New Revision: 307387

URL: http://svn.apache.org/viewcvs?rev=307387&view=rev
Log:
* Class MutableString is no more used
* fixed a NPE when getting byte[] length

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

Modified: directory/asn1/trunk/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
URL: http://svn.apache.org/viewcvs/directory/asn1/trunk/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java?rev=307387&r1=307386&r2=307387&view=diff
==============================================================================
--- directory/asn1/trunk/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java (original)
+++ directory/asn1/trunk/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java Sun Oct
 9 03:57:03 2005
@@ -19,7 +19,6 @@
 import org.apache.asn1.codec.EncoderException;
 import org.apache.asn1new.primitives.OID;
 import org.apache.asn1new.primitives.OctetString;
-import org.apache.asn1new.util.MutableString;
 import org.apache.asn1new.util.StringUtils;
 
 import java.io.Serializable;
@@ -326,9 +325,9 @@
         try 
         {
             buffer.put( UniversalTag.OCTET_STRING_TAG );
-            buffer.put( Length.getBytes( string.getLength() ) );
+            buffer.put( Length.getBytes( string.getNbBytes() ) );
     
-            if ( string.getLength() != 0 )
+            if ( string.getNbBytes() != 0 )
             {
                 buffer.put( string.getValue() );
             }
@@ -357,10 +356,14 @@
         try 
         {
             buffer.put( UniversalTag.OCTET_STRING_TAG );
-            buffer.put( Length.getBytes( bytes.length ) );
-    
-            if ( bytes.length != 0 )
+            
+            if ( ( bytes == null ) || ( bytes.length == 0 ) )
+            {
+                buffer.put( (byte) 0 );
+            }
+            else
             {
+                buffer.put( Length.getBytes( bytes.length ) );
                 buffer.put( bytes );
             }
         }
@@ -393,37 +396,6 @@
             if ( oid.getOIDLength() != 0 )
             {
                 buffer.put( oid.getOID() );
-            }
-        }
-        catch ( BufferOverflowException boe )
-        {
-            throw new EncoderException("The PDU buffer size is too small !"); 
-        }
-
-        return;
-    }
-
-    /**
-     * Encode a MutableString value 
-     * 
-     * @param buffer The PDU in which the value will be put
-     * @param string The MutableString to be encoded
-     */
-    public static void encode( ByteBuffer buffer, MutableString string ) 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( string.getLength() ) );
-    
-            if ( string.getLength() != 0 )
-            {
-                buffer.put( string.getData() );
             }
         }
         catch ( BufferOverflowException boe )



Mime
View raw message