org.opends.server.types
Class SearchFilter

java.lang.Object
  extended by org.opends.server.types.SearchFilter

@PublicAPI(stability=UNCOMMITTED,
           mayInstantiate=true,
           mayExtend=false,
           mayInvoke=true)
public final class SearchFilter
extends java.lang.Object

This class defines a data structure for storing and interacting with a search filter that may serve as criteria for locating entries in the Directory Server.


Constructor Summary
SearchFilter(FilterType filterType, java.util.Collection<SearchFilter> filterComponents, SearchFilter notComponent, AttributeType attributeType, java.util.Set<java.lang.String> attributeOptions, AttributeValue assertionValue, ByteString subInitialElement, java.util.List<ByteString> subAnyElements, ByteString subFinalElement, java.lang.String matchingRuleID, boolean dnAttributes)
          Creates a new search filter with the provided information.
 
Method Summary
static SearchFilter createANDFilter(java.util.Collection<SearchFilter> filterComponents)
          Creates a new AND search filter with the provided information.
static SearchFilter createApproximateFilter(AttributeType attributeType, AttributeValue assertionValue)
          Creates an approximate search filter with the provided information.
static SearchFilter createApproximateFilter(AttributeType attributeType, java.util.Set<java.lang.String> attributeOptions, AttributeValue assertionValue)
          Creates an approximate search filter with the provided information.
static SearchFilter createEqualityFilter(AttributeType attributeType, AttributeValue assertionValue)
          Creates a new equality search filter with the provided information.
static SearchFilter createEqualityFilter(AttributeType attributeType, java.util.Set<java.lang.String> attributeOptions, AttributeValue assertionValue)
          Creates a new equality search filter with the provided information.
static SearchFilter createExtensibleMatchFilter(AttributeType attributeType, AttributeValue assertionValue, java.lang.String matchingRuleID, boolean dnAttributes)
          Creates an extensible matching filter with the provided information.
static SearchFilter createExtensibleMatchFilter(AttributeType attributeType, java.util.Set<java.lang.String> attributeOptions, AttributeValue assertionValue, java.lang.String matchingRuleID, boolean dnAttributes)
          Creates an extensible matching filter with the provided information.
static SearchFilter createFilterFromString(java.lang.String filterString)
          Decodes the provided filter string as a search filter.
static SearchFilter createGreaterOrEqualFilter(AttributeType attributeType, AttributeValue assertionValue)
          Creates a greater-or-equal search filter with the provided information.
static SearchFilter createGreaterOrEqualFilter(AttributeType attributeType, java.util.Set<java.lang.String> attributeOptions, AttributeValue assertionValue)
          Creates a greater-or-equal search filter with the provided information.
static SearchFilter createLessOrEqualFilter(AttributeType attributeType, AttributeValue assertionValue)
          Creates a less-or-equal search filter with the provided information.
static SearchFilter createLessOrEqualFilter(AttributeType attributeType, java.util.Set<java.lang.String> attributeOptions, AttributeValue assertionValue)
          Creates a less-or-equal search filter with the provided information.
static SearchFilter createNOTFilter(SearchFilter notComponent)
          Creates a new NOT search filter with the provided information.
static SearchFilter createORFilter(java.util.Collection<SearchFilter> filterComponents)
          Creates a new OR search filter with the provided information.
static SearchFilter createPresenceFilter(AttributeType attributeType)
          Creates a presence search filter with the provided information.
static SearchFilter createPresenceFilter(AttributeType attributeType, java.util.Set<java.lang.String> attributeOptions)
          Creates a presence search filter with the provided information.
static SearchFilter createSubstringFilter(AttributeType attributeType, ByteString subInitialElement, java.util.List<ByteString> subAnyElements, ByteString subFinalElement)
          Creates a new substring search filter with the provided information.
static SearchFilter createSubstringFilter(AttributeType attributeType, java.util.Set<java.lang.String> attributeOptions, ByteString subInitialElement, java.util.List<ByteString> subAnyElements, ByteString subFinalElement)
          Creates a new substring search filter with the provided information.
 boolean equals(java.lang.Object o)
          Indicates whether this search filter is equal to the provided object.
 AttributeValue getAssertionValue()
          Retrieves the assertion value for this filter.
 AttributeType getAttributeType()
          Retrieves the attribute type for this filter.
 boolean getDNAttributes()
          Retrieves the dnAttributes flag for this extensible matching filter.
 java.util.Set<SearchFilter> getFilterComponents()
          Retrieves the set of filter components for this AND or OR filter.
 FilterType getFilterType()
          Retrieves the filter type for this search filter.
 java.lang.String getMatchingRuleID()
          Retrieves the matching rule ID for this extensible matching filter.
 SearchFilter getNotComponent()
          Retrieves the filter component for this NOT filter.
 java.util.List<ByteString> getSubAnyElements()
          Retrieves the set of subAny elements for this substring filter.
 ByteString getSubFinalElement()
          Retrieves the subFinal element for this substring filter.
 ByteString getSubInitialElement()
          Retrieves the subInitial element for this substring filter.
 int hashCode()
          Retrieves the hash code for this search filter.
 boolean matchesEntry(Entry entry)
          Indicates whether this search filter matches the provided entry.
 java.lang.String toString()
          Retrieves a string representation of this search filter.
 void toString(java.lang.StringBuilder buffer)
          Appends a string representation of this search filter to the provided buffer.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SearchFilter

public SearchFilter(FilterType filterType,
                    java.util.Collection<SearchFilter> filterComponents,
                    SearchFilter notComponent,
                    AttributeType attributeType,
                    java.util.Set<java.lang.String> attributeOptions,
                    AttributeValue assertionValue,
                    ByteString subInitialElement,
                    java.util.List<ByteString> subAnyElements,
                    ByteString subFinalElement,
                    java.lang.String matchingRuleID,
                    boolean dnAttributes)
Creates a new search filter with the provided information.

Parameters:
filterType - The filter type for this search filter.
filterComponents - The set of filter components for AND and OR filters.
notComponent - The filter component for NOT filters.
attributeType - The attribute type for this filter.
attributeOptions - The set of attribute options for the associated attribute type.
assertionValue - The assertion value for this filter.
subInitialElement - The subInitial element for substring filters.
subAnyElements - The subAny elements for substring filters.
subFinalElement - The subFinal element for substring filters.
matchingRuleID - The matching rule ID for this search filter.
dnAttributes - Indicates whether to match on DN attributes for extensible match filters. FIXME: this should be private.
Method Detail

createANDFilter

public static SearchFilter createANDFilter(java.util.Collection<SearchFilter> filterComponents)
Creates a new AND search filter with the provided information.

Parameters:
filterComponents - The set of filter components for the AND filter.
Returns:
The constructed search filter.

createORFilter

public static SearchFilter createORFilter(java.util.Collection<SearchFilter> filterComponents)
Creates a new OR search filter with the provided information.

Parameters:
filterComponents - The set of filter components for the OR filter.
Returns:
The constructed search filter.

createNOTFilter

public static SearchFilter createNOTFilter(SearchFilter notComponent)
Creates a new NOT search filter with the provided information.

Parameters:
notComponent - The filter component for this NOT filter.
Returns:
The constructed search filter.

createEqualityFilter

public static SearchFilter createEqualityFilter(AttributeType attributeType,
                                                AttributeValue assertionValue)
Creates a new equality search filter with the provided information.

Parameters:
attributeType - The attribute type for this equality filter.
assertionValue - The assertion value for this equality filter.
Returns:
The constructed search filter.

createEqualityFilter

public static SearchFilter createEqualityFilter(AttributeType attributeType,
                                                java.util.Set<java.lang.String> attributeOptions,
                                                AttributeValue assertionValue)
Creates a new equality search filter with the provided information.

Parameters:
attributeType - The attribute type for this equality filter.
attributeOptions - The set of attribute options for this equality filter.
assertionValue - The assertion value for this equality filter.
Returns:
The constructed search filter.

createSubstringFilter

public static SearchFilter createSubstringFilter(AttributeType attributeType,
                                                 ByteString subInitialElement,
                                                 java.util.List<ByteString> subAnyElements,
                                                 ByteString subFinalElement)
Creates a new substring search filter with the provided information.

Parameters:
attributeType - The attribute type for this filter.
subInitialElement - The subInitial element for substring filters.
subAnyElements - The subAny elements for substring filters.
subFinalElement - The subFinal element for substring filters.
Returns:
The constructed search filter.

createSubstringFilter

public static SearchFilter createSubstringFilter(AttributeType attributeType,
                                                 java.util.Set<java.lang.String> attributeOptions,
                                                 ByteString subInitialElement,
                                                 java.util.List<ByteString> subAnyElements,
                                                 ByteString subFinalElement)
Creates a new substring search filter with the provided information.

Parameters:
attributeType - The attribute type for this filter.
attributeOptions - The set of attribute options for this search filter.
subInitialElement - The subInitial element for substring filters.
subAnyElements - The subAny elements for substring filters.
subFinalElement - The subFinal element for substring filters.
Returns:
The constructed search filter.

createGreaterOrEqualFilter

public static SearchFilter createGreaterOrEqualFilter(AttributeType attributeType,
                                                      AttributeValue assertionValue)
Creates a greater-or-equal search filter with the provided information.

Parameters:
attributeType - The attribute type for this greater-or-equal filter.
assertionValue - The assertion value for this greater-or-equal filter.
Returns:
The constructed search filter.

createGreaterOrEqualFilter

public static SearchFilter createGreaterOrEqualFilter(AttributeType attributeType,
                                                      java.util.Set<java.lang.String> attributeOptions,
                                                      AttributeValue assertionValue)
Creates a greater-or-equal search filter with the provided information.

Parameters:
attributeType - The attribute type for this greater-or-equal filter.
attributeOptions - The set of attribute options for this search filter.
assertionValue - The assertion value for this greater-or-equal filter.
Returns:
The constructed search filter.

createLessOrEqualFilter

public static SearchFilter createLessOrEqualFilter(AttributeType attributeType,
                                                   AttributeValue assertionValue)
Creates a less-or-equal search filter with the provided information.

Parameters:
attributeType - The attribute type for this less-or-equal filter.
assertionValue - The assertion value for this less-or-equal filter.
Returns:
The constructed search filter.

createLessOrEqualFilter

public static SearchFilter createLessOrEqualFilter(AttributeType attributeType,
                                                   java.util.Set<java.lang.String> attributeOptions,
                                                   AttributeValue assertionValue)
Creates a less-or-equal search filter with the provided information.

Parameters:
attributeType - The attribute type for this less-or-equal filter.
attributeOptions - The set of attribute options for this search filter.
assertionValue - The assertion value for this less-or-equal filter.
Returns:
The constructed search filter.

createPresenceFilter

public static SearchFilter createPresenceFilter(AttributeType attributeType)
Creates a presence search filter with the provided information.

Parameters:
attributeType - The attribute type for this presence filter.
Returns:
The constructed search filter.

createPresenceFilter

public static SearchFilter createPresenceFilter(AttributeType attributeType,
                                                java.util.Set<java.lang.String> attributeOptions)
Creates a presence search filter with the provided information.

Parameters:
attributeType - The attribute type for this presence filter.
attributeOptions - The attribute options for this presence filter.
Returns:
The constructed search filter.

createApproximateFilter

public static SearchFilter createApproximateFilter(AttributeType attributeType,
                                                   AttributeValue assertionValue)
Creates an approximate search filter with the provided information.

Parameters:
attributeType - The attribute type for this approximate filter.
assertionValue - The assertion value for this approximate filter.
Returns:
The constructed search filter.

createApproximateFilter

public static SearchFilter createApproximateFilter(AttributeType attributeType,
                                                   java.util.Set<java.lang.String> attributeOptions,
                                                   AttributeValue assertionValue)
Creates an approximate search filter with the provided information.

Parameters:
attributeType - The attribute type for this approximate filter.
attributeOptions - The attribute options for this approximate filter.
assertionValue - The assertion value for this approximate filter.
Returns:
The constructed search filter.

createExtensibleMatchFilter

public static SearchFilter createExtensibleMatchFilter(AttributeType attributeType,
                                                       AttributeValue assertionValue,
                                                       java.lang.String matchingRuleID,
                                                       boolean dnAttributes)
                                                throws DirectoryException
Creates an extensible matching filter with the provided information.

Parameters:
attributeType - The attribute type for this extensible match filter.
assertionValue - The assertion value for this extensible match filter.
matchingRuleID - The matching rule ID for this search filter.
dnAttributes - Indicates whether to match on DN attributes for extensible match filters.
Returns:
The constructed search filter.
Throws:
DirectoryException - If the provided information is not sufficient to create an extensible match filter.

createExtensibleMatchFilter

public static SearchFilter createExtensibleMatchFilter(AttributeType attributeType,
                                                       java.util.Set<java.lang.String> attributeOptions,
                                                       AttributeValue assertionValue,
                                                       java.lang.String matchingRuleID,
                                                       boolean dnAttributes)
                                                throws DirectoryException
Creates an extensible matching filter with the provided information.

Parameters:
attributeType - The attribute type for this extensible match filter.
attributeOptions - The set of attribute options for this extensible match filter.
assertionValue - The assertion value for this extensible match filter.
matchingRuleID - The matching rule ID for this search filter.
dnAttributes - Indicates whether to match on DN attributes for extensible match filters.
Returns:
The constructed search filter.
Throws:
DirectoryException - If the provided information is not sufficient to create an extensible match filter.

createFilterFromString

public static SearchFilter createFilterFromString(java.lang.String filterString)
                                           throws DirectoryException
Decodes the provided filter string as a search filter.

Parameters:
filterString - The filter string to be decoded as a search filter.
Returns:
The search filter decoded from the provided string.
Throws:
DirectoryException - If a problem occurs while attempting to decode the provided string as a search filter.

getFilterType

public FilterType getFilterType()
Retrieves the filter type for this search filter.

Returns:
The filter type for this search filter.

getFilterComponents

public java.util.Set<SearchFilter> getFilterComponents()
Retrieves the set of filter components for this AND or OR filter. The returned list can be modified by the caller.

Returns:
The set of filter components for this AND or OR filter.

getNotComponent

public SearchFilter getNotComponent()
Retrieves the filter component for this NOT filter.

Returns:
The filter component for this NOT filter, or null if this is not a NOT filter.

getAttributeType

public AttributeType getAttributeType()
Retrieves the attribute type for this filter.

Returns:
The attribute type for this filter, or null if there is none.

getAssertionValue

public AttributeValue getAssertionValue()
Retrieves the assertion value for this filter.

Returns:
The assertion value for this filter, or null if there is none.

getSubInitialElement

public ByteString getSubInitialElement()
Retrieves the subInitial element for this substring filter.

Returns:
The subInitial element for this substring filter, or null if there is none.

getSubAnyElements

public java.util.List<ByteString> getSubAnyElements()
Retrieves the set of subAny elements for this substring filter. The returned list may be altered by the caller.

Returns:
The set of subAny elements for this substring filter.

getSubFinalElement

public ByteString getSubFinalElement()
Retrieves the subFinal element for this substring filter.

Returns:
The subFinal element for this substring filter.

getMatchingRuleID

public java.lang.String getMatchingRuleID()
Retrieves the matching rule ID for this extensible matching filter.

Returns:
The matching rule ID for this extensible matching filter.

getDNAttributes

public boolean getDNAttributes()
Retrieves the dnAttributes flag for this extensible matching filter.

Returns:
The dnAttributes flag for this extensible matching filter.

matchesEntry

public boolean matchesEntry(Entry entry)
                     throws DirectoryException
Indicates whether this search filter matches the provided entry.

Parameters:
entry - The entry for which to make the determination.
Returns:
true if this search filter matches the provided entry, or false if it does not.
Throws:
DirectoryException - If a problem is encountered during processing.

equals

public boolean equals(java.lang.Object o)
Indicates whether this search filter is equal to the provided object.

Overrides:
equals in class java.lang.Object
Parameters:
o - The object for which to make the determination.
Returns:
true if the provide object is equal to this search filter, or false if it is not.

hashCode

public int hashCode()
Retrieves the hash code for this search filter.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code for this search filter.

toString

public java.lang.String toString()
Retrieves a string representation of this search filter.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this search filter.

toString

public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this search filter to the provided buffer.

Parameters:
buffer - The buffer to which the information should be appended.