Class HardcodedFilter

  • All Implemented Interfaces:
    Filter

    public class HardcodedFilter
    extends AbstractFilter
    Allows hard coded parts to be included in a search filter. Particularly useful if some filters are specified in configuration files and these should be combined with other ones.
     Filter filter = new HardcodedFilter("(&(objectClass=user)(!(objectClass=computer)))");
     System.out.println(filter.toString());
     
    would result in: (&(objectClass=user)(!(objectClass=computer)))

    Note 1: If the definition is in XML you will need to properly encode any special characters so that they are valid in an XML file, e.g. "&" needs to be encoded as "&", e.g.

     <bean class="MyClass">
       <property name="filter" value="(&amp;(objectClass=user)(!(objectClass=computer)))" />
     </bean>
     

    Note 2: There will be no validation to ensure that the supplied filter is valid. Using this implementation to build filters from user input is strongly discouraged.

    • Constructor Summary

      Constructors 
      Constructor Description
      HardcodedFilter​(java.lang.String filter)
      The hardcoded string to be used for this filter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.StringBuffer encode​(java.lang.StringBuffer buff)
      Encodes the filter to a StringBuffer.
      boolean equals​(java.lang.Object o)
      All filters must implement equals.
      int hashCode()
      All filters must implement hashCode.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • HardcodedFilter

        public HardcodedFilter​(java.lang.String filter)
        The hardcoded string to be used for this filter.
        Parameters:
        filter - the hardcoded filter string.
    • Method Detail

      • encode

        public java.lang.StringBuffer encode​(java.lang.StringBuffer buff)
        Description copied from interface: Filter
        Encodes the filter to a StringBuffer.
        Parameters:
        buff - The StringBuffer to encode the filter to
        Returns:
        The same StringBuffer as was given
      • equals

        public boolean equals​(java.lang.Object o)
        Description copied from interface: Filter
        All filters must implement equals.
        Specified by:
        equals in interface Filter
        Overrides:
        equals in class java.lang.Object
        Returns:
        true if the objects are equal.
      • hashCode

        public int hashCode()
        Description copied from interface: Filter
        All filters must implement hashCode.
        Specified by:
        hashCode in interface Filter
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash code according to the contract in Object.hashCode()