org.opends.server.types
Class RawFilter

java.lang.Object
  extended by org.opends.server.types.RawFilter
Direct Known Subclasses:
LDAPFilter

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

This class defines the data structures and methods to use when interacting with a raw search filter, which defines a set of criteria for locating entries in a search request.


Constructor Summary
RawFilter()
           
 
Method Summary
static RawFilter create(SearchFilter filter)
          Creates a new LDAP filter from the provided search filter.
static RawFilter create(java.lang.String filterString)
          Creates a new LDAP filter from the provided filter string.
static LDAPFilter createANDFilter(java.util.ArrayList<RawFilter> filterComponents)
          Creates a new AND search filter with the provided filter components.
static LDAPFilter createApproximateFilter(java.lang.String attributeType, ByteString assertionValue)
          Creates a new approximate search filter with the provided information.
static LDAPFilter createEqualityFilter(java.lang.String attributeType, ByteString assertionValue)
          Creates a new equality search filter with the provided information.
static LDAPFilter createExtensibleFilter(java.lang.String matchingRuleID, java.lang.String attributeType, ByteString assertionValue, boolean dnAttributes)
          Creates a new extensible matching search filter with the provided information.
static LDAPFilter createGreaterOrEqualFilter(java.lang.String attributeType, ByteString assertionValue)
          Creates a new greater or equal search filter with the provided information.
static LDAPFilter createLessOrEqualFilter(java.lang.String attributeType, ByteString assertionValue)
          Creates a new less or equal search filter with the provided information.
static LDAPFilter createNOTFilter(RawFilter notComponent)
          Creates a new NOT search filter with the provided filter component.
static LDAPFilter createORFilter(java.util.ArrayList<RawFilter> filterComponents)
          Creates a new OR search filter with the provided filter components.
static LDAPFilter createPresenceFilter(java.lang.String attributeType)
          Creates a new presence search filter with the provided attribute type.
static LDAPFilter createSubstringFilter(java.lang.String attributeType, ByteString subInitialElement, java.util.ArrayList<ByteString> subAnyElements, ByteString subFinalElement)
          Creates a new substring search filter with the provided information.
static LDAPFilter decode(ASN1Element element)
          Decodes the provided ASN.1 element as a raw search filter.
 ASN1Element encode()
          Encodes this search filter to an ASN.1 element.
abstract  ByteString getAssertionValue()
          Retrieves the assertion value for this search filter.
abstract  java.lang.String getAttributeType()
          Retrieves the attribute type for this search filter.
abstract  boolean getDNAttributes()
          Retrieves the value of the DN attributes flag for this extensible match filter, which indicates whether to perform matching on the components of the DN.
abstract  java.util.ArrayList<RawFilter> getFilterComponents()
          Retrieves the set of subordinate filter components for AND or OR searches.
abstract  FilterType getFilterType()
          Retrieves the filter type for this search filter.
abstract  java.lang.String getMatchingRuleID()
          Retrieves the matching rule ID for this extensible match filter.
abstract  RawFilter getNOTComponent()
          Retrieves the subordinate filter component for NOT searches.
abstract  java.util.ArrayList<ByteString> getSubAnyElements()
          Retrieves the set of subAny elements for this substring filter.
abstract  ByteString getSubFinalElement()
          Retrieves the subFinal element for this substring filter.
abstract  ByteString getSubInitialElement()
          Retrieves the subInitial component for this substring filter.
abstract  void setAssertionValue(ByteString assertionValue)
          Specifies the assertion value for this search filter.
abstract  void setAttributeType(java.lang.String attributeType)
          Specifies the attribute type for this search filter.
abstract  void setDNAttributes(boolean dnAttributes)
          Specifies the value of the DN attributes flag for this extensible match filter.
abstract  void setFilterComponents(java.util.ArrayList<RawFilter> filterComponents)
          Specifies the set of subordinate filter components for AND or OR searches.
abstract  void setMatchingRuleID(java.lang.String matchingRuleID)
          Specifies the matching rule ID for this extensible match filter.
abstract  void setNOTComponent(RawFilter notComponent)
          Specifies the subordinate filter component for NOT searches.
abstract  void setSubAnyElements(java.util.ArrayList<ByteString> subAnyElements)
          Specifies the set of subAny values for this substring filter.
abstract  void setSubFinalElement(ByteString subFinalElement)
          Specifies the subFinal element for this substring filter.
abstract  void setSubInitialElement(ByteString subInitialElement)
          Specifies the subInitial element for this substring filter.
abstract  SearchFilter toSearchFilter()
          Converts this raw filter to a search filter that may be used by the Directory Server's core processing.
 java.lang.String toString()
          Retrieves a string representation of this search filter.
abstract  void toString(java.lang.StringBuilder buffer)
          Appends a string representation of this search filter to the provided buffer.
static void valueToFilterString(java.lang.StringBuilder buffer, ByteString value)
          Appends a properly-cleaned version of the provided value to the given buffer so that it can be safely used in string representations of this search filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RawFilter

public RawFilter()
Method Detail

create

public static RawFilter create(java.lang.String filterString)
                        throws LDAPException
Creates a new LDAP filter from the provided filter string.

Parameters:
filterString - The filter string to use to create this raw filter.
Returns:
The raw filter decoded from the provided filter string.
Throws:
LDAPException - If the provied filter string could not be decoded as a raw filter.

create

public static RawFilter create(SearchFilter filter)
Creates a new LDAP filter from the provided search filter.

Parameters:
filter - The search filter to use to create this raw filter.
Returns:
The constructed raw filter.

createANDFilter

public static LDAPFilter createANDFilter(java.util.ArrayList<RawFilter> filterComponents)
Creates a new AND search filter with the provided filter components.

Parameters:
filterComponents - The filter components for this AND filter.
Returns:
The AND search filter with the provided filter components.

createORFilter

public static LDAPFilter createORFilter(java.util.ArrayList<RawFilter> filterComponents)
Creates a new OR search filter with the provided filter components.

Parameters:
filterComponents - The filter components for this OR filter.
Returns:
The OR search filter with the provided filter components.

createNOTFilter

public static LDAPFilter createNOTFilter(RawFilter notComponent)
Creates a new NOT search filter with the provided filter component.

Parameters:
notComponent - The filter component for this NOT filter.
Returns:
The NOT search filter with the provided filter component.

createEqualityFilter

public static LDAPFilter createEqualityFilter(java.lang.String attributeType,
                                              ByteString 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 equality search filter.

createSubstringFilter

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

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

createGreaterOrEqualFilter

public static LDAPFilter createGreaterOrEqualFilter(java.lang.String attributeType,
                                                    ByteString assertionValue)
Creates a new 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 greater or equal search filter.

createLessOrEqualFilter

public static LDAPFilter createLessOrEqualFilter(java.lang.String attributeType,
                                                 ByteString assertionValue)
Creates a new 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 less or equal search filter.

createPresenceFilter

public static LDAPFilter createPresenceFilter(java.lang.String attributeType)
Creates a new presence search filter with the provided attribute type.

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

createApproximateFilter

public static LDAPFilter createApproximateFilter(java.lang.String attributeType,
                                                 ByteString assertionValue)
Creates a new 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 approximate search filter.

createExtensibleFilter

public static LDAPFilter createExtensibleFilter(java.lang.String matchingRuleID,
                                                java.lang.String attributeType,
                                                ByteString assertionValue,
                                                boolean dnAttributes)
Creates a new extensible matching search filter with the provided information.

Parameters:
matchingRuleID - The matching rule ID for this extensible filter.
attributeType - The attribute type for this extensible filter.
assertionValue - The assertion value for this extensible filter.
dnAttributes - The dnAttributes flag for this extensible filter.
Returns:
The constructed extensible matching search filter.

getFilterType

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

Returns:
The filter type for this search filter.

getFilterComponents

public abstract java.util.ArrayList<RawFilter> getFilterComponents()
Retrieves the set of subordinate filter components for AND or OR searches. The contents of the returned list may be altered by the caller.

Returns:
The set of subordinate filter components for AND and OR searches, or null if this is not an AND or OR search.

setFilterComponents

public abstract void setFilterComponents(java.util.ArrayList<RawFilter> filterComponents)
Specifies the set of subordinate filter components for AND or OR searches. This will be ignored for all other filter types.

Parameters:
filterComponents - The set of subordinate filter components for AND or OR searches.

getNOTComponent

public abstract RawFilter getNOTComponent()
Retrieves the subordinate filter component for NOT searches.

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

setNOTComponent

public abstract void setNOTComponent(RawFilter notComponent)
Specifies the subordinate filter component for NOT searches. This will be ignored for any other type of search.

Parameters:
notComponent - The subordinate filter component for NOT searches.

getAttributeType

public abstract java.lang.String getAttributeType()
Retrieves the attribute type for this search filter. This will not be applicable for AND, OR, or NOT filters.

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

setAttributeType

public abstract void setAttributeType(java.lang.String attributeType)
Specifies the attribute type for this search filter. This will be ignored for AND, OR, and NOT searches.

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

getAssertionValue

public abstract ByteString getAssertionValue()
Retrieves the assertion value for this search filter. This will only be applicable for equality, greater or equal, less or equal, approximate, or extensible matching filters.

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

setAssertionValue

public abstract void setAssertionValue(ByteString assertionValue)
Specifies the assertion value for this search filter. This will be ignored for types of filters that do not have an assertion value.

Parameters:
assertionValue - The assertion value for this search filter.

getSubInitialElement

public abstract ByteString getSubInitialElement()
Retrieves the subInitial component for this substring filter. This is only applicable for substring search filters, but even substring filters might not have a value for this component.

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

setSubInitialElement

public abstract void setSubInitialElement(ByteString subInitialElement)
Specifies the subInitial element for this substring filter. This will be ignored for all other types of filters.

Parameters:
subInitialElement - The subInitial element for this substring filter.

getSubAnyElements

public abstract java.util.ArrayList<ByteString> getSubAnyElements()
Retrieves the set of subAny elements for this substring filter. This is only applicable for substring search filters, and even then may be null or empty for some substring filters.

Returns:
The set of subAny elements for this substring filter, or null if there are none.

setSubAnyElements

public abstract void setSubAnyElements(java.util.ArrayList<ByteString> subAnyElements)
Specifies the set of subAny values for this substring filter. This will be ignored for other filter types.

Parameters:
subAnyElements - The set of subAny elements for this substring filter.

getSubFinalElement

public abstract ByteString getSubFinalElement()
Retrieves the subFinal element for this substring filter. This is not applicable for any other filter type, and may not be provided even for some substring filters.

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

setSubFinalElement

public abstract void setSubFinalElement(ByteString subFinalElement)
Specifies the subFinal element for this substring filter. This will be ignored for all other filter types.

Parameters:
subFinalElement - The subFinal element for this substring filter.

getMatchingRuleID

public abstract java.lang.String getMatchingRuleID()
Retrieves the matching rule ID for this extensible match filter. This is not applicable for any other type of filter and may not be included in some extensible matching filters.

Returns:
The matching rule ID for this extensible match filter, or null if there is none.

setMatchingRuleID

public abstract void setMatchingRuleID(java.lang.String matchingRuleID)
Specifies the matching rule ID for this extensible match filter. It will be ignored for all other filter types.

Parameters:
matchingRuleID - The matching rule ID for this extensible match filter.

getDNAttributes

public abstract boolean getDNAttributes()
Retrieves the value of the DN attributes flag for this extensible match filter, which indicates whether to perform matching on the components of the DN. This does not apply for any other type of filter.

Returns:
The value of the DN attributes flag for this extensibleMatch filter.

setDNAttributes

public abstract void setDNAttributes(boolean dnAttributes)
Specifies the value of the DN attributes flag for this extensible match filter. It will be ignored for all other filter types.

Parameters:
dnAttributes - The value of the DN attributes flag for this extensible match filter.

encode

public final ASN1Element encode()
Encodes this search filter to an ASN.1 element.

Returns:
The ASN.1 element containing the encoded search filter.

decode

public static LDAPFilter decode(ASN1Element element)
                         throws LDAPException
Decodes the provided ASN.1 element as a raw search filter.

Parameters:
element - The ASN.1 element to decode.
Returns:
The decoded search filter.
Throws:
LDAPException - If the provided ASN.1 element cannot be decoded as a raw search filter.

toSearchFilter

public abstract SearchFilter toSearchFilter()
                                     throws DirectoryException
Converts this raw filter to a search filter that may be used by the Directory Server's core processing.

Returns:
The generated search filter.
Throws:
DirectoryException - If a problem occurs while attempting to construct the 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 abstract 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.

valueToFilterString

public static void valueToFilterString(java.lang.StringBuilder buffer,
                                       ByteString value)
Appends a properly-cleaned version of the provided value to the given buffer so that it can be safely used in string representations of this search filter. The formatting changes that may be performed will be in compliance with the specification in RFC 2254.

Parameters:
buffer - The buffer to which the "safe" version of the value will be appended.
value - The value to be appended to the buffer.