Package org.ldaptive
Class FilterTemplate
java.lang.Object
org.ldaptive.FilterTemplate
Class for producing an LDAP search filter from a filter template. Templates can use either index based parameters or
name based parameters for substitutions. Parameters are encoded according to RFC 4515.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final inthash code seed.filter parameters.private Stringfilter. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.FilterTemplate(String filter) Creates a new search filter with the supplied filter.FilterTemplate(String filter, Object[] params) Creates a new search filter with the supplied filter and parameters. -
Method Summary
Modifier and TypeMethodDescriptionstatic FilterTemplate.Builderbuilder()Creates a builder for this class.static FilterTemplatecopy(FilterTemplate template) Returns a new filter template with the same properties as the supplied template.protected static StringHex encodes the supplied object if it is of type byte[], otherwise the string format of the object is escaped.static StringencodeValue(byte[] value) Hex encodes the supplied byte array for use in a search filter.static StringencodeValue(String value) Encodes the supplied attribute value for use in a search filter.booleanprivate static StringReplaces any brackets in the supplied string with their hex encoding.format()Returns this filter with its parameters encoded and replaced.Gets the filter.Gets the filter parameters.inthashCode()voidSets the filter.voidsetParameter(int position, Object value) Sets a positional filter parameter.voidsetParameter(String name, Object value) Sets a named filter parameter.voidsetParameters(Object[] values) Sets positional filter parameters.toString()
-
Field Details
-
HASH_CODE_SEED
private static final int HASH_CODE_SEEDhash code seed.- See Also:
-
searchFilter
filter. -
parameters
filter parameters.
-
-
Constructor Details
-
FilterTemplate
public FilterTemplate()Default constructor. -
FilterTemplate
Creates a new search filter with the supplied filter.- Parameters:
filter- to set
-
FilterTemplate
Creates a new search filter with the supplied filter and parameters.- Parameters:
filter- to setparams- to set
-
-
Method Details
-
getFilter
Gets the filter.- Returns:
- filter
-
setFilter
Sets the filter.- Parameters:
filter- to set
-
getParameters
Gets the filter parameters.- Returns:
- unmodifiable map of filter parameters
-
setParameter
Sets a positional filter parameter.- Parameters:
position- of the parameter in the filtervalue- to set
-
setParameter
Sets a named filter parameter.- Parameters:
name- of the parameter in the filtervalue- to set
-
setParameters
Sets positional filter parameters.- Parameters:
values- to set
-
format
Returns this filter with its parameters encoded and replaced. Seeencode(Object).- Returns:
- formatted and encoded filter
-
encodeValue
Hex encodes the supplied byte array for use in a search filter.- Parameters:
value- to encode- Returns:
- encoded value or null if supplied value is null
-
encodeValue
Encodes the supplied attribute value for use in a search filter. SeeFilterUtils.escape(String).- Parameters:
value- to encode- Returns:
- encoded value or null if supplied value is null
-
encode
Hex encodes the supplied object if it is of type byte[], otherwise the string format of the object is escaped. SeeFilterUtils.escape(String).- Parameters:
obj- to encode- Returns:
- encoded object
-
escapeBrackets
Replaces any brackets in the supplied string with their hex encoding.- Parameters:
s- to escape- Returns:
- string with escaped brackets
-
equals
-
hashCode
public int hashCode() -
toString
-
copy
Returns a new filter template with the same properties as the supplied template.- Parameters:
template- to copy- Returns:
- copy of the supplied filter template
-
builder
Creates a builder for this class.- Returns:
- new builder
-