Class LDAPFilter
- All Implemented Interfaces:
Cloneable
Although this class provides methods to create and modify LDAP filters, in most cases, you do not need to use these methods. In most situations, these classes are used to access individual filters from filter configuration files.
For example, you might do the following:
- Connect to the LDAP server and accept a set of search criteria.
- Create an LDAP filter configuration file.
- Call the
LDAPFilterDescriptor
constructor to read the filter configuration file into memory. - Call the
getFilters
method to get a list of filters that match the search criteria. This list of filters is represented by anLDAPFilterList
object. - Iterate through the list of filters (each filter is represented
by an
LDAPFilter
object), and apply the filter to a search.
For an example of using an object of this class and for more information on the filter configuration file syntax, see the documentation for LDAPFilterDescriptor.
- Version:
- 1.0
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLDAPFilter
(String strMatchPattern, String strDelimiter, String strFilterTemplate, String strDescription, int nScope) Constructs anLDAPFilter
object.LDAPFilter
(String strMatchPattern, String strDelimiter, String strFilterTemplate, String strDescription, String strScope) Constructs anLDAPFilter
object. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Makes a copy of thisLDAPFilter
object.(package private) String
convertMatchPattern
(String strMatchPattern) The ldapfilter.conf specifies match patterns in a funny way.(package private) void
createFilterString
(String strValue, String strPrefix, String strSuffix) Create the filter string which can be used in LDAPConnection.search() and others given the parameter strValue.Return this filter's delimiter.Return this filter's description.Returns the filter string.Create a filter string given a string value.Create a filter string given a string value.Return this filter's filter template.Return this filter's line number.Return this filter's match pattern.getScope()
Return this filter's scope.void
setFilterAffixes
(String strPrefix, String strSuffix) (package private) void
setLine
(int nLine) Set the line number from which this filter was created.void
setupFilter
(String strValue) Sets up the filter string, given the stringstrValue
.void
setupFilter
(String strValue, String strPrefix, String strSuffix) Sets up the filter string, given the stringstrValue
.toString()
Print out a string representation of the LDAPFilter.
-
Field Details
-
DEFAULT_FILTER_LENGTH
private static final int DEFAULT_FILTER_LENGTH- See Also:
-
m_strFilter
-
m_strDescription
-
m_nScope
private int m_nScope -
m_bIsExact
private boolean m_bIsExact -
m_strMatchPattern
-
m_strDelimiter
-
m_strFilterTemplate
-
m_nLine
private int m_nLine -
m_strSuffix
-
m_strPrefix
-
-
Constructor Details
-
LDAPFilter
public LDAPFilter(String strMatchPattern, String strDelimiter, String strFilterTemplate, String strDescription, int nScope) throws IllegalArgumentException Constructs anLDAPFilter
object. In most situations, you do not need to construct an LDAPFilter object. Instead, you work withLDAPFilter
objects created from theLDAPFilter
objects andLDAPFilterDescriptor
objects.This constructor uses the integer value for a search scope in addition to other information to construct an
LDAPFilter
object. The integer value of the search scope can be one of the following:LDAPConnection.SCOPE_BASE
LDAPConnection.SCOPE_ONE
LDAPConnection.SCOPE_SUB
illegalArgumentException
.- Throws:
IllegalArgumentException
-
LDAPFilter
public LDAPFilter(String strMatchPattern, String strDelimiter, String strFilterTemplate, String strDescription, String strScope) throws IllegalArgumentException Constructs anLDAPFilter
object. In most situations, you do not need to construct an LDAPFilter object. Instead, you work withLDAPFilter
objects created from theLDAPFilter
objects andLDAPFilterDescriptor
objects.This constructor uses the string value for a search scope in addition to other information to construct an
LDAPFilter
object. The string value of the search scope can be one of the following:"base"
"onelevel"
"subtree"
illegalArgumentException
.- Throws:
IllegalArgumentException
-
-
Method Details
-
toString
Print out a string representation of the LDAPFilter. Basically, it prints out the appropriate fields.For example, suppose you called the method in this way:
System.out.println(filter.toString());
The resulting output might look like this:matchPtn: "@" delim: " " filttmpl: "(mail=%v*)" descript: "start of email address" scope: "LDAPConnection.SCOPE_SUB" line: "32" FILTER: "(mail=babs@aceindustry.com*)"
-
setupFilter
Sets up the filter string, given the stringstrValue
. If thestrPrefix
andstrSuffix
arguments are non-null strings, they are prepended and appended to the filter string (respectively).This string, which is available through the
getFilter()
method, should be suitable for use as search criteria when calling theLDAPConnection.search()
method.Notes:
- This method does not maintain the affixes
set with the
LDAPFilterDescriptor.setFilterAffixes
method, so you need to explicitly define any filter prefixes or suffixes here. - This method only uses the
strPrefix and strSuffix for this invocation of setupFilter. It
does not redefine strPrefix and strSuffix for later
invocations.
- This method does not maintain the affixes
set with the
-
setupFilter
Sets up the filter string, given the stringstrValue
. This string, which is available through thegetFilter()
method, should be suitable for use as search criteria when calling theLDAPConnection.search()
method.Note: If you want to specify a filter prefix and suffix, you need to explicitly define them by calling the
setFilterAffixes()
method. -
createFilterString
Create the filter string which can be used in LDAPConnection.search() and others given the parameter strValue. If strPrefix and strSuffix are non-null strings, prepend strPrefix and append strSuffix. -
clone
Makes a copy of thisLDAPFilter
object. -
setLine
void setLine(int nLine) Set the line number from which this filter was created. This is used only when the LDAPFilter is created when an LDAPFilterDescriptor is initialized from a file/URL/buffer. -
convertMatchPattern
The ldapfilter.conf specifies match patterns in a funny way. A "." means "any character" except when used inside of a set of square brackets "[]", in which case, the "." means just a plain old period (not a * special character). This function converts periods inside of a set of square brackets into a "\." as per normal regexp code. -
getFilter
Returns the filter string. This method will return null if the filter string has not been calculated by thesetupFilter()
,getFilter (strValue)
, orgetFilter (strValue, strPrefix, strSuffix )
methods. -
getFilter
Create a filter string given a string value. This method uses any Prefixes or Suffixes that have been set by the setFilterAffixes() method.This is the same as doing:
setupFilter ( strValue ); getFilter();
-
getFilter
Create a filter string given a string value. If strPrefix and/or strSuffix is non-null, these values are prepended and appended to the returned string.This is the same as doing:
setupFilter ( strValue, strPrefix, strSuffix ); getFilter();
-
getMatchPattern
Return this filter's match pattern. The match pattern is found as the first token in a filter configuration line in the ldapfilter.conf file. -
getDelimiter
Return this filter's delimiter. The delmimeter is found as the second token in a filter configuration line in the ldapfilter.conf file. -
getFilterTemplate
Return this filter's filter template. The filter template is found as the third token in a filter configuration line in the ldapfilter.conf file. -
getDescription
Return this filter's description. The description is found as the fourth token in a filter configuration line in the ldapfilter.conf file. -
getScope
Return this filter's scope. The scope is found as the fifth (optional) token in a filter configuration line in the ldapfilter.conf file. -
getLineNumber
Return this filter's line number. The line number is mostly a debugging variable to let the developer know which filter from the filter configuration file is being used. -
setFilterAffixes
-