This implies the creation of query statements from the criteria which can be applied to data sinks; such as databases (SQL like statements). In turn, this also implies parsing of criteria trees from a query statement (provided as logical operators in your code). Such parsable query statement can look as follows:
( ( ( City = 'Berlin' ) OR ( City = 'Munich' ) ) AND ( Surname = 'Miller' ) )A dedicated CriteriaFactory implementation is required (and already provided) for parsing the above query statement.
The refcodes-criteria framework consists of the following components:
A Criteria represents an atomic query or atomic logical operator with which complex queries can be constructed in an object oriented manner by combining the Criteria instances in a tree structure. From this tree structure, query statements can be generated. In turn, a query statement provided as logical operators can be parsed for the construction of a Criteria tree (see example above)s.
This means that a Criteria query is constructed from a Criteria tree with CriteriaNode node instances and CriteriaLeaf leaf instances. A node may contain other node instances and/or other leaf instances, all of which being the node's children.
import static org.refcodes.criteria.-DeclarativeCriteria.*; ... Criteria theCriteria = and( or( equalWith( "City", "Berlin" ), equalWith( "City", "Munich" ) ), equalWith( "Surname", "Miller" ) ); ...
( ( ( City = 'Berlin' ) OR ( City = 'Munich' ) ) AND ( Surname = 'Miller' ) )CAUTION: The syntax supported for the query statement is implementation depended!
The ExpressionCriteriaFactoryImpl implements a CriteriaFactory being capable of parsing the above query.
CAUTION: The syntax supported for the query statement is implementation depended!
Interface Summary Interface Description AndCriteriaA
CriteriaNoderepresenting a logical AND operator.
Criteria CriteriaAccessorProvides an accessor for a
CriteriaAccessor.CriteriaMutatorProvides a mutator for a
CriteriaFactory<Q> CriteriaLeaf<T>A CriteriaLeaf tree leaf is an expression usually relating to a key (for example identifying a table's column in a database) and a value, both of which consolidating an expression (for example "City = 'Munich'"). CriteriaNodeA CriteriaNode tree node may represent a logical AND or a logical OR or a logical NOT applied on the node's children Criteria (CriteriaNode instances and CriteriaLeaf instances). EqualWithCriteria<T>A
CriteriaLeafrepresenting a EQUAL WITH expression.
CriteriaLeafrepresenting a GREATER OR EQUAL THAN expression.
CriteriaLeafrepresenting a GREATER THAN expression.
CriteriaNoderepresenting a logical INTERSECT operator.
CriteriaLeafrepresenting a LESS OR EQUAL THAN expression.
CriteriaLeafrepresenting a LESS THAN expression.
CriteriaNoderepresenting a logical NOT operator.
CriteriaLeafrepresenting a NOT EQUAL WITH expression.
CriteriaNoderepresenting a logical OR operator.
PartitionQueryFactory<Q,PS> QueryFactory<Q> SingleCriteriaNodeA special specialization of the
CriteriaNode, allowing just one child.
Class Summary Class Description AbstractCriteria AbstractCriteriaLeaf<T> AbstractCriteriaNode AbstractSingleCriteriaNode CriteriaSugarDeclarative syntactic sugar which may be statically imported in order to allow declarative definitions of
CriteriaUtilityThe Class CriteriaUtility. ExpressionCriteriaFactoryImplImplements a
CriteriaFactorywhich is capable of parsing an expression such as the following one: ( ( ( City = 'Berlin' ) OR ( City = 'Munich' ) ) AND ( Surname = 'Miller' ) ).
Exception Summary Exception Description ComplexCriteriaExceptionThe Class ComplexCriteriaException. CriteriaExceptionThe Class CriteriaException. CriteriaRuntimeExceptionThe Class CriteriaRuntimeException. UnknownCriteriaRuntimeExceptionThe Class UnknownCriteriaRuntimeException.