public final class FilterParser
extends java.lang.Object
| Modifier | Constructor and Description |
|---|---|
private |
FilterParser() |
| Modifier and Type | Method and Description |
|---|---|
static ExprNode |
parse(byte[] filter) |
static ExprNode |
parse(SchemaManager schemaManager,
byte[] filter) |
private static ExprNode |
parse(SchemaManager schemaManager,
byte[] filter,
boolean relaxed) |
static ExprNode |
parse(SchemaManager schemaManager,
java.lang.String filter) |
static ExprNode |
parse(SchemaManager schemaManager,
java.lang.String filter,
Position pos) |
static ExprNode |
parse(java.lang.String filter)
Parses a search filter from it's string representation to an expression node object.
|
static ExprNode |
parse(java.lang.String filter,
boolean relaxed)
Parses a search filter from it's string representation to an expression node object.
|
private static Value<?> |
parseAssertionValue(SchemaManager schemaManager,
byte[] filter,
Position pos)
An assertion value :
assertionvalue = valueencoding
valueencoding = 0*(normal / escaped)
normal = UTF1SUBSET / UTFMB
escaped = '\' HEX HEX
HEX = '0'-'9' / 'A'-'F' / 'a'-'f'
UTF1SUBSET = %x01-27 / %x2B-5B / %x5D-7F (Everything but '\0', '*', '(', ')' and '\')
UTFMB = UTF2 / UTF3 / UTF4
UTF0 = %x80-BF
UTF2 = %xC2-DF UTF0
UTF3 = %xE0 %xA0-BF UTF0 / %xE1-EC UTF0 UTF0 / %xED %x80-9F UTF0 / %xEE-EF UTF0 UTF0
UTF4 = %xF0 %x90-BF UTF0 UTF0 / %xF1-F3 UTF0 UTF0 UTF0 / %xF4 %x80-8F UTF0 UTF0
With the specific constraints (RFC 4515):
"The
|
private static Value<?> |
parseAssertionValue(SchemaManager schemaManager,
java.lang.String attribute,
byte[] filter,
Position pos)
An assertion value :
assertionvalue = valueencoding
valueencoding = 0*(normal / escaped)
normal = UTF1SUBSET / UTFMB
escaped = '\' HEX HEX
HEX = '0'-'9' / 'A'-'F' / 'a'-'f'
UTF1SUBSET = %x01-27 / %x2B-5B / %x5D-7F (Everything but '\0', '*', '(', ')' and '\')
UTFMB = UTF2 / UTF3 / UTF4
UTF0 = %x80-BF
UTF2 = %xC2-DF UTF0
UTF3 = %xE0 %xA0-BF UTF0 / %xE1-EC UTF0 UTF0 / %xED %x80-9F UTF0 / %xEE-EF UTF0 UTF0
UTF4 = %xF0 %x90-BF UTF0 UTF0 / %xF1-F3 UTF0 UTF0 UTF0 / %xF4 %x80-8F UTF0 UTF0
With the specific constraints (RFC 4515):
"The
|
private static ExprNode |
parseBranchNode(SchemaManager schemaManager,
ExprNode node,
byte[] filter,
Position pos,
boolean relaxed)
Parse AND, OR and NOT nodes :
and = '&' filterlist
or = '|' filterlist
not = '!' filter
filterlist = 1*filter
|
private static ExprNode |
parseExtensible(SchemaManager schemaManager,
java.lang.String attribute,
byte[] filter,
Position pos,
boolean relaxed)
Parse an extensible
extensible = ( attr [":dn"] [':' oid] ":=" assertionvalue )
/ ( [":dn"] ':' oid ":=" assertionvalue )
matchingrule = ":" oid
|
private static ExprNode |
parseFilterComp(SchemaManager schemaManager,
byte[] filter,
Position pos,
boolean relaxed)
filtercomp = and / or / not / item
and = '&' filterlist
or = '|' filterlist
not = '!' filter
item = simple / present / substring / extensible
simple = attr filtertype assertionvalue
present = attr EQUALS ASTERISK
substring = attr EQUALS [initial] any [final]
extensible = ( attr [dnattrs]
[matchingrule] COLON EQUALS assertionvalue )
/ ( [dnattrs]
matchingrule COLON EQUALS assertionvalue )
|
private static ExprNode |
parseFilterInternal(SchemaManager schemaManager,
byte[] filter,
Position pos,
boolean relaxed)
Pasre the grammar rule :
filter ::= '(' filterComp ')'
|
private static ExprNode |
parseItem(SchemaManager schemaManager,
byte[] filter,
Position pos,
byte b,
boolean relaxed)
Parse the following grammar :
item = simple / present / substring / extensible
simple = attr filtertype assertionvalue
filtertype = '=' / '~=' / '>=' / '<='
present = attr '=' '*'
substring = attr '=' [initial] any [final]
extensible = ( attr [":dn"] [':' oid] ":=" assertionvalue )
/ ( [":dn"] ':' oid ":=" assertionvalue )
matchingrule = ":" oid
An item starts with an attribute or a colon.
|
private static ExprNode |
parsePresenceEqOrSubstring(SchemaManager schemaManager,
java.lang.String attribute,
byte[] filter,
Position pos)
Here is the grammar to parse :
simple ::= '=' assertionValue
present ::= '=' '*'
substring ::= '=' [initial] any [final]
initial ::= assertionValue
any ::= '*' ( assertionValue '*')*
As we can see, there is an ambiguity in the grammar : attr=* can be
seen as a present or as a substring.
|
private static ExprNode |
parseSubstring(SchemaManager schemaManager,
java.lang.String attribute,
Value<?> initial,
byte[] filter,
Position pos)
Parse a substring
|
private static ExprNode parseExtensible(SchemaManager schemaManager, java.lang.String attribute, byte[] filter, Position pos, boolean relaxed) throws LdapException, java.text.ParseException
LdapExceptionjava.text.ParseExceptionprivate static Value<?> parseAssertionValue(SchemaManager schemaManager, java.lang.String attribute, byte[] filter, Position pos) throws java.text.ParseException
LdapInvalidAttributeValueExceptionjava.text.ParseExceptionprivate static Value<?> parseAssertionValue(SchemaManager schemaManager, byte[] filter, Position pos) throws java.text.ParseException
java.text.ParseExceptionprivate static ExprNode parseSubstring(SchemaManager schemaManager, java.lang.String attribute, Value<?> initial, byte[] filter, Position pos) throws java.text.ParseException, LdapException
java.text.ParseExceptionLdapExceptionprivate static ExprNode parsePresenceEqOrSubstring(SchemaManager schemaManager, java.lang.String attribute, byte[] filter, Position pos) throws java.text.ParseException, LdapException
attributeType - filter - pos - java.text.ParseExceptionLdapExceptionprivate static ExprNode parseItem(SchemaManager schemaManager, byte[] filter, Position pos, byte b, boolean relaxed) throws java.text.ParseException, LdapException
java.text.ParseExceptionLdapExceptionprivate static ExprNode parseBranchNode(SchemaManager schemaManager, ExprNode node, byte[] filter, Position pos, boolean relaxed) throws java.text.ParseException, LdapException
java.text.ParseExceptionLdapExceptionprivate static ExprNode parseFilterComp(SchemaManager schemaManager, byte[] filter, Position pos, boolean relaxed) throws java.text.ParseException, LdapException
java.text.ParseExceptionLdapExceptionprivate static ExprNode parseFilterInternal(SchemaManager schemaManager, byte[] filter, Position pos, boolean relaxed) throws java.text.ParseException, LdapException
java.text.ParseExceptionLdapExceptionpublic static ExprNode parse(java.lang.String filter) throws java.text.ParseException
filter - the search filter in it's string representationjava.text.ParseExceptionpublic static ExprNode parse(byte[] filter) throws java.text.ParseException
java.text.ParseExceptionparse(String)public static ExprNode parse(SchemaManager schemaManager, java.lang.String filter) throws java.text.ParseException
java.text.ParseExceptionparse(String)public static ExprNode parse(SchemaManager schemaManager, byte[] filter) throws java.text.ParseException
java.text.ParseExceptionparse(String)private static ExprNode parse(SchemaManager schemaManager, byte[] filter, boolean relaxed) throws java.text.ParseException
java.text.ParseExceptionpublic static ExprNode parse(SchemaManager schemaManager, java.lang.String filter, Position pos) throws java.text.ParseException
java.text.ParseExceptionparse(String)public static ExprNode parse(java.lang.String filter, boolean relaxed) throws java.text.ParseException
relaxed mode the filter may violate RFC 4515, e.g. the underscore in attribute names is allowed.filter - the search filter in it's string representationrelaxed - true to parse the filter in relaxed modejava.text.ParseException