directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r191340 - in /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/primitives: LdapDN.java LdapString.java
Date Sun, 19 Jun 2005 14:38:53 GMT
Author: elecharny
Date: Sun Jun 19 07:38:52 2005
New Revision: 191340

URL: http://svn.apache.org/viewcvs?rev=191340&view=rev
Log:
LdapDN and LdapString now extend MutableString.
The static method parse has been removed and replaced by a constructor

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/primitives/LdapDN.java
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/primitives/LdapString.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/primitives/LdapDN.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/primitives/LdapDN.java?rev=191340&r1=191339&r2=191340&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/primitives/LdapDN.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/primitives/LdapDN.java
Sun Jun 19 07:38:52 2005
@@ -52,7 +52,7 @@
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LdapDN
+public class LdapDN extends MutableString
 {
     //~ Static fields/initializers -----------------------------------------------------------------
 
@@ -62,6 +62,9 @@
     /** "OID." static */
     private static final byte[] OID_UPPER = new byte[] { 'O', 'I', 'D', '.' };
 
+    /** A null LdapDN */
+    public transient static final LdapDN EMPTY_STRING = new LdapDN();
+
     //~ Methods ------------------------------------------------------------------------------------
 
     /**
@@ -452,6 +455,14 @@
     }
 
     /**
+     * Construct an empty LdapDN object
+     */
+    public LdapDN()
+    {
+        super(0, false);
+    }
+    
+    /**
      * Parse a buffer and checks that it is a valid DN <br>
      * <p>
      * &lt;distinguishedName&gt;     ::= &lt;name&gt; | e <br>
@@ -460,18 +471,16 @@
      * </p>
      * 
      * @param bytes The byte buffer that contains the DN
-     * @return A MutableString containing the DN. 
      * @exception A DecoderException is thrown if the buffer does not contains a valid DN.
      */
-    public static MutableString parseDN( byte[] bytes ) throws DecoderException
+    public LdapDN( byte[] bytes ) throws DecoderException
     {
 
-        // <distinguishedName> ::= e
-        if ( ( bytes == null ) || ( bytes.length == 0 ) )
+        if ( bytes == null || bytes.length == 0)
         {
-            return MutableString.EMPTY_STRING;
+            return;
         }
-
+        
         int pos = 0;
 
         // <name>             ::= <name-component> <name-components>
@@ -504,9 +513,6 @@
         
         int stringLength = StringUtils.countChars(bytes);
         
-        MutableString string = new MutableString(stringLength);
-        string.setData(bytes);
-        
-        return string;
+        setData(bytes);
     }
 }

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/primitives/LdapString.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/primitives/LdapString.java?rev=191340&r1=191339&r2=191340&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/primitives/LdapString.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/primitives/LdapString.java
Sun Jun 19 07:38:52 2005
@@ -27,8 +27,20 @@
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LdapString
+public class LdapString extends MutableString
 {
+    /** A null LdapString */
+    public transient static final LdapString EMPTY_STRING = new LdapString();
+
+    /**
+     * Construct an empty LdapString
+     *
+     */
+    public LdapString()
+    {
+        super( 0, false );
+    }
+    
     //~ Methods ------------------------------------------------------------------------------------
 
     /**
@@ -40,18 +52,10 @@
      * 
      * @throws DecoderException If the byte array does not comply with RFC 2279
      */
-    public static MutableString parse( byte[] bytes ) throws DecoderException
+    public LdapString( byte[] bytes ) throws DecoderException
     {
-        if ( ( bytes == null ) || ( bytes.length == 0 ) )
-        {
-            return MutableString.EMPTY_STRING;
-        }
-
         int stringLength = StringUtils.countChars(bytes);
         
-        MutableString string = new MutableString(stringLength);
-        string.setData(bytes);
-        
-        return string;
+        setData(bytes);
     }
 }



Mime
View raw message