Package org.ldaptive.filter
Class DefaultFilterFunction
- java.lang.Object
-
- org.ldaptive.filter.AbstractFilterFunction
-
- org.ldaptive.filter.DefaultFilterFunction
-
- All Implemented Interfaces:
FilterFunction
public class DefaultFilterFunction extends AbstractFilterFunction
Parses an LDAP search filter string.
-
-
Field Summary
Fields Modifier and Type Field Description private String
attributeDescriptionChars
Allowed attribute description characters.protected static String
DEFAULT_ATTRIBUTE_DESCRIPTION_CHARS
Lower and upper case ASCII alphabetical, digits, semi-colon, dot, dash.
-
Constructor Summary
Constructors Constructor Description DefaultFilterFunction()
Default constructor.DefaultFilterFunction(String validChars)
Creates a new default filter function.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private ExtensibleFilter
parseExtensible(String attribute, CharBuffer cb)
Parses the supplied buffer and creates an extensible filter.protected Filter
parseFilterComp(String filter)
Inspects the supplied filter string and creates the type of filter it represents.private Filter
parseSubstringOrEquality(String attribute, CharBuffer cb)
Parses the supplied buffer and returns either a substring or equality filter.private CharBuffer
readAttribute(CharBuffer cb)
Returns a new buffer containing an attribute description.private Map<String,List<CharBuffer>>
readSubstrings(CharBuffer cb)
Reads the supplied buffer and builds a map of the substring data it contains.private CharBuffer
sliceAtMatch(CharBuffer cb, char match)
Returns a new char buffer whose position is 0 and whose limit is before the match character.-
Methods inherited from class org.ldaptive.filter.AbstractFilterFunction
parse
-
-
-
-
Field Detail
-
DEFAULT_ATTRIBUTE_DESCRIPTION_CHARS
protected static final String DEFAULT_ATTRIBUTE_DESCRIPTION_CHARS
Lower and upper case ASCII alphabetical, digits, semi-colon, dot, dash.- See Also:
- Constant Field Values
-
attributeDescriptionChars
private final String attributeDescriptionChars
Allowed attribute description characters.
-
-
Constructor Detail
-
DefaultFilterFunction
public DefaultFilterFunction()
Default constructor.
-
DefaultFilterFunction
public DefaultFilterFunction(String validChars)
Creates a new default filter function.- Parameters:
validChars
- characters that are valid for an attribute description
-
-
Method Detail
-
parseFilterComp
protected Filter parseFilterComp(String filter) throws FilterParseException
Description copied from class:AbstractFilterFunction
Inspects the supplied filter string and creates the type of filter it represents.- Specified by:
parseFilterComp
in classAbstractFilterFunction
- Parameters:
filter
- to inspect- Returns:
- search filter
- Throws:
FilterParseException
- if filter is invalid
-
readAttribute
private CharBuffer readAttribute(CharBuffer cb) throws FilterParseException
Returns a new buffer containing an attribute description. The supplied buffer will have its position set to the next position after the attribute.- Parameters:
cb
- to read from- Returns:
- new char buffer
- Throws:
FilterParseException
- if the char buffer is empty
-
parseSubstringOrEquality
private Filter parseSubstringOrEquality(String attribute, CharBuffer cb) throws FilterParseException
Parses the supplied buffer and returns either a substring or equality filter.- Parameters:
attribute
- attribute descriptioncb
- containing the assertion- Returns:
- either EqualityFilter or SubstringFilter
- Throws:
FilterParseException
- if neither substring or equality syntax can be parsed
-
readSubstrings
private Map<String,List<CharBuffer>> readSubstrings(CharBuffer cb) throws FilterParseException
Reads the supplied buffer and builds a map of the substring data it contains. The following keys are made available in the map:- INITIAL: singleton list containing the initial substring or null
- ANY: list of any substring components or null
- FINAL: singleton list containing the final substring or null
- EQUALITY: singleton list containing the equality expression or null
- Parameters:
cb
- to read- Returns:
- map of character buffers
- Throws:
FilterParseException
- if an invalid character is encountered
-
parseExtensible
private ExtensibleFilter parseExtensible(String attribute, CharBuffer cb) throws FilterParseException
Parses the supplied buffer and creates an extensible filter.- Parameters:
attribute
- attribute description or nullcb
- to parse- Returns:
- extensible filter
- Throws:
FilterParseException
- if the buffer does not contain an extensible expression
-
sliceAtMatch
private CharBuffer sliceAtMatch(CharBuffer cb, char match)
Returns a new char buffer whose position is 0 and whose limit is before the match character. The supplied buffer has its position incremented one position past the match character.- Parameters:
cb
- to searchmatch
- to search for- Returns:
- new char buffer or null if there is no match
-
-