Class QueryResult<T>
java.lang.Object
org.apache.commons.configuration2.tree.QueryResult<T>
- Type Parameters:
T
- the type of the result nodes
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.
- Since:
- 2.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> QueryResult<T>
createAttributeResult
(T parentNode, String attrName) Creates aQueryResult
instance representing an attribute result.static <T> QueryResult<T>
createNodeResult
(T resultNode) Creates aQueryResult
instance representing the specified result node.boolean
Compares this object with another one.Gets the name of the attribute.getAttributeValue
(NodeHandler<T> handler) Gets the attribute value if this is an attribute result.getNode()
Gets the node referenced by this object.int
hashCode()
boolean
Returns a flag whether this is a result of type attribute.toString()
Returns a string representation of this object.
-
Method Details
-
createAttributeResult
Creates aQueryResult
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.)- Type Parameters:
T
- the type of the parent node- Parameters:
parentNode
- the node which owns the attributeattrName
- the attribute name- Returns:
- the newly created instance
-
createNodeResult
Creates aQueryResult
instance representing the specified result node.- Type Parameters:
T
- the type of the result node- Parameters:
resultNode
- the result node- Returns:
- the newly created instance
-
equals
Compares this object with another one. Two instances ofQueryResult
are considered equal if they are of the same result type and have the same properties. -
getAttributeName
Gets the name of the attribute. This method is defined only for results of type attribute.- Returns:
- the attribute name
-
getAttributeValue
Gets the attribute value if this is an attribute result. If this is not an attribute result, an exception is thrown.- Parameters:
handler
- theNodeHandler
- Returns:
- the attribute value
- Throws:
IllegalStateException
- if this is not an attribute result
-
getNode
Gets the node referenced by this object. Depending on the result type, this is either the result node or the parent node of the represented attribute.- Returns:
- the referenced node
-
hashCode
-
isAttributeResult
Returns a flag whether this is a result of type attribute. If result is true, the attribute name and value can be queried. Otherwise, only the result node is available.- Returns:
- true for an attribute result, false otherwise
-
toString
Returns a string representation of this object. Depending on the result type either the result node or the parent node and the attribute name are contained in this string.
-