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 class
SearchTemplates.DefaultTermParser
Adds each term as a filter parameter using the name 'termX' where X is the index of the term.static class
SearchTemplates.InitialTermParser
Adds the first letter of each term as a filter parameter using the name 'initialX' where X is the index of the term.static interface
SearchTemplates.TermParser
Converts query terms into search filter parameters.
-
Field Summary
Fields Modifier and Type Field Description private String[]
filterTemplates
Search filter templates.private String
searchRestrictions
Appended to every search filter to restrict results.private SearchTemplates.TermParser[]
termParsers
Term 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 String
concatFilters(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.String
getSearchRestrictions()
Returns the filter to use for search restrictions.SearchTemplates.TermParser[]
getTermParsers()
Returns the term parsers used for creating filter parameters.void
setSearchRestrictions(String restrictions)
Sets the filter to use for search restrictions.void
setTermParsers(SearchTemplates.TermParser... parsers)
Sets the term parsers used for creating filter parameters.String
toString()
-
-
-
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
-
-