@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class Filter extends java.lang.Object implements java.io.Serializable
create(String)
method, using the syntax described in RFC 4515.
For example:
Filter f1 = Filter.create("(objectClass=*)"); Filter f2 = Filter.create("(uid=john.doe)"); Filter f3 = Filter.create("(|(givenName=John)(givenName=Johnathan))");
Filter f1 = Filter.present("objectClass"); Filter f2 = Filter.equals("uid", "john.doe"); Filter f3 = Filter.or( Filter.equals("givenName", "John"), Filter.equals("givenName", "Johnathan"));In general, it is recommended to avoid creating filters from their string representations if any of that string representation may include user-provided data or special characters including non-ASCII characters, parentheses, asterisks, or backslashes.
Modifier and Type | Field and Description |
---|---|
static byte |
FILTER_TYPE_AND
The BER type for AND search filters.
|
static byte |
FILTER_TYPE_APPROXIMATE_MATCH
The BER type for approximate match search filters.
|
static byte |
FILTER_TYPE_EQUALITY
The BER type for equality search filters.
|
static byte |
FILTER_TYPE_EXTENSIBLE_MATCH
The BER type for extensible match search filters.
|
static byte |
FILTER_TYPE_GREATER_OR_EQUAL
The BER type for greaterOrEqual search filters.
|
static byte |
FILTER_TYPE_LESS_OR_EQUAL
The BER type for lessOrEqual search filters.
|
static byte |
FILTER_TYPE_NOT
The BER type for NOT search filters.
|
static byte |
FILTER_TYPE_OR
The BER type for OR search filters.
|
static byte |
FILTER_TYPE_PRESENCE
The BER type for presence search filters.
|
static byte |
FILTER_TYPE_SUBSTRING
The BER type for substring search filters.
|
Modifier and Type | Method and Description |
---|---|
static Filter |
and(java.util.Collection<Filter> andComponents)
Creates a new AND search filter with the provided components.
|
static Filter |
and(Filter... andComponents)
Creates a new AND search filter with the provided components.
|
static Filter |
approximateMatch(java.lang.String attributeName,
byte[] assertionValue)
Creates a new approximate match search filter with the provided
information.
|
static Filter |
approximateMatch(java.lang.String attributeName,
java.lang.String assertionValue)
Creates a new approximate match search filter with the provided
information.
|
static Filter |
create(java.lang.String filterString)
Creates a new search filter from the provided string representation.
|
static Filter |
createANDFilter(java.util.Collection<Filter> andComponents)
Creates a new AND search filter with the provided components.
|
static Filter |
createANDFilter(Filter... andComponents)
Creates a new AND search filter with the provided components.
|
static Filter |
createANDFilter(java.util.List<Filter> andComponents)
Creates a new AND search filter with the provided components.
|
static Filter |
createApproximateMatchFilter(java.lang.String attributeName,
byte[] assertionValue)
Creates a new approximate match search filter with the provided
information.
|
static Filter |
createApproximateMatchFilter(java.lang.String attributeName,
java.lang.String assertionValue)
Creates a new approximate match search filter with the provided
information.
|
static Filter |
createEqualityFilter(java.lang.String attributeName,
byte[] assertionValue)
Creates a new equality search filter with the provided information.
|
static Filter |
createEqualityFilter(java.lang.String attributeName,
java.lang.String assertionValue)
Creates a new equality search filter with the provided information.
|
static Filter |
createExtensibleMatchFilter(java.lang.String attributeName,
java.lang.String matchingRuleID,
boolean dnAttributes,
byte[] assertionValue)
Creates a new extensible match search filter with the provided
information.
|
static Filter |
createExtensibleMatchFilter(java.lang.String attributeName,
java.lang.String matchingRuleID,
boolean dnAttributes,
java.lang.String assertionValue)
Creates a new extensible match search filter with the provided
information.
|
static Filter |
createGreaterOrEqualFilter(java.lang.String attributeName,
byte[] assertionValue)
Creates a new greater-or-equal search filter with the provided information.
|
static Filter |
createGreaterOrEqualFilter(java.lang.String attributeName,
java.lang.String assertionValue)
Creates a new greater-or-equal search filter with the provided information.
|
static Filter |
createLessOrEqualFilter(java.lang.String attributeName,
byte[] assertionValue)
Creates a new less-or-equal search filter with the provided information.
|
static Filter |
createLessOrEqualFilter(java.lang.String attributeName,
java.lang.String assertionValue)
Creates a new less-or-equal search filter with the provided information.
|
static Filter |
createNOTFilter(Filter notComponent)
Creates a new NOT search filter with the provided component.
|
static Filter |
createORFilter(java.util.Collection<Filter> orComponents)
Creates a new OR search filter with the provided components.
|
static Filter |
createORFilter(Filter... orComponents)
Creates a new OR search filter with the provided components.
|
static Filter |
createORFilter(java.util.List<Filter> orComponents)
Creates a new OR search filter with the provided components.
|
static Filter |
createPresenceFilter(java.lang.String attributeName)
Creates a new presence search filter with the provided information.
|
static Filter |
createSubAnyFilter(java.lang.String attributeName,
byte[]... subAny)
Creates a new substring search filter with only a subAny (contains)
component.
|
static Filter |
createSubAnyFilter(java.lang.String attributeName,
java.lang.String... subAny)
Creates a new substring search filter with only a subAny (contains)
component.
|
static Filter |
createSubFinalFilter(java.lang.String attributeName,
byte[] subFinal)
Creates a new substring search filter with only a subFinal (ends with)
component.
|
static Filter |
createSubFinalFilter(java.lang.String attributeName,
java.lang.String subFinal)
Creates a new substring search filter with only a subFinal (ends with)
component.
|
static Filter |
createSubInitialFilter(java.lang.String attributeName,
byte[] subInitial)
Creates a new substring search filter with only a subInitial (starts with)
component.
|
static Filter |
createSubInitialFilter(java.lang.String attributeName,
java.lang.String subInitial)
Creates a new substring search filter with only a subInitial (starts with)
component.
|
static java.lang.String |
createSubstringAssertion(byte[] subInitial,
byte[][] subAny,
byte[] subFinal)
Creates the string representation of a substring assertion with the
provided components.
|
static java.lang.String |
createSubstringAssertion(java.lang.String subInitial,
java.lang.String[] subAny,
java.lang.String subFinal)
Creates the string representation of a substring assertion with the
provided components.
|
static Filter |
createSubstringFilter(java.lang.String attributeName,
byte[] subInitial,
byte[][] subAny,
byte[] subFinal)
Creates a new substring search filter with the provided information.
|
static Filter |
createSubstringFilter(java.lang.String attributeName,
java.lang.String subInitial,
java.lang.String[] subAny,
java.lang.String subFinal)
Creates a new substring search filter with the provided information.
|
static Filter |
decode(ASN1Element filterElement)
Decodes the provided ASN.1 element as a search filter.
|
ASN1Element |
encode()
Encodes this search filter to an ASN.1 element suitable for inclusion in an
LDAP search request protocol op.
|
static void |
encodeValue(ASN1OctetString value,
java.lang.StringBuilder buffer)
Appends the assertion value for this filter to the provided buffer,
encoding any special characters as necessary.
|
static java.lang.String |
encodeValue(byte[] value)
Encodes the provided value into a form suitable for use as the assertion
value in the string representation of a search filter.
|
static java.lang.String |
encodeValue(java.lang.String value)
Encodes the provided value into a form suitable for use as the assertion
value in the string representation of a search filter.
|
boolean |
equals(java.lang.Object o)
Indicates whether the provided object is equal to this search filter.
|
static Filter |
equals(java.lang.String attributeName,
byte[] assertionValue)
Creates a new equality search filter with the provided information.
|
static Filter |
equals(java.lang.String attributeName,
java.lang.String assertionValue)
Creates a new equality search filter with the provided information.
|
static Filter |
extensibleMatch(java.lang.String attributeName,
java.lang.String matchingRuleID,
boolean dnAttributes,
byte[] assertionValue)
Creates a new extensible match search filter with the provided
information.
|
static Filter |
extensibleMatch(java.lang.String attributeName,
java.lang.String matchingRuleID,
boolean dnAttributes,
java.lang.String assertionValue)
Creates a new extensible match search filter with the provided
information.
|
java.lang.String |
getAssertionValue()
Retrieves the string representation of the assertion value for this search
filter.
|
byte[] |
getAssertionValueBytes()
Retrieves the binary representation of the assertion value for this search
filter.
|
java.lang.String |
getAttributeName()
Retrieves the name of the attribute type for this search filter.
|
Filter[] |
getComponents()
Retrieves the set of filter components used in this AND or OR filter.
|
boolean |
getDNAttributes()
Retrieves the dnAttributes flag for this extensible match filter.
|
byte |
getFilterType()
Retrieves the filter type for this filter.
|
java.lang.String |
getMatchingRuleID()
Retrieves the matching rule ID for this extensible match filter.
|
Filter |
getNOTComponent()
Retrieves the filter component used in this NOT filter.
|
ASN1OctetString |
getRawAssertionValue()
Retrieves the raw assertion value for this search filter as an ASN.1
octet string.
|
ASN1OctetString[] |
getRawSubAnyValues()
Retrieves the raw subAny values for this substring filter.
|
ASN1OctetString |
getRawSubFinalValue()
Retrieves the raw subFinal element for this filter as an ASN.1 octet
string.
|
ASN1OctetString |
getRawSubInitialValue()
Retrieves the raw subInitial element for this filter as an ASN.1 octet
string.
|
byte[][] |
getSubAnyBytes()
Retrieves the binary representations of the subAny elements for this
substring filter.
|
java.lang.String[] |
getSubAnyStrings()
Retrieves the string representations of the subAny elements for this
substring filter.
|
byte[] |
getSubFinalBytes()
Retrieves the binary representation of the subFinal element for this
substring filter.
|
java.lang.String |
getSubFinalString()
Retrieves the string representation of the subFinal element for this
substring filter.
|
byte[] |
getSubInitialBytes()
Retrieves the binary representation of the subInitial element for this
substring filter.
|
java.lang.String |
getSubInitialString()
Retrieves the string representation of the subInitial element for this
substring filter.
|
static Filter |
greaterOrEqual(java.lang.String attributeName,
byte[] assertionValue)
Creates a new greater-or-equal search filter with the provided information.
|
static Filter |
greaterOrEqual(java.lang.String attributeName,
java.lang.String assertionValue)
Creates a new greater-or-equal search filter with the provided information.
|
int |
hashCode()
Generates a hash code for this search filter.
|
static Filter |
lessOrEqual(java.lang.String attributeName,
byte[] assertionValue)
Creates a new less-or-equal search filter with the provided information.
|
static Filter |
lessOrEqual(java.lang.String attributeName,
java.lang.String assertionValue)
Creates a new less-or-equal search filter with the provided information.
|
boolean |
matchesEntry(Entry entry)
Indicates whether this filter matches the provided entry.
|
boolean |
matchesEntry(Entry entry,
Schema schema)
Indicates whether this filter matches the provided entry.
|
static Filter |
not(Filter notComponent)
Creates a new NOT search filter with the provided component.
|
static Filter |
or(java.util.Collection<Filter> orComponents)
Creates a new OR search filter with the provided components.
|
static Filter |
or(Filter... orComponents)
Creates a new OR search filter with the provided components.
|
static Filter |
present(java.lang.String attributeName)
Creates a new presence search filter with the provided information.
|
static Filter |
readFrom(ASN1StreamReader reader)
Reads and decodes a search filter from the provided ASN.1 stream reader.
|
static Filter |
simplifyFilter(Filter filter,
boolean reOrderElements)
Attempts to simplify the provided filter to allow it to be more efficiently
processed by the server.
|
static Filter |
subAny(java.lang.String attributeName,
byte[]... subAny)
Creates a new substring search filter with only a subAny (contains)
component.
|
static Filter |
subAny(java.lang.String attributeName,
java.lang.String... subAny)
Creates a new substring search filter with only a subAny (contains)
component.
|
static Filter |
subFinal(java.lang.String attributeName,
byte[] subFinal)
Creates a new substring search filter with only a subFinal (ends with)
component.
|
static Filter |
subFinal(java.lang.String attributeName,
java.lang.String subFinal)
Creates a new substring search filter with only a subFinal (ends with)
component.
|
static Filter |
subInitial(java.lang.String attributeName,
byte[] subInitial)
Creates a new substring search filter with only a subInitial (starts with)
component.
|
static Filter |
subInitial(java.lang.String attributeName,
java.lang.String subInitial)
Creates a new substring search filter with only a subInitial (starts with)
component.
|
static Filter |
substring(java.lang.String attributeName,
byte[] subInitial,
byte[][] subAny,
byte[] subFinal)
Creates a new substring search filter with the provided information.
|
static Filter |
substring(java.lang.String attributeName,
java.lang.String subInitial,
java.lang.String[] subAny,
java.lang.String subFinal)
Creates a new substring search filter with the provided information.
|
void |
toCode(java.util.List<java.lang.String> lineList,
int indentSpaces,
java.lang.String firstLinePrefix,
java.lang.String lastLineSuffix)
Appends a number of lines comprising the Java source code that can be used
to recreate this filter to the given list.
|
java.lang.String |
toNormalizedString()
Retrieves a normalized string representation of this search filter.
|
void |
toNormalizedString(java.lang.StringBuilder buffer)
Appends a normalized string representation of this search filter to the
provided buffer.
|
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.
|
void |
writeTo(ASN1Buffer buffer)
Writes an ASN.1-encoded representation of this filter to the provided ASN.1
buffer.
|
public static final byte FILTER_TYPE_AND
public static final byte FILTER_TYPE_OR
public static final byte FILTER_TYPE_NOT
public static final byte FILTER_TYPE_EQUALITY
public static final byte FILTER_TYPE_SUBSTRING
public static final byte FILTER_TYPE_GREATER_OR_EQUAL
public static final byte FILTER_TYPE_LESS_OR_EQUAL
public static final byte FILTER_TYPE_PRESENCE
public static final byte FILTER_TYPE_APPROXIMATE_MATCH
public static final byte FILTER_TYPE_EXTENSIBLE_MATCH
@NotNull public static Filter and(@NotNull Filter... andComponents)
createANDFilter(Filter...)
, but with a shorter method name for
convenience.andComponents
- The set of filter components to include in the AND
filter. It must not be null
.@NotNull public static Filter and(@NotNull java.util.Collection<Filter> andComponents)
createANDFilter(Collection)
, but with a shorter method name for
convenience.andComponents
- The set of filter components to include in the AND
filter. It must not be null
.@NotNull public static Filter createANDFilter(@NotNull Filter... andComponents)
andComponents
- The set of filter components to include in the AND
filter. It must not be null
.@NotNull public static Filter createANDFilter(@NotNull java.util.List<Filter> andComponents)
andComponents
- The set of filter components to include in the AND
filter. It must not be null
.@NotNull public static Filter createANDFilter(@NotNull java.util.Collection<Filter> andComponents)
andComponents
- The set of filter components to include in the AND
filter. It must not be null
.@NotNull public static Filter or(@NotNull Filter... orComponents)
createORFilter(Filter...)
, but with a shorter method name for
convenience.orComponents
- The set of filter components to include in the OR
filter. It must not be null
.@NotNull public static Filter or(@NotNull java.util.Collection<Filter> orComponents)
createORFilter(Collection)
, but with a shorter method name for
convenience.orComponents
- The set of filter components to include in the OR
filter. It must not be null
.@NotNull public static Filter createORFilter(@NotNull Filter... orComponents)
orComponents
- The set of filter components to include in the OR
filter. It must not be null
.@NotNull public static Filter createORFilter(@NotNull java.util.List<Filter> orComponents)
orComponents
- The set of filter components to include in the OR
filter. It must not be null
.@NotNull public static Filter createORFilter(@NotNull java.util.Collection<Filter> orComponents)
orComponents
- The set of filter components to include in the OR
filter. It must not be null
.@NotNull public static Filter not(@NotNull Filter notComponent)
createNOTFilter(Filter)
, but with a shorter method name for
convenience.notComponent
- The filter component to include in this NOT filter.
It must not be null
.@NotNull public static Filter createNOTFilter(@NotNull Filter notComponent)
notComponent
- The filter component to include in this NOT filter.
It must not be null
.@NotNull public static Filter equals(@NotNull java.lang.String attributeName, @NotNull java.lang.String assertionValue)
createEqualityFilter(String,String)
, but with a shorter method
name for convenience.attributeName
- The attribute name for this equality filter. It
must not be null
.assertionValue
- The assertion value for this equality filter. It
must not be null
.@NotNull public static Filter equals(@NotNull java.lang.String attributeName, @NotNull byte[] assertionValue)
createEqualityFilter(String,byte[])
, but with a shorter method
name for convenience.attributeName
- The attribute name for this equality filter. It
must not be null
.assertionValue
- The assertion value for this equality filter. It
must not be null
.@NotNull public static Filter createEqualityFilter(@NotNull java.lang.String attributeName, @NotNull java.lang.String assertionValue)
attributeName
- The attribute name for this equality filter. It
must not be null
.assertionValue
- The assertion value for this equality filter. It
must not be null
.@NotNull public static Filter createEqualityFilter(@NotNull java.lang.String attributeName, @NotNull byte[] assertionValue)
attributeName
- The attribute name for this equality filter. It
must not be null
.assertionValue
- The assertion value for this equality filter. It
must not be null
.@NotNull public static Filter substring(@NotNull java.lang.String attributeName, @Nullable java.lang.String subInitial, @Nullable java.lang.String[] subAny, @Nullable java.lang.String subFinal)
null
.
createSubstringFilter(String,String,String[],String)
, but with a
shorter method name for convenience.attributeName
- The attribute name for this substring filter. It
must not be null
.subInitial
- The subInitial component for this substring filter.
It may be null
if there is no subInitial
component, but it must not be empty.subAny
- The set of subAny components for this substring
filter. It may be null
or empty if there
are no subAny components.subFinal
- The subFinal component for this substring filter.
It may be null
if there is no subFinal
component, but it must not be empty.@NotNull public static Filter substring(@NotNull java.lang.String attributeName, @Nullable byte[] subInitial, @Nullable byte[][] subAny, @Nullable byte[] subFinal)
null
.
createSubstringFilter(String,byte[],byte[][],byte[])
, but with a
shorter method name for convenience.attributeName
- The attribute name for this substring filter. It
must not be null
.subInitial
- The subInitial component for this substring filter.
It may be null
if there is no subInitial
component, but it must not be empty.subAny
- The set of subAny components for this substring
filter. It may be null
or empty if there
are no subAny components.subFinal
- The subFinal component for this substring filter.
It may be null
if there is no subFinal
component, but it must not be empty.@NotNull public static Filter createSubstringFilter(@NotNull java.lang.String attributeName, @Nullable java.lang.String subInitial, @Nullable java.lang.String[] subAny, @Nullable java.lang.String subFinal)
null
.attributeName
- The attribute name for this substring filter. It
must not be null
.subInitial
- The subInitial component for this substring filter.
It may be null
if there is no subInitial
component, but it must not be empty.subAny
- The set of subAny components for this substring
filter. It may be null
or empty if there
are no subAny components.subFinal
- The subFinal component for this substring filter.
It may be null
if there is no subFinal
component, but it must not be empty.@NotNull public static Filter createSubstringFilter(@NotNull java.lang.String attributeName, @Nullable byte[] subInitial, @Nullable byte[][] subAny, @Nullable byte[] subFinal)
null
.attributeName
- The attribute name for this substring filter. It
must not be null
.subInitial
- The subInitial component for this substring filter.
It may be null
if there is no subInitial
component, but it must not be empty.subAny
- The set of subAny components for this substring
filter. It may be null
or empty if there
are no subAny components.subFinal
- The subFinal component for this substring filter.
It may be null
if there is no subFinal
component, but it must not be empty.@NotNull public static Filter subInitial(@NotNull java.lang.String attributeName, @NotNull java.lang.String subInitial)
createSubInitialFilter(String,String)
, but with a shorter method
name for convenience.attributeName
- The attribute name for this substring filter. It
must not be null
.subInitial
- The subInitial component for this substring filter.
It must not be null
or empty.@NotNull public static Filter subInitial(@NotNull java.lang.String attributeName, @NotNull byte[] subInitial)
createSubInitialFilter(String,byte[])
, but with a shorter method
name for convenience.attributeName
- The attribute name for this substring filter. It
must not be null
.subInitial
- The subInitial component for this substring filter.
It must not be null
or empty.@NotNull public static Filter createSubInitialFilter(@NotNull java.lang.String attributeName, @NotNull java.lang.String subInitial)
attributeName
- The attribute name for this substring filter. It
must not be null
.subInitial
- The subInitial component for this substring filter.
It must not be null
or empty.@NotNull public static Filter createSubInitialFilter(@NotNull java.lang.String attributeName, @NotNull byte[] subInitial)
attributeName
- The attribute name for this substring filter. It
must not be null
.subInitial
- The subInitial component for this substring filter.
It must not be null
or empty.@NotNull public static Filter subAny(@NotNull java.lang.String attributeName, @NotNull java.lang.String... subAny)
createSubAnyFilter(String,String...)
, but with a shorter method
name for convenience.attributeName
- The attribute name for this substring filter. It
must not be null
.subAny
- The subAny values for this substring filter. It
must not be null
or empty.@NotNull public static Filter subAny(@NotNull java.lang.String attributeName, @NotNull byte[]... subAny)
createSubAnyFilter(String,byte[][])
, but with a shorter method
name for convenience.attributeName
- The attribute name for this substring filter. It
must not be null
.subAny
- The subAny values for this substring filter. It
must not be null
or empty.@NotNull public static Filter createSubAnyFilter(@NotNull java.lang.String attributeName, @NotNull java.lang.String... subAny)
attributeName
- The attribute name for this substring filter. It
must not be null
.subAny
- The subAny values for this substring filter. It
must not be null
or empty.@NotNull public static Filter createSubAnyFilter(@NotNull java.lang.String attributeName, @NotNull byte[]... subAny)
attributeName
- The attribute name for this substring filter. It
must not be null
.subAny
- The subAny values for this substring filter. It
must not be null
or empty.@NotNull public static Filter subFinal(@NotNull java.lang.String attributeName, @NotNull java.lang.String subFinal)
createSubFinalFilter(String,String)
, but with a shorter method
name for convenience.attributeName
- The attribute name for this substring filter. It
must not be null
.subFinal
- The subFinal component for this substring filter.
It must not be null
or empty.@NotNull public static Filter subFinal(@NotNull java.lang.String attributeName, @NotNull byte[] subFinal)
createSubFinalFilter(String,byte[])
, but with a shorter method
name for convenience.attributeName
- The attribute name for this substring filter. It
must not be null
.subFinal
- The subFinal component for this substring filter.
It must not be null
or empty.@NotNull public static Filter createSubFinalFilter(@NotNull java.lang.String attributeName, @NotNull java.lang.String subFinal)
attributeName
- The attribute name for this substring filter. It
must not be null
.subFinal
- The subFinal component for this substring filter.
It must not be null
or empty.@NotNull public static Filter createSubFinalFilter(@NotNull java.lang.String attributeName, @NotNull byte[] subFinal)
attributeName
- The attribute name for this substring filter. It
must not be null
.subFinal
- The subFinal component for this substring filter.
It must not be null
or empty.@NotNull public static Filter greaterOrEqual(@NotNull java.lang.String attributeName, @NotNull java.lang.String assertionValue)
createGreaterOrEqualFilter(String,String)
, but with a shorter
method name for convenience.attributeName
- The attribute name for this greater-or-equal
filter. It must not be null
.assertionValue
- The assertion value for this greater-or-equal
filter. It must not be null
.@NotNull public static Filter greaterOrEqual(@NotNull java.lang.String attributeName, @NotNull byte[] assertionValue)
createGreaterOrEqualFilter(String,byte[])
, but with a shorter
method name for convenience.attributeName
- The attribute name for this greater-or-equal
filter. It must not be null
.assertionValue
- The assertion value for this greater-or-equal
filter. It must not be null
.@NotNull public static Filter createGreaterOrEqualFilter(@NotNull java.lang.String attributeName, @NotNull java.lang.String assertionValue)
attributeName
- The attribute name for this greater-or-equal
filter. It must not be null
.assertionValue
- The assertion value for this greater-or-equal
filter. It must not be null
.@NotNull public static Filter createGreaterOrEqualFilter(@NotNull java.lang.String attributeName, @NotNull byte[] assertionValue)
attributeName
- The attribute name for this greater-or-equal
filter. It must not be null
.assertionValue
- The assertion value for this greater-or-equal
filter. It must not be null
.@NotNull public static Filter lessOrEqual(@NotNull java.lang.String attributeName, @NotNull java.lang.String assertionValue)
createLessOrEqualFilter(String,String)
, but with a shorter method
name for convenience.attributeName
- The attribute name for this less-or-equal
filter. It must not be null
.assertionValue
- The assertion value for this less-or-equal
filter. It must not be null
.@NotNull public static Filter lessOrEqual(@NotNull java.lang.String attributeName, @NotNull byte[] assertionValue)
createLessOrEqualFilter(String,byte[])
, but with a shorter method
name for convenience.attributeName
- The attribute name for this less-or-equal
filter. It must not be null
.assertionValue
- The assertion value for this less-or-equal
filter. It must not be null
.@NotNull public static Filter createLessOrEqualFilter(@NotNull java.lang.String attributeName, @NotNull java.lang.String assertionValue)
attributeName
- The attribute name for this less-or-equal
filter. It must not be null
.assertionValue
- The assertion value for this less-or-equal
filter. It must not be null
.@NotNull public static Filter createLessOrEqualFilter(@NotNull java.lang.String attributeName, @NotNull byte[] assertionValue)
attributeName
- The attribute name for this less-or-equal
filter. It must not be null
.assertionValue
- The assertion value for this less-or-equal
filter. It must not be null
.@NotNull public static Filter present(@NotNull java.lang.String attributeName)
createPresenceFilter(String)
, but with a shorter method name for
convenience.attributeName
- The attribute name for this presence filter. It
must not be null
.@NotNull public static Filter createPresenceFilter(@NotNull java.lang.String attributeName)
attributeName
- The attribute name for this presence filter. It
must not be null
.@NotNull public static Filter approximateMatch(@NotNull java.lang.String attributeName, @NotNull java.lang.String assertionValue)
createApproximateMatchFilter(String,String)
, but with a shorter
method name for convenience.attributeName
- The attribute name for this approximate match
filter. It must not be null
.assertionValue
- The assertion value for this approximate match
filter. It must not be null
.@NotNull public static Filter approximateMatch(@NotNull java.lang.String attributeName, @NotNull byte[] assertionValue)
createApproximateMatchFilter(String,byte[])
, but with a shorter
method name for convenience.attributeName
- The attribute name for this approximate match
filter. It must not be null
.assertionValue
- The assertion value for this approximate match
filter. It must not be null
.@NotNull public static Filter createApproximateMatchFilter(@NotNull java.lang.String attributeName, @NotNull java.lang.String assertionValue)
attributeName
- The attribute name for this approximate match
filter. It must not be null
.assertionValue
- The assertion value for this approximate match
filter. It must not be null
.@NotNull public static Filter createApproximateMatchFilter(@NotNull java.lang.String attributeName, @NotNull byte[] assertionValue)
attributeName
- The attribute name for this approximate match
filter. It must not be null
.assertionValue
- The assertion value for this approximate match
filter. It must not be null
.@NotNull public static Filter extensibleMatch(@Nullable java.lang.String attributeName, @Nullable java.lang.String matchingRuleID, boolean dnAttributes, @NotNull java.lang.String assertionValue)
createExtensibleMatchFilter(String,String,boolean,String)
, but
with a shorter method name for convenience.attributeName
- The attribute name for this extensible match
filter.matchingRuleID
- The matching rule ID for this extensible match
filter.dnAttributes
- Indicates whether the match should be performed
against attributes in the target entry's DN.assertionValue
- The assertion value for this extensible match
filter. It must not be null
.@NotNull public static Filter extensibleMatch(@Nullable java.lang.String attributeName, @Nullable java.lang.String matchingRuleID, boolean dnAttributes, @NotNull byte[] assertionValue)
createExtensibleMatchFilter(String,String,boolean,byte[])
, but
with a shorter method name for convenience.attributeName
- The attribute name for this extensible match
filter.matchingRuleID
- The matching rule ID for this extensible match
filter.dnAttributes
- Indicates whether the match should be performed
against attributes in the target entry's DN.assertionValue
- The assertion value for this extensible match
filter. It must not be null
.@NotNull public static Filter createExtensibleMatchFilter(@Nullable java.lang.String attributeName, @Nullable java.lang.String matchingRuleID, boolean dnAttributes, @NotNull java.lang.String assertionValue)
attributeName
- The attribute name for this extensible match
filter.matchingRuleID
- The matching rule ID for this extensible match
filter.dnAttributes
- Indicates whether the match should be performed
against attributes in the target entry's DN.assertionValue
- The assertion value for this extensible match
filter. It must not be null
.@NotNull public static Filter createExtensibleMatchFilter(@Nullable java.lang.String attributeName, @Nullable java.lang.String matchingRuleID, boolean dnAttributes, @NotNull byte[] assertionValue)
attributeName
- The attribute name for this extensible match
filter.matchingRuleID
- The matching rule ID for this extensible match
filter.dnAttributes
- Indicates whether the match should be performed
against attributes in the target entry's DN.assertionValue
- The assertion value for this extensible match
filter. It must not be null
.@NotNull public static Filter create(@NotNull java.lang.String filterString) throws LDAPException
filterString
- The string representation of the filter to create.
It must not be null
.LDAPException
- If the provided string cannot be decoded as a valid
LDAP search filter.public void writeTo(@NotNull ASN1Buffer buffer)
buffer
- The ASN.1 buffer to which the encoded representation should
be written.@NotNull public ASN1Element encode()
@NotNull public static Filter readFrom(@NotNull ASN1StreamReader reader) throws LDAPException
reader
- The ASN.1 stream reader from which to read the filter.LDAPException
- If an error occurs while reading or parsing the
search filter.@NotNull public static Filter decode(@NotNull ASN1Element filterElement) throws LDAPException
filterElement
- The ASN.1 element containing the encoded search
filter.LDAPException
- If the provided ASN.1 element cannot be decoded as
a search filter.public byte getFilterType()
@NotNull public Filter[] getComponents()
@Nullable public Filter getNOTComponent()
null
if
this is some other type of filter.@Nullable public java.lang.String getAttributeName()
null
if it is not applicable for this type of filter.@Nullable public java.lang.String getAssertionValue()
null
if it is not applicable for this type of
filter.@Nullable public byte[] getAssertionValueBytes()
null
if it is not applicable for this type of
filter.@Nullable public ASN1OctetString getRawAssertionValue()
null
if it is not applicable for this type of
filter.@Nullable public java.lang.String getSubInitialString()
null
if this is some other type of
filter, or if it is a substring filter with no subInitial element.@Nullable public byte[] getSubInitialBytes()
null
if this is some other type of
filter, or if it is a substring filter with no subInitial element.@Nullable public ASN1OctetString getRawSubInitialValue()
null
if this is not a substring filter, or if
it is a substring filter with no subInitial element.@NotNull public java.lang.String[] getSubAnyStrings()
@NotNull public byte[][] getSubAnyBytes()
@NotNull public ASN1OctetString[] getRawSubAnyValues()
@Nullable public java.lang.String getSubFinalString()
null
if this is some other type of
filter, or if it is a substring filter with no subFinal element.@Nullable public byte[] getSubFinalBytes()
null
if this is some other type of
filter, or if it is a substring filter with no subFinal element.@Nullable public ASN1OctetString getRawSubFinalValue()
null
if this is not a substring filter, or if
it is a substring filter with no subFinal element.@Nullable public java.lang.String getMatchingRuleID()
null
if this is some other type of filter, or if this
extensible match filter does not have a matching rule ID.public boolean getDNAttributes()
public boolean matchesEntry(@NotNull Entry entry) throws LDAPException
entry
- The entry for which to make the determination. It must not
be null
.true
if this filter appears to match the provided entry,
or false
if not.LDAPException
- If a problem occurs while trying to make the
determination.public boolean matchesEntry(@NotNull Entry entry, @Nullable Schema schema) throws LDAPException
entry
- The entry for which to make the determination. It must not
be null
.schema
- The schema to use when making the determination. If this
is null
, then all matching will be performed using
a case-ignore matching rule.true
if this filter appears to match the provided entry,
or false
if not.LDAPException
- If a problem occurs while trying to make the
determination.@NotNull public static Filter simplifyFilter(@NotNull Filter filter, boolean reOrderElements)
reOrderElements
is true, then this method will attempt to
re-order the elements inside AND and OR filters in an attempt to
ensure that the components which are likely to be the most efficient
come earlier than those which are likely to be the least efficient.
This can speed up processing in servers that process filter
components in a left-to-right order.filter
- The filter to attempt to simplify.reOrderElements
- Indicates whether this method may re-order the
elements in the filter so that, in a server that
evaluates the components in a left-to-right order,
the components which are likely to be more
efficient to process will be listed before those
which are likely to be less efficient.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(@Nullable java.lang.Object o)
equals
in class java.lang.Object
o
- The object for which to make the determination.true
if the provided object can be considered equal to
this search filter, or false
if not.@NotNull public java.lang.String toString()
toString
in class java.lang.Object
public void toString(@NotNull java.lang.StringBuilder buffer)
buffer
- The buffer to which to append a string representation of
this search filter.@NotNull public java.lang.String toNormalizedString()
public void toNormalizedString(@NotNull java.lang.StringBuilder buffer)
buffer
- The buffer to which to append a normalized string
representation of this search filter.@NotNull public static java.lang.String encodeValue(@NotNull java.lang.String value)
value
- The value to be encoded. It must not be null
.@NotNull public static java.lang.String createSubstringAssertion(@Nullable java.lang.String subInitial, @Nullable java.lang.String[] subAny, @Nullable java.lang.String subFinal)
subInitial
- The subInitial component for this substring filter. It
may be null
if there is no subInitial
component, but it must not be empty.subAny
- The set of subAny components for this substring filter.
It may be null
or empty if there are no subAny
components.subFinal
- The subFinal component for this substring filter. It
may be null
if there is no subFinal component,
but it must not be empty.@NotNull public static java.lang.String createSubstringAssertion(@Nullable byte[] subInitial, @Nullable byte[][] subAny, @Nullable byte[] subFinal)
subInitial
- The subInitial component for this substring filter. It
may be null
if there is no subInitial
component, but it must not be empty.subAny
- The set of subAny components for this substring filter.
It may be null
or empty if there are no subAny
components.subFinal
- The subFinal component for this substring filter. It
may be null
if there is no subFinal component,
but it must not be empty.@NotNull public static java.lang.String encodeValue(@NotNull byte[] value)
value
- The value to be encoded. It must not be null
.public static void encodeValue(@NotNull ASN1OctetString value, @NotNull java.lang.StringBuilder buffer)
value
- The value to be encoded.buffer
- The buffer to which the assertion value should be appended.public void toCode(@NotNull java.util.List<java.lang.String> lineList, int indentSpaces, @Nullable java.lang.String firstLinePrefix, @Nullable java.lang.String lastLineSuffix)
lineList
- The list to which the source code lines should be
added.indentSpaces
- The number of spaces that should be used to indent
the generated code. It must not be negative.firstLinePrefix
- An optional string that should precede the static
method call (e.g., it could be used for an
attribute assignment, like "Filter f = "). It may
be null
or empty if there should be no
first line prefix.lastLineSuffix
- An optional suffix that should follow the closing
parenthesis of the static method call (e.g., it
could be a semicolon to represent the end of a
Java statement). It may be null
or empty
if there should be no last line suffix.