|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.day.cq.search.Predicate
public class Predicate
A Predicate is a single constraint for a Query. It is a
pure data model object, consisting of a parameter map based on key-value
string pairs.
Each Predicate has a type (getType()) that is used to find
the right PredicateEvaluator that will handle this predicate and eg.
translate it into an XPath statement.
Using the composite pattern, the subclass PredicateGroup allows to
group multiple predicates into one. This allows the query to actually consist
of a predicate tree and reflects more complex queries that include sub-terms.
The methods getName(), getPath() and #getParent()
return that hierarchy information. The name/path is important, because facets
will be returned in a map with the appropriate predicate path as key (see
SearchResult.getFacets()).
The parameters are set via the set(String, String) method and
retrieved via get(String), get(String, String) or
getParameters(). Predicates are also Cloneable, so that it
is easy to copy them.
| Field Summary | |
|---|---|
static String |
ORDER_BY
|
static String |
PARAM_EXCERPT
|
static String |
PARAM_LIMIT
|
static String |
PARAM_OFFSET
|
static String |
PARAM_SORT
|
static String |
SORT_ASCENDING
|
static String |
SORT_DESCENDING
|
| Constructor Summary | |
|---|---|
Predicate(String type)
Creates a Predicate of the given type. |
|
Predicate(String name,
String type)
Creates a Predicate with the given name and type. |
|
| Method Summary | |
|---|---|
Predicate |
clone()
Clones this predicate so that the returned clone can be used completely independently from this original. |
String |
get(String parameterName)
Returns the value for the given parameter name or null if
that parameter is not set. |
String |
get(String parameterName,
String defaultValue)
Returns the value for the given parameter name or the given default value if that parameter is not set. |
String |
getName()
Returns the name of this predicate. |
Map<String,String> |
getParameters()
Returns an unmodifiable map of all parameters and their values. |
String |
getPath()
Returns the path in a predicate tree of PredicateGroups to this predicate, eg. |
String |
getType()
Returns the predicate type name for finding the right PredicateEvaluator. |
boolean |
hasNonEmptyValue(String parameterName)
Returns true when there is a parameter present with the
given name and if the string value is not empty. |
boolean |
ignored()
This is used only during evaluation and indicates that this predicate is marked as "invisible" for any PredicateEvaluator that will
encounter it. |
Predicate |
set(String parameterName,
String value)
Sets the parameter 'parameterName' to the value given by 'value'. |
void |
setIgnored(boolean ignore)
This is used only during evaluation and marks this predicate as "invisible" for any PredicateEvaluator that will encounter it. |
void |
setName(String name)
Sets the name of this predicate. |
protected void |
setParent(PredicateGroup parent)
Used by PredicateGroup to store the hierarchy information when
adding a predicate (through eg. |
String |
toString()
Overwrites the standard Object.toString() implementation and
returns a debug-friendly string representation of the predicate. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String PARAM_OFFSET
public static final String PARAM_LIMIT
public static final String PARAM_EXCERPT
public static final String ORDER_BY
public static final String PARAM_SORT
public static final String SORT_ASCENDING
public static final String SORT_DESCENDING
| Constructor Detail |
|---|
public Predicate(String type)
Predicate of the given type. Note that the type cannot
be changed later. Initially the name will be null, no
parameters will be set and no parent will be present.
type - predicate type name for finding the right
PredicateEvaluator
public Predicate(String name,
String type)
Predicate with the given name and type. Note that the
type cannot be changed later. Initially no parameters will be set and no
parent will be present.
name - identifying name for this predicatetype - predicate type name for finding the right
PredicateEvaluator| Method Detail |
|---|
public String getType()
PredicateEvaluator.
public void setName(String name)
facet map, in logging or other debug
output.
When a predicate is included in PredicateGroup, the names of the
parent predicates will make up the path, eg.
parent.child.grandchild. The name must not be changed after
the predicate is passed to a Query.
name - identifying name for this predicategetName()public String getName()
facet map, in logging or other debug
output.
When a predicate is included in PredicateGroup, the names of the
parent predicates will make up the path, eg.
parent.child.grandchild. The name must not be changed after
the predicate is passed to a Query.
null if
no name was set)setName(String)public String getPath()
PredicateGroups to this predicate, eg.
parent.child.grandchild. This can be null if no
name was set. The path is used for identifying predicates in the
facet map, in logging or other debug
output.
public String get(String parameterName)
null if
that parameter is not set. Parameters always have String values.
public String get(String parameterName,
String defaultValue)
String
values.
public Predicate set(String parameterName,
String value)
String values.
group.add(new Predicate("mytype", "type").set("type", "nt:file"));public boolean hasNonEmptyValue(String parameterName)
true when there is a parameter present with the
given name and if the string value is not empty. Parameters always have
String values.
public Map<String,String> getParameters()
public void setIgnored(boolean ignore)
PredicateEvaluator that will encounter it.
Don't use that method when creating a query.
ignore - true if this predicate should be ignored by
evaluators (default is false)public boolean ignored()
PredicateEvaluator that will
encounter it. This method has no use for clients of the querybuilder API.
true if this predicate should be ignored by
evaluators (default is false)public Predicate clone()
clone in class Objectprotected void setParent(PredicateGroup parent)
PredicateGroup to store the hierarchy information when
adding a predicate (through eg. PredicateGroup.add(Predicate)).
Normally there is no reason to call this method, hence it is
protected.
parent - parent predicate group to setpublic String toString()
Object.toString() implementation and
returns a debug-friendly string representation of the predicate.
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||