generalDatabase
Class EmptyTableDefinition

java.lang.Object
  extended by generalDatabase.EmptyTableDefinition
Direct Known Subclasses:
PamTableDefinition

public class EmptyTableDefinition
extends java.lang.Object

A totally empty table definition. Not really empty, since it includes an Id.

Author:
Doug Gillespie

Field Summary
protected  java.sql.Connection checkedConnection
           
private  PamTableItem indexItem
           
protected  java.util.ArrayList<PamTableItem> pamTableItems
           
protected  java.lang.String tableName
           
 
Constructor Summary
EmptyTableDefinition(java.lang.String tableName)
           
 
Method Summary
 int addTableItem(PamTableItem pamTableItem)
          Adds a new table item
static java.lang.String deblankString(java.lang.String str)
          Function to remove leading and trailing blanks and to replace spaces in a database table or column name with the _ character.
(package private) static PamTableDefinition findTableDefinition(java.lang.String tableName)
          Searches the Pamguard system for a table with a particular name.
 PamTableItem findTableItem(PamTableItem tableItem)
          Searches the table definition to see if a TableItem already exists with the same name as tableITem.
 PamTableItem findTableItem(java.lang.String itemName)
          Searches the existing table defnition to see if a table item already exists with a given name.
 PamTableItem getIndexItem()
           
 java.lang.String getSQLInsertString()
          gets an sql insert string for the table that selects all fields.
 java.lang.String getSQLSelectString()
          Get a very basic select string which queries for all items in the table, no ordering or selection
 PamTableItem getTableItem(int itemNumber)
           
 int getTableItemCount()
           
 java.lang.String getTableName()
           
private static boolean isValidCharacter(char ch)
           
 PamTableItem removeTableItem(int itemIndex)
          Removes a table item from the table definition.
 boolean removeTableItem(PamTableItem item)
          Removes a table item from the table definition.
 void setTableName(java.lang.String tableName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tableName

protected java.lang.String tableName

pamTableItems

protected java.util.ArrayList<PamTableItem> pamTableItems

checkedConnection

protected java.sql.Connection checkedConnection

indexItem

private PamTableItem indexItem
Constructor Detail

EmptyTableDefinition

public EmptyTableDefinition(java.lang.String tableName)
Parameters:
tableName -
Method Detail

deblankString

public static java.lang.String deblankString(java.lang.String str)
Function to remove leading and trailing blanks and to replace spaces in a database table or column name with the _ character.

Parameters:
str - datbase table or column name
Returns:
deblanked string.

isValidCharacter

private static boolean isValidCharacter(char ch)

getTableName

public java.lang.String getTableName()
Returns:
Deblanked database table name

setTableName

public void setTableName(java.lang.String tableName)

getTableItem

public PamTableItem getTableItem(int itemNumber)
Parameters:
itemNumber - Table item index (0 indexed)
Returns:
table item
See Also:
PamTableItem

getTableItemCount

public int getTableItemCount()
Returns:
Count of table items (database columns)
See Also:
PamTableItem

addTableItem

public int addTableItem(PamTableItem pamTableItem)
Adds a new table item

Parameters:
pamTableItem - new table item object.
Returns:
The index of the new table item. Some columns are automatically added to every table, so the first column you create yourself may not be column 0. Since the number of columns added automatically may change in future versions of Pamguard, you should use this index when adding data to the table using the SQLLogging.setColumnData function.

If an item already exists with the same name (after deblanking) the new table item will not be added to the list and the index of the existing table item will be returned.


removeTableItem

public PamTableItem removeTableItem(int itemIndex)
Removes a table item from the table definition.

Parameters:
itemIndex - index of the table item.
Returns:
the item removed.

removeTableItem

public boolean removeTableItem(PamTableItem item)
Removes a table item from the table definition.

Parameters:
item - reference to the item to be removed.
Returns:
true if successful, false if the item could not be found.

findTableItem

public PamTableItem findTableItem(java.lang.String itemName)
Searches the existing table defnition to see if a table item already exists with a given name. Returns the reference to the PamTableItem if it exists, null otherwise.

Parameters:
itemName -
Returns:
Pamguard table item with given name

findTableItem

public PamTableItem findTableItem(PamTableItem tableItem)
Searches the table definition to see if a TableItem already exists with the same name as tableITem. Returns the reference to the existing tableItem.

Parameters:
tableItem -
Returns:
reference to the database item, or null if no item found

getSQLInsertString

public java.lang.String getSQLInsertString()
gets an sql insert string for the table that selects all fields. Note that some databases don't support the " around a column name, so this has been omitted, making it impossible to use fields with spaces.

If skipCounters is true, then counters are not included in the statement. Generally, this is the sensible ting to do.

Returns:
SQL Insert string

getSQLSelectString

public java.lang.String getSQLSelectString()
Get a very basic select string which queries for all items in the table, no ordering or selection

Returns:
an SQL string.

findTableDefinition

static PamTableDefinition findTableDefinition(java.lang.String tableName)
Searches the Pamguard system for a table with a particular name. Table names used in the seach are deblanked.

Parameters:
tableName -
Returns:
reference to the database deinition if it exists, or null

getIndexItem

public PamTableItem getIndexItem()