directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r329685 - /directory/asn1/branches/asn1-utf8/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
Date Mon, 31 Oct 2005 00:53:22 GMT
Author: elecharny
Date: Sun Oct 30 16:53:18 2005
New Revision: 329685

URL: http://svn.apache.org/viewcvs?rev=329685&view=rev
Log:
- deleted the encode method that was taking an OctetString parameter
- Use of StringUtils.toUtf8String instead of new String( value, "UTF-8") : less code

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

Modified: directory/asn1/branches/asn1-utf8/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
URL: http://svn.apache.org/viewcvs/directory/asn1/branches/asn1-utf8/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java?rev=329685&r1=329684&r2=329685&view=diff
==============================================================================
--- directory/asn1/branches/asn1-utf8/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
(original)
+++ directory/asn1/branches/asn1-utf8/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
Sun Oct 30 16:53:18 2005
@@ -18,11 +18,9 @@
 
 import org.apache.asn1.codec.EncoderException;
 import org.apache.asn1new.primitives.OID;
-import org.apache.asn1new.primitives.OctetString;
 import org.apache.asn1new.util.StringUtils;
 
 import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
@@ -283,53 +281,13 @@
         {
             buffer.put( UniversalTag.OCTET_STRING_TAG );
             
-            byte[] value = null;
-            
-            try 
-            {
-                value = string.getBytes("UTF-8");
-            } 
-            catch (UnsupportedEncodingException uee)
-            {
-                throw new EncoderException("The Value encoding is not UTF-8");
-            }
+            byte[] value = StringUtils.getBytesUtf8( string );
             
             buffer.put( Length.getBytes( value.length ) );
     
             if ( value.length != 0 )
             {
                 buffer.put( value );
-            }
-        }
-        catch ( BufferOverflowException boe )
-        {
-            throw new EncoderException("The PDU buffer size is too small !"); 
-        }
-
-        return;
-    }
-
-    /**
-     * Encode an OctetString value 
-     * 
-     * @param buffer The PDU in which the value will be put
-     * @param string The OctetString to be encoded
-     */
-    public static void encode( ByteBuffer buffer, OctetString 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.getNbBytes() ) );
-    
-            if ( string.getNbBytes() != 0 )
-            {
-                buffer.put( string.getValue() );
             }
         }
         catch ( BufferOverflowException boe )



Mime
View raw message