T
- the type of the result nodespublic final class QueryResult<T> extends Object
A data class representing a single query result produced by an
ExpressionEngine
.
When passing a key to the query()
method of ExpressionEngine
the result can be a set of nodes or attributes - depending on the key. This
class can represent both types of results. The aim is to give a user of
ExpressionEngine
all information needed for evaluating the results
returned.
Implementation note: Instances are immutable. They are created using the static factory methods.
Modifier and Type | Method and Description |
---|---|
static <T> QueryResult<T> |
createAttributeResult(T parentNode,
String attrName)
Creates a
QueryResult instance representing an attribute result. |
static <T> QueryResult<T> |
createNodeResult(T resultNode)
Creates a
QueryResult instance representing the specified result
node. |
boolean |
equals(Object obj)
Compares this object with another one.
|
String |
getAttributeName()
Returns the name of the attribute.
|
Object |
getAttributeValue(NodeHandler<T> handler)
Returns the attribute value if this is an attribute result.
|
T |
getNode()
Returns the node referenced by this object.
|
int |
hashCode() |
boolean |
isAttributeResult()
Returns a flag whether this is a result of type attribute.
|
String |
toString()
Returns a string representation of this object.
|
public static <T> QueryResult<T> createNodeResult(T resultNode)
QueryResult
instance representing the specified result
node.T
- the type of the result noderesultNode
- the result nodepublic static <T> QueryResult<T> createAttributeResult(T parentNode, String attrName)
QueryResult
instance representing an attribute result.
An attribute result consists of the node the attribute belongs to and the
attribute name. (The value can be obtained based on this information.)T
- the type of the parent nodeparentNode
- the node which owns the attributeattrName
- the attribute namepublic T getNode()
public String getAttributeName()
public boolean isAttributeResult()
public Object getAttributeValue(NodeHandler<T> handler)
handler
- the NodeHandler
IllegalStateException
- if this is not an attribute resultpublic boolean equals(Object obj)
QueryResult
are considered equal if they are of the same result
type and have the same properties.Copyright © 2001–2020 The Apache Software Foundation. All rights reserved.