org.springframework.ldap.filter

## Class CompareFilter

- java.lang.Object
- - org.springframework.ldap.filter.AbstractFilter
  - - org.springframework.ldap.filter.CompareFilter

- All Implemented Interfaces:
    Filter
  Direct Known Subclasses:
    EqualsFilter, GreaterThanOrEqualsFilter, LessThanOrEqualsFilter

      public abstract class CompareFilter
      extends AbstractFilter

  Abstract superclass for filters that compare values.
  Author:
    Mattias Hellborg Arthursson

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CompareFilter(String attribute, int value)` Convenience constructor for `int` values.
    `CompareFilter(String attribute, String value)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `StringBuffer` | `encode(StringBuffer buff)` Encodes the filter to a StringBuffer.
    `protected String` | `encodeValue(String value)` Override to perform special encoding in subclass.
    `boolean` | `equals(Object o)` All filters must implement equals.
    `protected abstract String` | `getCompareString()` Implement this method in subclass to return a String representing the operator.
    `int` | `hashCode()` All filters must implement hashCode.

    - ### Methods inherited from class org.springframework.ldap.filter.AbstractFilter

      `encode, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### CompareFilter

          public CompareFilter(String attribute,
                               String value)

    - #### CompareFilter

          public CompareFilter(String attribute,
                               int value)

      Convenience constructor for `int` values.
      Parameters:
        `attribute` - Name of attribute in filter.
        `value` - The value of the attribute in the filter.

  - ### Method Detail

    - #### encodeValue

          protected String encodeValue(String value)

      Override to perform special encoding in subclass.
      Parameters:
        `value` - the value to encode.
      Returns:
        properly escaped value.

    - #### encode

          public StringBuffer encode(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(Object o)

      Description copied from interface: `Filter`
      All filters must implement equals.
      Specified by:
        `equals` in interface `Filter`
      Overrides:
        `equals` in class `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 `Object`
      Returns:
        the hash code according to the contract in `Object.hashCode()`

    - #### getCompareString

          protected abstract String getCompareString()

      Implement this method in subclass to return a String representing the operator. The `EqualsFilter.getCompareString()` would for example return an equals sign, "=".
      Returns:
        the String to use as operator in the comparison for the specific subclass.