Class EmptyTableDefinition
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
CopyTableDefinition
,DecisionTable
,OutputTableDefinition
,PamTableDefinition
,RainbowClicksTableDef
,RainbowEventsTableDef
,UDFTableDefinition
- Author:
- Doug Gillespie
-
Field Summary
-
Constructor Summary
ConstructorDescriptionEmptyTableDefinition
(String tableName) EmptyTableDefinition
(String tableName, int updatePolicy) -
Method Summary
Modifier and TypeMethodDescriptionint
addTableItem
(PamTableItem pamTableItem) Adds a new table itemstatic String
deblankString
(String str) Function to remove leading and trailing blanks and to replace spaces in a database table or column name with the _ character.findTableItem
(PamTableItem tableItem) Searches the table definition to see if a TableItem already exists with the same name as tableITem.findTableItem
(String itemName) Searches the existing table defnition to see if a table item already exists with a given name.final String
getBasicSelectString
(SQLTypes sqlTypes) getSQLInsertString
(SQLTypes sqlTypes) getSQLInsertString
(SQLTypes sqlTypes, boolean includeCounters) gets an sql insert string for the table that selects all fields.getSQLSelectString
(SQLTypes sqlTypes) Get a very basic select string which queries for all items in the table, no ordering or selectiongetTableItem
(int itemNumber) int
int
boolean
Cheat at database indexing.static String
reblankString
(String str) Function to replace the _ character in a database table or column name with spaces to use with displays.removeTableItem
(int itemIndex) Removes a table item from the table definition.boolean
removeTableItem
(PamTableItem item) Removes a table item from the table definition.void
setCheckedConnection
(PamConnection checkedConnection) void
setTableName
(String tableName) void
setUpdatePolicy
(int updatePolicy) void
setUseCheatIndexing
(boolean useCheatIndexing) Cheat at database indexing.boolean
unpackResultSet
(ResultSet resultSet) Move the data out of a result set into the holding places in the table items.
-
Field Details
-
indexColName
- See Also:
-
-
Constructor Details
-
EmptyTableDefinition
-
EmptyTableDefinition
- Parameters:
tableName
-
-
-
Method Details
-
deblankString
Function to remove leading and trailing blanks and to replace spaces in a database table or column name with the _ character.- Parameters:
str
- database table or column name- Returns:
- deblanked string.
-
reblankString
Function to replace the _ character in a database table or column name with spaces to use with displays.- Parameters:
str
- database table or column name- Returns:
- reblanked string.
-
getTableName
- Returns:
- Deblanked database table name
-
setTableName
-
getTableItem
- Parameters:
itemNumber
- Table item index (0 indexed)- Returns:
- table item
- See Also:
-
getTableItemCount
public int getTableItemCount()- Returns:
- Count of table items (database columns)
- See Also:
-
addTableItem
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 replace the old one. This is required for the annotation framework which is a bit fast and loose with recreating table items - without care, the item in the table definition will end up with a different reference to the item stored in the annotation code, so data will be written to the wrong tableitem when data are being prepared for storage.
-
removeTableItem
Removes a table item from the table definition.- Parameters:
itemIndex
- index of the table item.- Returns:
- the item removed.
-
removeTableItem
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
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
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
-
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
Get a very basic select string which queries for all items in the table, no ordering or selection- Returns:
- an SQL string.
-
getBasicSelectString
-
unpackResultSet
Move the data out of a result set into the holding places in the table items.- Parameters:
resultSet
- result set to unpack- Returns:
- true if OK, false if any exceptions thrown
-
getIndexItem
-
isUseCheatIndexing
public boolean isUseCheatIndexing()Cheat at database indexing. If cheat indexing is used, then the index will only be read back from the database table when the first record is written. After that, the PAMCursor working with this table will keep a count of the index and increment it by one each time a record is written.This could go badly wrong if more than one program or different bits of the same programme are writing to the same table. However, in many cases this will not be important since the indexes are not actually used in real time operation. i.e. it's safe to do this for things like GPS and whistle data. However, it would not be recommended for things where it's more likely that multiple users might write to the same database or where indexing is really critical such as in logger forms (the index is used to update data) or Click offline events (the index is used for cross referencing from the clicks).
- Returns:
- the useCheatIndexing
-
setUseCheatIndexing
public void setUseCheatIndexing(boolean useCheatIndexing) Cheat at database indexing. If cheat indexing is used, then the index will only be read back from the database table when the first record is written. After that, the PAMCursor working with this table will keep a count of the index and increment it by one each time a record is written.This could go badly wrong if more than one program or different bits of the same programme are writing to the same table. However, in many cases this will not be important since the indexes are not actually used in real time operation. i.e. it's safe to do this for things like GPS and whistle data. However, it would not be recommended for things where it's more likely that multiple users might write to the same database or where indexing is really critical such as in logger forms (the index is used to update data) or Click offline events (the index is used for cross referencing from the clicks).
- Parameters:
useCheatIndexing
- the useCheatIndexing to set
-
getUpdatePolicy
public int getUpdatePolicy()- Returns:
- the updatePolicy
-
setUpdatePolicy
public void setUpdatePolicy(int updatePolicy) - Parameters:
updatePolicy
- the updatePolicy to set
-
getCheckedConnection
-
setCheckedConnection
-