Package org.ldaptive.templates
Class SearchTemplates
- java.lang.Object
-
- org.ldaptive.templates.SearchTemplates
-
public class SearchTemplates extends Object
Contains a list of common search filter templates that can be formatted for any given query.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSearchTemplates.DefaultTermParserAdds each term as a filter parameter using the name 'termX' where X is the index of the term.static classSearchTemplates.InitialTermParserAdds the first letter of each term as a filter parameter using the name 'initialX' where X is the index of the term.static interfaceSearchTemplates.TermParserConverts query terms into search filter parameters.
-
Field Summary
Fields Modifier and Type Field Description private String[]filterTemplatesSearch filter templates.private StringsearchRestrictionsAppended to every search filter to restrict results.private SearchTemplates.TermParser[]termParsersTerm parsers for creating filter parameters.
-
Constructor Summary
Constructors Constructor Description SearchTemplates(String... templates)Creates a new search templates.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private StringconcatFilters(String... filters)Concatenates the supplied filters into a single filter will all arguments ANDED together.FilterTemplate[]format(Query query)Creates the filter templates using configured templates and the supplied query.StringgetSearchRestrictions()Returns the filter to use for search restrictions.SearchTemplates.TermParser[]getTermParsers()Returns the term parsers used for creating filter parameters.voidsetSearchRestrictions(String restrictions)Sets the filter to use for search restrictions.voidsetTermParsers(SearchTemplates.TermParser... parsers)Sets the term parsers used for creating filter parameters.StringtoString()
-
-
-
Field Detail
-
filterTemplates
private final String[] filterTemplates
Search filter templates.
-
searchRestrictions
private String searchRestrictions
Appended to every search filter to restrict results.
-
termParsers
private SearchTemplates.TermParser[] termParsers
Term parsers for creating filter parameters.
-
-
Constructor Detail
-
SearchTemplates
public SearchTemplates(String... templates)
Creates a new search templates.- Parameters:
templates- list of search filters
-
-
Method Detail
-
getSearchRestrictions
public String getSearchRestrictions()
Returns the filter to use for search restrictions.- Returns:
- search restrictions
-
setSearchRestrictions
public void setSearchRestrictions(String restrictions)
Sets the filter to use for search restrictions.- Parameters:
restrictions- search restrictions
-
getTermParsers
public SearchTemplates.TermParser[] getTermParsers()
Returns the term parsers used for creating filter parameters.- Returns:
- term parsers
-
setTermParsers
public void setTermParsers(SearchTemplates.TermParser... parsers)
Sets the term parsers used for creating filter parameters.- Parameters:
parsers- term parsers
-
format
public FilterTemplate[] format(Query query)
Creates the filter templates using configured templates and the supplied query.- Parameters:
query- to create search filter with- Returns:
- filter templates
-
concatFilters
private String concatFilters(String... filters)
Concatenates the supplied filters into a single filter will all arguments ANDED together. Null array values are ignored.- Parameters:
filters- to concatenate- Returns:
- search filter
-
-