org.azzyzt.jee.runtime.dto.query
Class QuerySpec

java.lang.Object
  extended by org.azzyzt.jee.runtime.dto.query.QuerySpec
All Implemented Interfaces:
java.io.Serializable, Node

public class QuerySpec
extends java.lang.Object
implements Node, java.io.Serializable

For each entity class Azzyzt JEE Tools create two type-specific service beans with, among others, a list operation. List takes a QuerySpec as parameter and delivers a list of DTOs, according to the result of the query.

A query specification contains an expression that selects what objects are in the result, and a list of OrderByClause that determines the order ther result list. Both are optional. The result of the empty query specification is a list of all objects in a database table in unspecified order.

Query specifications can either be constructed as a tree of objects or as XML text. The latter is the only way to submit a query via the generated REST interface.

QuerySpec implements Node, because this way the parser can directly use the QuerySpec as root of the expression tree.

See Also:
Expression, Node, AttributedTags2QuerySpec, OrderByClause, Serialized Form

Constructor Summary
QuerySpec()
           
QuerySpec(Expression e, java.util.List<OrderByClause> orderByList)
          Programmatically construct a query specification from an expression and a list of order-by clauses
 
Method Summary
 void add(Expression expression)
          Adds an expression to the current Node.
 void addOrderBy(OrderByClause orderBy)
           
static QuerySpec fromXML(java.lang.String querySpecXml)
          Factory method that constructs a query specification from an XML representation.
 Expression getExpression()
           
 java.util.List<OrderByClause> getOrderByList()
           
 Expression getReplaceableBy()
           
 boolean isValid()
           
 void setExpression(Expression expression)
           
 void setOrderByList(java.util.List<OrderByClause> orderByList)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QuerySpec

public QuerySpec()

QuerySpec

public QuerySpec(Expression e,
                 java.util.List<OrderByClause> orderByList)
Programmatically construct a query specification from an expression and a list of order-by clauses

Parameters:
e - an expression
orderByList - a list of order-by clauses
Method Detail

fromXML

public static QuerySpec fromXML(java.lang.String querySpecXml)
                         throws QuerySyntaxException
Factory method that constructs a query specification from an XML representation. This is mandatory for REST clients, but may also be useful in cases where we want to read queries from files, etc.

Parameters:
querySpecXml - an XML representation as it is used by REST clients
Returns:
the query specification as object tree
Throws:
QuerySyntaxException

getExpression

public Expression getExpression()

setExpression

public void setExpression(Expression expression)

add

public void add(Expression expression)
         throws QuerySyntaxException
Description copied from interface: Node
Adds an expression to the current Node. Invalid XML can cause a QuerySyntaxExpression.

Specified by:
add in interface Node
Parameters:
expression - the expression to be added
Throws:
QuerySyntaxException

getOrderByList

public java.util.List<OrderByClause> getOrderByList()

setOrderByList

public void setOrderByList(java.util.List<OrderByClause> orderByList)

addOrderBy

public void addOrderBy(OrderByClause orderBy)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getReplaceableBy

public Expression getReplaceableBy()
Specified by:
getReplaceableBy in interface Node
Returns:
a simpler and equivalent expression or null.

isValid

public boolean isValid()
Specified by:
isValid in interface Node
Returns:
true if the expression is valid