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 int
hash code seed.filter parameters.private String
filter. -
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.Builder
builder()
Creates a builder for this class.protected static String
Hex encodes the supplied object if it is of type byte[], otherwise the string format of the object is escaped.static String
encodeValue
(byte[] value) Hex encodes the supplied byte array for use in a search filter.static String
encodeValue
(String value) Encodes the supplied attribute value for use in a search filter.boolean
format()
Returns this filter with it's parameters encoded and replaced.Gets the filter.Gets the filter parameters.int
hashCode()
void
Sets the filter.void
setParameter
(int position, Object value) Sets a positional filter parameter.void
setParameter
(String name, Object value) Sets a named filter parameter.void
setParameters
(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 it's 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
-
equals
-
hashCode
public int hashCode() -
toString
-
builder
Creates a builder for this class.- Returns:
- new builder
-