jodd.db.orm.sqlgen.chunks
Class SqlChunk

java.lang.Object
  extended by jodd.db.orm.sqlgen.chunks.SqlChunk
Direct Known Subclasses:
ColumnChunk, ConditionChunk, InsertChunk, JoinOnChunk, RawSqlChunk, ReferenceChunk, ReferenceFkChunk, ReferenceJoinChunk, SqlChunkContainerSupport, TableChunk, UpdateSetChunk, ValueChunk

public abstract class SqlChunk
extends java.lang.Object

Sql chunk generates part of SQL query.


Field Summary
static int COLS_ALL
          Marker for using all available columns.
static int COLS_NA
           
static int COLS_ONLY_EXISTING
          Marker for using only existing columns i.e. that are not-null.
static int COLS_ONLY_IDS
          Marker for using only identity columns.
protected  boolean isColumnChunk
           
protected  boolean isJoinOnChunk
           
protected  boolean isTableChunk
           
protected  SqlChunk nextChunk
           
protected  SqlChunk previousChunk
           
protected  java.lang.StringBuilder query
           
protected  DbSqlBuilder sqlBuilder
           
 
Constructor Summary
SqlChunk()
           
 
Method Summary
protected  void defineParameter(java.lang.StringBuilder query, java.lang.String name, java.lang.Object value)
          Defines parameter with name and its value.
 SqlChunk getNextChunk()
          Returns next chunk.
 SqlChunk getPreviousChunk()
          Returns previous chunk.
 void init(DbSqlBuilder sqlBuilder)
          Initializes chunk.
 void insertChunkAfter(SqlChunk previous)
          Appends chunk to previous one and maintaince the double-linked list.
 boolean isColumnChunk()
          Returns true if this chunk is kind-of column chunk.
 boolean isJoinOnChunk()
          Returns true if this chunk is kind-of join on chunk.
 boolean isTableChunk()
          Returns true if this chunk is kind-of table chunk.
protected  DbEntityDescriptor lookupName(java.lang.String entityName)
          Lookups for entity name and throws exception if entity name not found.
protected  DbEntityDescriptor lookupTableRef(java.lang.String tableRef)
          Lookups for table reference and throws an exception if table reference not found.
protected  DbEntityDescriptor lookupType(java.lang.Class entity)
          Lookups for entity name and throws an exception if entity type is invalid.
abstract  void process()
          Process the chunk and prepares the output.
 java.lang.String render()
          Returns processed output.
protected  java.lang.String resolveTableRef(java.lang.String tableRef)
          Returns the real value for table reference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLS_NA

public static final int COLS_NA
See Also:
Constant Field Values

COLS_ONLY_EXISTING

public static final int COLS_ONLY_EXISTING
Marker for using only existing columns i.e. that are not-null.

See Also:
Constant Field Values

COLS_ONLY_IDS

public static final int COLS_ONLY_IDS
Marker for using only identity columns.

See Also:
Constant Field Values

COLS_ALL

public static final int COLS_ALL
Marker for using all available columns.

See Also:
Constant Field Values

previousChunk

protected SqlChunk previousChunk

nextChunk

protected SqlChunk nextChunk

sqlBuilder

protected DbSqlBuilder sqlBuilder

query

protected java.lang.StringBuilder query

isTableChunk

protected boolean isTableChunk

isJoinOnChunk

protected boolean isJoinOnChunk

isColumnChunk

protected boolean isColumnChunk
Constructor Detail

SqlChunk

public SqlChunk()
Method Detail

getPreviousChunk

public SqlChunk getPreviousChunk()
Returns previous chunk.


getNextChunk

public SqlChunk getNextChunk()
Returns next chunk.


insertChunkAfter

public void insertChunkAfter(SqlChunk previous)
Appends chunk to previous one and maintaince the double-linked list.


init

public void init(DbSqlBuilder sqlBuilder)
Initializes chunk. Stores DbSqlBuilder instance and creates new string builder for the result.


process

public abstract void process()
Process the chunk and prepares the output.


render

public java.lang.String render()
Returns processed output.


isTableChunk

public boolean isTableChunk()
Returns true if this chunk is kind-of table chunk.


isColumnChunk

public boolean isColumnChunk()
Returns true if this chunk is kind-of column chunk.


isJoinOnChunk

public boolean isJoinOnChunk()
Returns true if this chunk is kind-of join on chunk.


lookupName

protected DbEntityDescriptor lookupName(java.lang.String entityName)
Lookups for entity name and throws exception if entity name not found.


lookupType

protected DbEntityDescriptor lookupType(java.lang.Class entity)
Lookups for entity name and throws an exception if entity type is invalid.


lookupTableRef

protected DbEntityDescriptor lookupTableRef(java.lang.String tableRef)
Lookups for table reference and throws an exception if table reference not found.


resolveTableRef

protected java.lang.String resolveTableRef(java.lang.String tableRef)
Returns the real value for table reference. Table names or aliases must be rendered using this method.


defineParameter

protected void defineParameter(java.lang.StringBuilder query,
                               java.lang.String name,
                               java.lang.Object value)
Defines parameter with name and its value.



Copyright ©2008 Jodd Team