directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r224576 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/SubstringFilter.java
Date Sat, 23 Jul 2005 23:02:31 GMT
Author: elecharny
Date: Sat Jul 23 16:02:28 2005
New Revision: 224576

URL: http://svn.apache.org/viewcvs?rev=224576&view=rev
Log:
- Added a toString() method
- changed the substrings type from MutableString to LdapString

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/SubstringFilter.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/SubstringFilter.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/SubstringFilter.java?rev=224576&r1=224575&r2=224576&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/SubstringFilter.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/SubstringFilter.java
Sat Jul 23 16:02:28 2005
@@ -17,7 +17,9 @@
 package org.apache.asn1.ldap.pojo.filters;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 
+import org.apache.asn1.ldap.codec.primitives.LdapString;
 import org.apache.asn1.util.MutableString;
 
 
@@ -37,19 +39,19 @@
     //~ Instance fields ----------------------------------------------------------------------------
 
     /** The substring filter type (an attributeDescription) */
-    private MutableString type;
+    private LdapString type;
 
     /** This member is used to control the length of the three parts of the substring filter
**/
     private transient int substringsLength;
     
     /** The initial filter */
-    private MutableString initialSubstrings;
+    private LdapString initialSubstrings;
 
     /** The any filter. It's a list of LdapString */
     private ArrayList anySubstrings;
 
     /** The final filter */
-    private MutableString finalSubstrings;
+    private LdapString finalSubstrings;
 
     //~ Methods ------------------------------------------------------------------------------------
     
@@ -96,7 +98,7 @@
      *
      * @param finalSubstrings The finalSubstrings to set.
      */
-    public void setFinalSubstrings( MutableString finalSubstrings )
+    public void setFinalSubstrings( LdapString finalSubstrings )
     {
         this.finalSubstrings = finalSubstrings;
     }
@@ -116,7 +118,7 @@
      *
      * @param initialSubstrings The initialSubstrings to set.
      */
-    public void setInitialSubstrings( MutableString initialSubstrings )
+    public void setInitialSubstrings( LdapString initialSubstrings )
     {
         this.initialSubstrings = initialSubstrings;
     }
@@ -136,7 +138,7 @@
      *
      * @param type The type to set.
      */
-    public void setType( MutableString type )
+    public void setType( LdapString type )
     {
         this.type = type;
     }
@@ -155,5 +157,40 @@
     public void setSubstringsLength(int substringsLength) 
     {
         this.substringsLength = substringsLength;
+    }
+    
+    /**
+     * Return a string compliant with RFC 2254 representing a Substring filter
+     *
+     * @return The substring filter string
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        if (initialSubstrings != null)
+        {
+            sb.append( initialSubstrings.toString() );
+        }
+        
+        sb.append('*');
+
+        if ( anySubstrings != null )
+        {
+            Iterator anyIterator = anySubstrings.iterator();
+            
+            while (anyIterator.hasNext())
+            {
+                sb.append( (LdapString)anyIterator.next() ).append('*');
+            }
+        }
+        
+        if (finalSubstrings != null)
+        {
+            sb.append( finalSubstrings.toString() );
+        }
+        
+        return sb.toString();
     }
 }



Mime
View raw message