public class TokenContext
extends java.lang.Object
When processing a token, the DDL statement that is being created can be
added to as appropriate for the contents of a
given token.
Multiple statements can be built up as part of a single generation. The
full generation can be accessed using getStatements().
| Modifier and Type | Method and Description |
|---|---|
void |
append(java.lang.Object value)
Appends the given value to the current statement buffer.
|
void |
appendString(java.lang.String string,
boolean incrementNewlines)
Appends the given string.
|
void |
decrementIndent()
Decrements the indent which will be appended at the beginning of every
new line.
|
void |
endCurrentStatement()
Terminates the current statement that is being appended to.
|
Difference |
findUpdateDifference(DBObject obj)
If we are processing the update of an object, this finds a Difference
that shows the changes for the given object.
|
Schema |
getDefaultSchema()
Gets the default Schema from the underlying provider.
|
Difference |
getDifference()
Gets the Difference for the current token.
|
java.lang.String |
getExternalName(java.lang.String name)
Gets the external version (e.g.
|
java.lang.Object |
getLoopObject()
Gets the loop object.
|
java.lang.Object |
getObject()
Gets the context object for the current token.
|
DDLOptions |
getOptions()
Gets the DDLOptions that the generation was started with.
|
java.lang.Object |
getPropertyValue(java.lang.String propName)
Gets a property value from the context object.
|
DBObjectProvider |
getProvider()
Gets the DBObjectProvider that the DBObjects being generated are
from/for.
|
java.util.List<java.lang.String> |
getStatements()
Returns the full list of statements that have been built in this DDL
generation.
|
void |
incrementIndent()
Increments the indent which will be appended at the beginning of every
new line.
|
boolean |
isUpdate()
Tests whether the current token has a Difference, and that tokens
such as
{old.name} and {+columns} will therefore work. |
int |
length()
Gets the length of the current statement being built.
|
TokenContext |
newChildContext(java.lang.Object newObj)
Creates a new child context for the given object.
|
void |
removeIfEndsWith(java.lang.String str)
If the current statement ends with the given string, this method
removes that string from the end of the statement.
|
java.lang.String |
toString()
Gets the contents of the current buffer being built.
|
public DBObjectProvider getProvider()
public Schema getDefaultSchema()
public java.lang.Object getObject()
difference.public Difference getDifference()
public boolean isUpdate()
{old.name} and {+columns} will therefore work.public Difference findUpdateDifference(DBObject obj)
This will only return a Difference if it contains changes (i.e.
!isSame()).
obj - the object to find a difference for (can be the original or
updated object).public DDLOptions getOptions()
public java.lang.Object getLoopObject()
{each} token.public void endCurrentStatement()
append(Object)public void incrementIndent()
public void decrementIndent()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.util.List<java.lang.String> getStatements()
Calling this method ends the current statement.
endCurrentStatement()public int length()
public void removeIfEndsWith(java.lang.String str)
str - the string to remove if presentpublic java.lang.String getExternalName(java.lang.String name)
public void appendString(java.lang.String string,
boolean incrementNewlines)
string - the string to append to the current bufferincrementNewlines - whether to also include the current increment
on any newlines within string.public void append(java.lang.Object value)
DBObject - the name of the object is appended, quoted
if necessary, unless the TokenProcessor has a GLOBAL token registered
for the object's type.SchemaObject - as DBObject but the schema name will
also be included if it is different to the schema of the object being
generated.
SQLFragment - the value of getSQLText() is
appended.DataTypeUsage - the full ddl for the usage (including
attributes) is appended.DBObjectID - the name of the referenced object is appended,
quoted and prepended with schema name if necessary.value - the object to appendpublic TokenContext newChildContext(java.lang.Object newObj)
newObj as the target for all tokens.newObj - the context object (a child of the current context
object)newObjpublic java.lang.Object getPropertyValue(java.lang.String propName)
propName - the name of the property to get the value for