|
All LDAP Classes Internal LDAP Classes |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.novell.ldap.asn1.ASN1Object
com.novell.ldap.asn1.ASN1Choice
com.novell.ldap.rfc2251.RfcFilter
Represents an LDAP Filter.
This filter object can be created from a String or can be built up programatically by adding filter components one at a time. Existing filter components can be iterated though.
Each filter component has an integer identifier defined in this class.
The following are basic filter components: EQUALITY_MATCH
,
GREATER_OR_EQUAL
, LESS_OR_EQUAL
, SUBSTRINGS
,
PRESENT
, APPROX_MATCH
, EXTENSIBLE_MATCH
.
More filters can be nested together into more complex filters with the
following filter components: AND
, OR
, NOT
Substrings can have three components:
Filter ::= CHOICE { and [0] SET OF Filter, or [1] SET OF Filter, not [2] Filter, equalityMatch [3] AttributeValueAssertion, substrings [4] SubstringFilter, greaterOrEqual [5] AttributeValueAssertion, lessOrEqual [6] AttributeValueAssertion, present [7] AttributeDescription, approxMatch [8] AttributeValueAssertion, extensibleMatch [9] MatchingRuleAssertion }
Nested Class Summary | |
private class |
RfcFilter.FilterIterator
This inner class wrappers the Search Filter with an iterator. |
(package private) class |
RfcFilter.FilterTokenizer
This inner class will tokenize the components of an RFC 2254 search filter. |
Field Summary | |
static int |
AND
Identifier for AND component. |
static int |
ANY
Identifier for ANY component. |
static int |
APPROX_MATCH
Identifier for APPROX_MATCH component. |
static int |
EQUALITY_MATCH
Identifier for EQUALITY_MATCH component. |
static int |
EXTENSIBLE_MATCH
Identifier for EXTENSIBLE_MATCH component. |
private java.util.Stack |
filterStack
|
static int |
FINAL
Identifier for FINAL component. |
private boolean |
finalFound
|
private RfcFilter.FilterTokenizer |
ft
|
static int |
GREATER_OR_EQUAL
Identifier for GREATER_OR_EQUAL component. |
static int |
INITIAL
Identifier for INITIAL component. |
static int |
LESS_OR_EQUAL
Identifier for LESS_OR_EQUAL component. |
static int |
NOT
Identifier for NOT component. |
static int |
OR
Identifier for OR component. |
static int |
PRESENT
Identifier for PRESENT component. |
static int |
SUBSTRINGS
Identifier for SUBSTRINGS component. |
Fields inherited from class com.novell.ldap.asn1.ASN1Choice |
|
Fields inherited from class com.novell.ldap.asn1.ASN1Object |
|
Constructor Summary | |
RfcFilter()
Constructs a Filter object that will be built up piece by piece. |
|
RfcFilter(java.lang.String filter)
Constructs a Filter object by parsing an RFC 2254 Search Filter String. |
Method Summary | |
void |
addAttributeValueAssertion(int rfcType,
java.lang.String attrName,
byte[] value)
Creates and adds an AttributeValueAssertion to the filter. |
void |
addExtensibleMatch(java.lang.String matchingRule,
java.lang.String attrName,
byte[] value,
boolean useDNMatching)
Adds an extensible match to the filter. |
private void |
addObject(ASN1Object current)
Called by sequential filter building methods to add to a filter component. |
void |
addPresent(java.lang.String attrName)
Creates and adds a present matching to the filter. |
void |
addSubstring(int type,
byte[] value)
Adds a Substring component of initial, any or final substring matching. |
private static java.lang.String |
byteString(byte[] value)
Convert a UTF8 encoded string, or binary data, into a String encoded for a string filter. |
void |
endNestedFilter(int rfcType)
Completes a nested filter and checks for the valid filter type. |
void |
endSubstrings()
Completes a SubString filter component. |
java.lang.String |
filterToString()
Creates and returns a String representation of this filter. |
java.util.Iterator |
getFilterIterator()
Creates an iterator over the preparsed segments of a filter. |
(package private) static int |
hex2int(char c)
Convert hex character to an integer. |
private ASN1Tagged |
parse(java.lang.String filterExpr)
Parses an RFC 2251 filter string into an ASN.1 LDAP Filter object. |
private ASN1Tagged |
parseFilter()
Parses an RFC 2254 filter |
private ASN1Tagged |
parseFilterComp()
RFC 2254 filter helper method. |
private ASN1SetOf |
parseFilterList()
Must have 1 or more Filters |
void |
startNestedFilter(int rfcType)
Creates and adds the ASN1Tagged value for a nestedFilter: AND, OR, or NOT. |
void |
startSubstrings(java.lang.String attrName)
Creates and addes a substrings filter component. |
private static void |
stringFilter(java.util.Iterator itr,
java.lang.StringBuffer filter)
Uses a filterIterator to create a string representation of a filter. |
private byte[] |
unescapeString(java.lang.String string)
Replace escaped hex digits with the equivalent binary representation. |
Methods inherited from class com.novell.ldap.asn1.ASN1Choice |
choiceValue, encode, getIdentifier, setChoiceValue, setIdentifier, toString |
Methods inherited from class com.novell.ldap.asn1.ASN1Object |
getEncoding |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int AND
public static final int OR
public static final int NOT
public static final int EQUALITY_MATCH
public static final int SUBSTRINGS
public static final int GREATER_OR_EQUAL
public static final int LESS_OR_EQUAL
public static final int PRESENT
public static final int APPROX_MATCH
public static final int EXTENSIBLE_MATCH
public static final int INITIAL
public static final int ANY
public static final int FINAL
private RfcFilter.FilterTokenizer ft
private java.util.Stack filterStack
private boolean finalFound
Constructor Detail |
public RfcFilter(java.lang.String filter) throws LDAPException
public RfcFilter()
Method Detail |
private final ASN1Tagged parse(java.lang.String filterExpr) throws LDAPException
LDAPException
private final ASN1Tagged parseFilter() throws LDAPException
LDAPException
private final ASN1Tagged parseFilterComp() throws LDAPException
LDAPException
private final ASN1SetOf parseFilterList() throws LDAPException
LDAPException
static final int hex2int(char c)
private final byte[] unescapeString(java.lang.String string) throws LDAPException
string
- A part of the input filter string to be converted.
LDAPException
private void addObject(ASN1Object current) throws LDAPLocalException
Verifies that the specified ASN1Object can be added, then adds the object to the filter.
current
- Filter component to be added to the filter
LDAPLocalException
- Occurs when an invalid component is added, or
when the component is out of sequence.public void startSubstrings(java.lang.String attrName) throws LDAPLocalException
startSubstrings must be immediatly followed by at least one
addSubstring(int, byte[])
method and one endSubstrings()
method
LDAPLocalException
- Occurs when this component is created out of sequence.public void addSubstring(int type, byte[] value) throws LDAPLocalException
This method can be invoked only if startSubString was the last filter- building method called. A substring is not required to have an 'INITIAL' substring. However, when a filter contains an 'INITIAL' substring only one can be added, and it must be the first substring added. Any number of 'ANY' substrings can be added. A substring is not required to have a 'FINAL' substrings either. However, when a filter does contain a 'FINAL' substring only one can be added, and it must be the last substring added.
type
- Substring type: INITIAL | ANY | FINAL]value
- Value to use for matching
LDAPLocalException
- Occurs if this method is called out of
sequence or the type added is out of sequence.public void endSubstrings() throws LDAPLocalException
LDAPLocalException
- Occurs when this is called out of sequence,
or the substrings filter is empty.public void addAttributeValueAssertion(int rfcType, java.lang.String attrName, byte[] value) throws LDAPLocalException
rfcType
- Filter type: EQUALITY_MATCH | GREATER_OR_EQUAL
| LESS_OR_EQUAL | APPROX_MATCH ]attrName
- Name of the attribute to be assertedvalue
- Value of the attribute to be asserted
LDAPLocalException
- Occurs when the filter type is not a valid attribute assertion.public void addPresent(java.lang.String attrName) throws LDAPLocalException
attrName
- Name of the attribute to check for presence.
LDAPLocalException
- Occurs if addPresent is called out of sequence.public void addExtensibleMatch(java.lang.String matchingRule, java.lang.String attrName, byte[] value, boolean useDNMatching) throws LDAPLocalException
matchingRule
- OID or name of the matching rule to use for comparisonattrName
- Name of the attribute to match.value
- Value of the attribute to match against.useDNMatching
- Indicates whether DN matching should be used.
LDAPLocalException
- Occurs when addExtensibleMatch is called out of sequence.public void startNestedFilter(int rfcType) throws LDAPLocalException
Note that a Not nested filter can only have one filter, where AND and OR do not
rfcType
- Filter type:
[AND | OR | NOT]
LDAPLocalException
public void endNestedFilter(int rfcType) throws LDAPLocalException
rfcType
- Type of filter to complete.
LDAPLocalException
- Occurs when the specified
type differs from the current filter component.public java.util.Iterator getFilterIterator()
The first object returned by an iterator is an integer indicating the type of filter components. Subseqence values are returned. If a component is of type 'AND' or 'OR' or 'NOT' then the value returned is another iterator. This iterator is used by toString.
public java.lang.String filterToString()
private static void stringFilter(java.util.Iterator itr, java.lang.StringBuffer filter)
itr
- Iterator of filter componentsfilter
- Buffer to place a string representation of the filtergetFilterIterator()
private static java.lang.String byteString(byte[] value)
|
All LDAP Classes Internal LDAP Classes |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |