|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lapetus_ltd._2009.xml.types.XLptsDBCreateStatementTableType
com.lapetus_ltd.api.db.xml.types.TLptsDBCreateStatementTableType
public class TLptsDBCreateStatementTableType
Class Description : Initiates the table type for a CREATE statement.
Field Summary |
---|
Fields inherited from class com.lapetus_ltd._2009.xml.types.XLptsDBCreateStatementTableType |
---|
columnList, commitType, constraintTypeList, id, table, temporary |
Constructor Summary | |
---|---|
TLptsDBCreateStatementTableType()
This constructor initiates a Create Table. |
|
TLptsDBCreateStatementTableType(XLptsDBCreateStatementTableType ctt)
This constructor copies the create table information from another XLptsDBCreateStatementTableType. |
Method Summary | |
---|---|
void |
addColumn(XLptsDBCreateStatementColumnType item)
Adds the column to the table column list. |
void |
addConstraint(XLptsDBCreateTableConstraintType item)
Adds the constraint to the table constraint list. |
boolean |
equals(java.lang.Object obj)
Check for equal TLptsDBCreateStatementTableType objects. |
java.util.List<XLptsDBCreateStatementColumnType> |
getColumnList()
Returns a copy of the column list. |
int |
getColumnListSize()
Returns the size of the actual list. |
java.util.List<XLptsDBCreateTableConstraintType> |
getConstraintTypeList()
Returns a copy of the table constraint list. |
int |
getConstraintTypeListSize()
Returns the size of the actual list. |
void |
removeColumn(XLptsDBCreateStatementColumnType item)
Removes the column from the table column list. |
void |
removeConstraint(XLptsDBCreateTableConstraintType item)
Removes the constraint from the table constraint list. |
Methods inherited from class com.lapetus_ltd._2009.xml.types.XLptsDBCreateStatementTableType |
---|
getCommitType, getId, getTable, getTemporary, setCommitType, setId, setTable, setTemporary |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TLptsDBCreateStatementTableType()
This constructor initiates a Create Table.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Never.
Notes : Initializes the table Constraint list and the Column list.
Example :
TLptsStatement createStatement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.CREATE); //Get the rootType TLptsDBCreateStatementRootType rootType = new TLptsDBCreateStatementRootType(); //Set a name for easy use rootType.setTitle("root"); //create a table TLptsDBCreateStatementTableType table = new TLptsDBCreateStatementTableType(); //Set the name of the table table.setTable("newTable"); //Set the table against the root type rootType.setTable(table); ...
public TLptsDBCreateStatementTableType(XLptsDBCreateStatementTableType ctt)
This constructor copies the create table information from another XLptsDBCreateStatementTableType.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Never.
Notes : Use this function every time you need to copy or instantiate a XLptsDBCreateStatementTableType class.
Example :
public void example(XLptsDBCreateStatementTableType ctt) { TLptsDBCreateStatementTableType createTable = new TLptsDBCreateStatementTableType(ctt); } }
ctt
- the class object to copy.Method Detail |
---|
public void addColumn(XLptsDBCreateStatementColumnType item)
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : n/a
Notes :
Use this to add to the list. Getting the list with getColumnList and then adding does not have any affect.
Example :
TLptsStatement createStatement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.CREATE); TLptsDBCreateStatementRootType rootType = new TLptsDBCreateStatementRootType(); //Set a logical name rootType.setTitle("root"); //Set a table TLptsDBCreateStatementTableType table = new TLptsDBCreateStatementTableType(); //Set the name of the table table.setTable("newTable"); //set the table in the root type rootType.setTable(table); //In some DBs the tables can be temporary TLptsDBCreateStatementTableTemporaryType temporary = new TLptsDBCreateStatementTableTemporaryType(); temporary.setTemporary(false); //Set other parameters on the temporary type XLptsDBCreateStatementTableGlobalLocal globalLocal = new XLptsDBCreateStatementTableGlobalLocal(); //Temporary table can be global, local or nothing specific globalLocal.setGlobalLocal(XLptsDBCreateStatementTableGlobalLocalType.GLOBAL); temporary.setGlobalLocal(globalLocal); table.setTemporary(temporary); //Create the columns TLptsDBCreateStatementColumnType idColumn = new TLptsDBCreateStatementColumnType(); //Set the column name idColumn.setColumn("id"); //Set the column sql type XLptsDBCreateStatementColumnSqlType sqlType = new XLptsDBCreateStatementColumnSqlType(); sqlType.setSqlType(java.sql.Types.INTEGER); idColumn.setSqlType(sqlType); //Some types like varchar have a size. Some types like decimal have two sizes. // The first is the integer digits and the second is the decimal places. //XLptsDBCreateStatementColumnSizeType size = new XLptsDBCreateStatementColumnSizeType(); //size.setSize1("10"); // total length //size.setSize2("2"); // decimal places //idColumn.setSizes(size); //Text type columns can have Collation. Collation is not available in all DB's and the values are not consistent across DBs. //XLptsDBCreateStatementColumnCollateType collate = new XLptsDBCreateStatementColumnCollateType(); //collate.setCollate("SQL_Latin1_General_CP1253_CI_AS"); //idColumn.setCollate(collate); //Some times we want a column to have a default value when a value is not set //XLptsDBCreateStatementColumnDefaultType defaultValue = new XLptsDBCreateStatementColumnDefaultType(); //defaultValue.setDefault("10"); //idColumn.setDefault(defaultValue); //Some DB's allows column Constraints. A column can have more than one constraint. TLptsDBCreateColumnConstraintType columnConstraintType = new TLptsDBCreateColumnConstraintType(); //Set column Parameters columnConstraintType.setColumnId(idColumn.getId()); //Constraint values are NOT NULL, UNIQUE, PRIMARY KEY, REFERENCES, CHECK // The following needs to be noted for each type: //NOT NULL and UNIQUE cannot have a name. setConstraint, onDelete and onUpdate cannot be set //PRIMARY KEY can have a name but setConstraint, onDelete and onUpdate cannot be set //CHECK can have a name and setConstraint should be set. onDelete and onUpdate cannot be set //REFERENCES can have a name. The table and column names must be set to the referenced column/table. columnConstraintType.setConstraintType(XLptsDBCreateColumnConstraintParameterType.PRIMARY_KEY); //columnConstraintType.setName("ID_PRI_CONSTRAINT"); //columnConstraintType.setConstraint("id"); //columnConstraintType.setColumn("id_of_refTable"); //columnConstraintType.setTable("refTable"); //columnConstraintType.setOnDelete(XLptsDBCreateColumnConstraintOnDeleteUpdateType.CASCADE); //columnConstraintType.setOnUpdate(XLptsDBCreateColumnConstraintOnDeleteUpdateType.RESTRICT); //At last we add the columnConstraint to the constraint list of the column idColumn.addConstraint(columnConstraintType); table.addColumn(idColumn); ...
item
- the column to add in the list.public void addConstraint(XLptsDBCreateTableConstraintType item)
Adds the constraint to the table constraint list.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : n/a
Notes : Use this to add to the list. Getting the list with getConstraintTypeList and
then adding does not have any affect.
Example :
TLptsStatement createStatement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.CREATE); TLptsDBCreateStatementRootType rootType = new TLptsDBCreateStatementRootType(); rootType.setTitle("root"); TLptsDBCreateStatementTableType table = new TLptsDBCreateStatementTableType(); table.setTable("newTable"); rootType.setTable(table); TLptsDBCreateStatementTableTemporaryType temporary = new TLptsDBCreateStatementTableTemporaryType(); temporary.setTemporary(true); TLptsDBCreateStatementTableGlobalLocal globalLocal = new TLptsDBCreateStatementTableGlobalLocal(); globalLocal.setGlobalLocal(XLptsDBCreateStatementTableGlobalLocalType.GLOBAL); temporary.setGlobalLocal(globalLocal); table.setTemporary(temporary); ... //Constraint values are NOT NULL, UNIQUE, PRIMARY KEY, REFERENCES, CHECK // The following needs to be noted for each type: //NOT NULL and UNIQUE cannot have a name. setConstraint, onDelete and onUpdate cannot be set //PRIMARY KEY can have a name but setConstraint, onDelete and onUpdate cannot be set //CHECK can have a name and setConstraint should be set. onDelete and onUpdate cannot be set //REFERENCES can have a name. The table and column names must be set to the referenced column/table. TLptsDBCreateTableConstraintType tableConstraint = new TLptsDBCreateTableConstraintType(); tableConstraint.setName("foreign_key"); tableConstraint.setConstraintType(XLptsDBCreateTableConstraintParameterType.FOREIGN_KEY); tableConstraint.setConstraint(""); tableConstraint.setReferences(""); table.addConstraint(tableConstraint); TLptsDBCreateStatementTableCommitType commit = new TLptsDBCreateStatementTableCommitType(table); commit.setCommitType(XLptsDBCreateTableCommitType.DELETE); table.setCommitType(commit); ...
item
- the column to add to the list.public boolean equals(java.lang.Object obj)
Check for equal TLptsDBCreateStatementTableType objects.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : n/a
Notes : Use this to compare two TLptsDBCreateStatementTableType objects by there id's.
Example :
equals
in class java.lang.Object
obj
- the create table type
public java.util.List<XLptsDBCreateStatementColumnType> getColumnList()
Returns a copy of the column list.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Never. The result may be an empty list.
Notes : Do not add to this list as there is no result. Use the addColumn function.
Example :
... JComboBox columnComboBox = new JComboBox(); ... private void setComboValues() { if(((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getColumnListSize()>0) { for(XLptsDBCreateStatementColumnType column : ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getColumnList()) columnComboBox.addItem(column.getColumn()); } } ... private void comboActionPerformed() { for(XLptsDBCreateStatementColumnType column : ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getColumnList()) if(column.getColumn().equals(columnComboBox.getSelectedItem())) { ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).removeColumn(column); break; } } ...
getColumnList
in class XLptsDBCreateStatementTableType
public int getColumnListSize()
Returns the size of the actual list.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Never. The result may be an empty list.
Notes : Do not use getColumnList().size() as it is not efficient.
Example :
... JComboBox columnComboBox = new JComboBox(); ... private void setComboValues() { if(((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getColumnListSize()>0) { for(XLptsDBCreateStatementColumnType column : ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getColumnList()) columnComboBox.addItem(column.getColumn()); } } ... private void comboActionPerformed() { for(XLptsDBCreateStatementColumnType column : ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getColumnList()) if(column.getColumn().equals(columnComboBox.getSelectedItem())) { ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).removeColumn(column); break; } } ...
public java.util.List<XLptsDBCreateTableConstraintType> getConstraintTypeList()
Returns a copy of the table constraint list.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Never. The result may be an empty list.
Notes :
Do not confuse this with the column constraints.
Add to this list has no result. Use the addConstraint function.
Example :
... JComboBox constraintComboBox = new JComboBox(); ... private void setComboValues() { if(((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getConstraintTypeListSize()>0) { for(XLptsDBCreateTableConstraintType constraint : ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getConstraintTypeList()) constraintComboBox.addItem(constraint.getConstraint()); } ... private void comboActionPerformed() { for(XLptsDBCreateTableConstraintType constraint : ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getConstraintTypeList()) if(constraint.getConstraint().equals(constraintComboBox.getSelectedItem())) { ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).removeConstraint(constraint); break; } }
getConstraintTypeList
in class XLptsDBCreateStatementTableType
public int getConstraintTypeListSize()
Returns the size of the actual list.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Never. The result may be an empty list.
Notes : Do not use getConstraintTypeList().size() as it is not efficient.
Example :
... JComboBox constraintComboBox = new JComboBox(); ... private void setComboValues() { if(((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getConstraintTypeListSize()>0) { for(XLptsDBCreateTableConstraintType constraint : ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getConstraintTypeList()) constraintComboBox.addItem(constraint.getConstraint()); } ... private void comboActionPerformed() { for(XLptsDBCreateTableConstraintType constraint : ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getConstraintTypeList()) if(constraint.getConstraint().equals(constraintComboBox.getSelectedItem())) { ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).removeConstraint(constraint); break; } }
public void removeColumn(XLptsDBCreateStatementColumnType item)
Removes the column from the table column list.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : n/a
Notes : Use this to remove from the list. Getting the list with getColumnList and then removing does not have any affect.
Example :
... JComboBox columnComboBox = new JComboBox(); ... private void setComboValues() { if(((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getColumnListSize()>0) { for(XLptsDBCreateStatementColumnType column : ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getColumnList()) columnComboBox.addItem(column.getColumn()); } } ... private void comboActionPerformed() { for(XLptsDBCreateStatementColumnType column : ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getColumnList()) if(column.getColumn().equals(columnComboBox.getSelectedItem())) { ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).removeColumn(column); break; } } ...
item
- the column to remove from list.public void removeConstraint(XLptsDBCreateTableConstraintType item)
Removes the constraint from the table constraint list.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : n/a
Notes : Use this to remove from the list.
Getting the list with getConstraintTypeList and then removing does not have any affect.
Example :
... JComboBox constraintComboBox = new JComboBox(); ... private void setComboValues() { if(((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getConstraintTypeListSize()>0) { for(XLptsDBCreateTableConstraintType constraint : ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getConstraintTypeList()) constraintComboBox.addItem(constraint.getConstraint()); } ... private void comboActionPerformed() { for(XLptsDBCreateTableConstraintType constraint : ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).getConstraintTypeList()) if(constraint.getConstraint().equals(constraintComboBox.getSelectedItem())) { ((TLptsDBCreateStatementTableType) createStatement.getCreateRootItem().getTable()).removeConstraint(constraint); break; } }
item
- the constraint to remove from list.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |