directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r224577 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/NotFilter.java
Date Sat, 23 Jul 2005 23:03:38 GMT
Author: elecharny
Date: Sat Jul 23 16:03:35 2005
New Revision: 224577

URL: http://svn.apache.org/viewcvs?rev=224577&view=rev
Log:
- Added a toString() method
- deleted the notFilter member, using the filterSet member from its super class instead. 

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

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/NotFilter.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/NotFilter.java?rev=224577&r1=224576&r2=224577&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/NotFilter.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/NotFilter.java
Sat Jul 23 16:03:35 2005
@@ -16,6 +16,8 @@
  */
 package org.apache.asn1.ldap.pojo.filters;
 
+import org.apache.asn1.DecoderException;
+
 /**
  * Not Filter Object to store the Not filter.
  * 
@@ -23,10 +25,6 @@
  */
 public class NotFilter extends ConnectorFilter
 {
-    //~ Instance fields ----------------------------------------------------------------------------
-    /** The 'not' filter. */
-    private Filter notFilter;
-
     //~ Methods ------------------------------------------------------------------------------------
 
     /**
@@ -38,12 +36,17 @@
     
     /**
      * Subclass the addFilterMethod, as this is specific for a NotFilter
-     * (we cannot have many elements).
+     * (we cannot have more than one elements).
      * @param Filter The Filter to add
      */
-    public void addFilter( Filter filter )
+    public void addFilter( Filter filter ) throws DecoderException
     {
-        notFilter = filter;
+        if ( filterSet != null )
+        {
+            throw new DecoderException("Cannot have more than one Filter within a Not Filter");
+        }
+        
+        super.addFilter( filter );
     }
 
     /**
@@ -53,7 +56,7 @@
      */
     public Filter getNotFilter()
     {
-        return notFilter;
+        return (Filter)filterSet.get(0);
     }
 
     /**
@@ -61,8 +64,27 @@
      *
      * @param not The notFilter to set.
      */
-    public void setNotFilter( Filter notFilter )
+    public void setNotFilter( Filter notFilter ) throws DecoderException
+    {
+        if ( filterSet != null )
+        {
+            throw new DecoderException("Cannot have more than one Filter within a Not Filter");
+        }
+        
+        super.addFilter( notFilter );
+    }
+    
+    /**
+     * Return a string compliant with RFC 2254 representing a NOT filter
+     *
+     * @return The NOT filter string
+     */
+    public String toString()
     {
-        this.notFilter = notFilter;
+        StringBuffer sb = new StringBuffer();
+        
+        sb.append('!').append(super.toString());
+        
+        return sb.toString();
     }
 }



Mime
View raw message