Class EmptyTableDefinition

java.lang.Object
generalDatabase.EmptyTableDefinition
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
CopyTableDefinition, DecisionTable, OutputTableDefinition, PamTableDefinition, RainbowClicksTableDef, RainbowEventsTableDef, UDFTableDefinition

public class EmptyTableDefinition extends Object implements Cloneable
A totally empty table definition. Not really empty, since it includes an Id.
Author:
Doug Gillespie
  • Field Details

  • Constructor Details

    • EmptyTableDefinition

      public EmptyTableDefinition(String tableName)
    • EmptyTableDefinition

      public EmptyTableDefinition(String tableName, int updatePolicy)
      Parameters:
      tableName -
  • Method Details

    • deblankString

      public static 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.
      Parameters:
      str - database table or column name
      Returns:
      deblanked string.
    • reblankString

      public static String reblankString(String str)
      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

      public String getTableName()
      Returns:
      Deblanked database table name
    • setTableName

      public void setTableName(String tableName)
    • getTableItem

      public PamTableItem getTableItem(int itemNumber)
      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

      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 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

      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(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 String getSQLInsertString(SQLTypes sqlTypes)
    • getSQLInsertString

      public String getSQLInsertString(SQLTypes sqlTypes, boolean includeCounters)
      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 String getSQLSelectString(SQLTypes sqlTypes)
      Get a very basic select string which queries for all items in the table, no ordering or selection
      Returns:
      an SQL string.
    • getBasicSelectString

      public final String getBasicSelectString(SQLTypes sqlTypes)
    • unpackResultSet

      public boolean unpackResultSet(ResultSet resultSet)
      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

      public PamTableItem 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

      public PamConnection getCheckedConnection()
    • setCheckedConnection

      public void setCheckedConnection(PamConnection checkedConnection)