Package org.ldaptive
Class FilterTemplate
- java.lang.Object
-
- org.ldaptive.FilterTemplate
-
public class FilterTemplate extends java.lang.ObjectClass 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.- Author:
- Middleware Services
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFilterTemplate.Builder
-
Constructor Summary
Constructors Constructor Description FilterTemplate()Default constructor.FilterTemplate(java.lang.String filter)Creates a new search filter with the supplied filter.FilterTemplate(java.lang.String filter, java.lang.Object[] params)Creates a new search filter with the supplied filter and parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FilterTemplate.Builderbuilder()Creates a builder for this class.protected static java.lang.Stringencode(java.lang.Object obj)Hex encodes the supplied object if it is of type byte[], otherwise the string format of the object is escaped.static java.lang.StringencodeValue(byte[] value)Hex encodes the supplied byte array for use in a search filter.static java.lang.StringencodeValue(java.lang.String value)Encodes the supplied attribute value for use in a search filter.booleanequals(java.lang.Object o)java.lang.Stringformat()Returns this filter with it's parameters encoded and replaced.java.lang.StringgetFilter()Gets the filter.java.util.Map<java.lang.String,java.lang.Object>getParameters()Gets the filter parameters.inthashCode()voidsetFilter(java.lang.String filter)Sets the filter.voidsetParameter(int position, java.lang.Object value)Sets a positional filter parameter.voidsetParameter(java.lang.String name, java.lang.Object value)Sets a named filter parameter.voidsetParameters(java.lang.Object[] values)Sets positional filter parameters.java.lang.StringtoString()
-
-
-
Constructor Detail
-
FilterTemplate
public FilterTemplate()
Default constructor.
-
FilterTemplate
public FilterTemplate(java.lang.String filter)
Creates a new search filter with the supplied filter.- Parameters:
filter- to set
-
FilterTemplate
public FilterTemplate(java.lang.String filter, java.lang.Object[] params)Creates a new search filter with the supplied filter and parameters.- Parameters:
filter- to setparams- to set
-
-
Method Detail
-
getFilter
public java.lang.String getFilter()
Gets the filter.- Returns:
- filter
-
setFilter
public void setFilter(java.lang.String filter)
Sets the filter.- Parameters:
filter- to set
-
getParameters
public java.util.Map<java.lang.String,java.lang.Object> getParameters()
Gets the filter parameters.- Returns:
- unmodifiable map of filter parameters
-
setParameter
public void setParameter(int position, java.lang.Object value)Sets a positional filter parameter.- Parameters:
position- of the parameter in the filtervalue- to set
-
setParameter
public void setParameter(java.lang.String name, java.lang.Object value)Sets a named filter parameter.- Parameters:
name- of the parameter in the filtervalue- to set
-
setParameters
public void setParameters(java.lang.Object[] values)
Sets positional filter parameters.- Parameters:
values- to set
-
format
public java.lang.String format()
Returns this filter with it's parameters encoded and replaced. Seeencode(Object).- Returns:
- formatted and encoded filter
-
encodeValue
public static java.lang.String encodeValue(byte[] value)
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
public static java.lang.String encodeValue(java.lang.String value)
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
protected static java.lang.String encode(java.lang.Object obj)
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
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
builder
public static FilterTemplate.Builder builder()
Creates a builder for this class.- Returns:
- new builder
-
-