org.ujorm.orm
Class CriterionDecoder

java.lang.Object
  extended by org.ujorm.orm.CriterionDecoder

public class CriterionDecoder
extends Object

SQL Criterion Decoder.


Field Summary
protected  MetaTable baseTable
           
protected  Criterion criterion
           
protected  SqlDialect dialect
           
protected  OrmHandler handler
           
protected  List<ValueCriterion> nullValues
           
protected  List<Key> orderBy
           
protected  boolean printAllJoinedTables
          EFFECTIVA REQUEST: to enforce printing all Ujorm joined tables
protected  StringBuilder sql
           
protected  Set<TableWrapper> tables
           
protected  List<ValueCriterion> values
           
 
Constructor Summary
CriterionDecoder(Criterion criterion, MetaTable baseTable)
          Constructor
CriterionDecoder(Criterion criterion, MetaTable baseTable, List<Key> orderByItems)
          Constructor
 
Method Summary
 Key getBaseProperty()
          Returns the first direct key.
 MetaTable getBaseTable()
          Get Base Table
 MetaColumn getColumn(int i)
          Returns direct column or throw an exception
 int getColumnCount()
          Returns a column count
 Criterion getCriterion()
          Returns the criterion from costructor.
 OrmHandler getHandler()
          Returns handler
 Operator getOperator(int i)
          Returns operator.
protected  Collection<AliasKey> getPropertyRelations()
          Returns the unique direct key relations.
 int getTableCount()
          Returns all participated tables include the parameter table.
 TableWrapper[] getTables()
          Returns all participated tables include the parameter table.
 TableWrapper[] getTablesSorted()
          Returns all participated tables include the parameter table.
 Object getValue(int i)
          Returns value
 Object getValueExtended(int i)
          Returns an extended value to the SQL statement
 String getWhere()
          Returns a SQL WHERE 'expression' of an empty string if no conditon is found.
 boolean isEmpty()
          Is the SQL statement empty?
 String toString()
          Returns the criterion
protected  void unpack(Criterion c)
          Unpack criterion.
protected  void writeRelations()
          Writer a relation conditions:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

handler

protected final OrmHandler handler

dialect

protected final SqlDialect dialect

criterion

protected final Criterion criterion

orderBy

protected final List<Key> orderBy

sql

protected final StringBuilder sql

values

protected final List<ValueCriterion> values

nullValues

protected final List<ValueCriterion> nullValues

tables

protected final Set<TableWrapper> tables

baseTable

protected final MetaTable baseTable

printAllJoinedTables

protected final boolean printAllJoinedTables
EFFECTIVA REQUEST: to enforce printing all Ujorm joined tables

Constructor Detail

CriterionDecoder

public CriterionDecoder(Criterion criterion,
                        MetaTable baseTable)
Constructor

Parameters:
criterion - Criterion non-null
baseTable - Base ORM table model

CriterionDecoder

public CriterionDecoder(Criterion criterion,
                        MetaTable baseTable,
                        List<Key> orderByItems)
Constructor

Parameters:
criterion - Criterion non-null
baseTable - Base ORM table model
orderByItems - The order item list is not mandatory (can be null).
Method Detail

unpack

protected void unpack(Criterion c)
Unpack criterion.


getColumnCount

public int getColumnCount()
Returns a column count


getColumn

public MetaColumn getColumn(int i)
                     throws IllegalArgumentException
Returns direct column or throw an exception

Throws:
IllegalArgumentException

getOperator

public Operator getOperator(int i)
Returns operator.


getValue

public Object getValue(int i)
Returns value


getValueExtended

public Object getValueExtended(int i)
Returns an extended value to the SQL statement


getCriterion

public Criterion getCriterion()
Returns the criterion from costructor.


getWhere

public String getWhere()
Returns a SQL WHERE 'expression' of an empty string if no conditon is found.


isEmpty

public boolean isEmpty()
Is the SQL statement empty?


getBaseProperty

public Key getBaseProperty()
Returns the first direct key.


writeRelations

protected void writeRelations()
Writer a relation conditions:


getPropertyRelations

protected Collection<AliasKey> getPropertyRelations()
Returns the unique direct key relations.


getBaseTable

public MetaTable getBaseTable()
Get Base Table


getTableCount

public int getTableCount()
Returns all participated tables include the parameter table.


getTables

public TableWrapper[] getTables()
Returns all participated tables include the parameter table.


getTablesSorted

public TableWrapper[] getTablesSorted()
Returns all participated tables include the parameter table. The 'baseTable' is on the first position always.


getHandler

public OrmHandler getHandler()
Returns handler


toString

public String toString()
Returns the criterion

Overrides:
toString in class Object


Copyright 2013, Pavel Ponec