Class PamTableItem

java.lang.Object
generalDatabase.PamTableItem
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
EnhancedTableItem, FormsTableItem

public class PamTableItem extends Object implements Cloneable
Defines a single item (column) for a Pamguard database table These are listed in PamTableDefinition for each table.
Author:
Doug Gillespie
See Also:
  • Constructor Details

    • PamTableItem

      public PamTableItem(String name, int sqlType)
      Generate a table item
      Parameters:
      name - name of table item
      sqlType - SQL Type from java.sql.Types, e.g. Types.INTEGER
    • PamTableItem

      public PamTableItem(String name, int sqlType, String description)
      Generate a table item
      Parameters:
      name - name of table item
      sqlType - SQL Type from java.sql.Types, e.g. Types.INTEGER
      description - optional description
    • PamTableItem

      public PamTableItem(String name, int sqlType, int length)
      Generate a table item
      Parameters:
      name - name of table item
      sqlType - SQL Type from java.sql.Types, e.g. Types.INTEGER
      length - length (only applicable to Types.CHAR types)
    • PamTableItem

      public PamTableItem(String name, int sqlType, int length, String description)
      Generate a table item
      Parameters:
      name - name of table item
      sqlType - SQL Type from java.sql.Types, e.g. Types.INTEGER
      length - length (only applicable to Types.CHAR types)
      description - optional description
    • PamTableItem

      public PamTableItem(String name, int sqlType, int length, boolean required)
  • Method Details

    • getLength

      public int getLength()
    • setLength

      public void setLength(int length)
    • getName

      public String getName()
      Get the column name, any spaces in the name will be filled with underscore characters
      Returns:
      a deblanked name
    • getNameWithBlanks

      public String getNameWithBlanks()
      Get the name with any spaces left in place. Should only be used when copying in data from old databases and requires careful formatting before use in an SQL query.
      Returns:
      the name with the spaces left in place
    • setName

      public void setName(String name)
    • isRequired

      public boolean isRequired()
    • setRequired

      public void setRequired(boolean required)
    • getSqlType

      public int getSqlType()
    • setSqlType

      public void setSqlType(int sqlType)
    • isPrimaryKey

      public boolean isPrimaryKey()
    • setPrimaryKey

      public void setPrimaryKey(boolean primaryKey)
    • isCounter

      public boolean isCounter()
    • setCounter

      public void setCounter(boolean isCounter)
    • getValue

      public Object getValue()
      Gets the most recently used value written to or read from the database.
      Returns:
      data read from or written to the database column
    • getDeblankedStringValue

      public String getDeblankedStringValue()
    • setValue

      public void setValue(Object value)
      Sets the value of data to be written to the database column.
      Parameters:
      value -
    • getCrossReferenceItem

      public PamTableItem getCrossReferenceItem()
      Gets the cross reference item. If the item reference is null then the function searches for it based on previously set table and column names.
      Returns:
      Table item the current item is cross referenced to
    • setCrossReferenceItem

      public PamTableItem setCrossReferenceItem(PamTableItem crossReferenceItem)
      Sets the cross reference item. Data from the crossREferenceItem will automatically be used when data are written to the database.
      Parameters:
      crossReferenceItem -
      Returns:
      reference to the crossREferenceItem.
    • setCrossReferenceItem

      public PamTableItem setCrossReferenceItem(String tableName, String columnName)
      Sets the cross reference item. Data from the crossREferenceItem will automatically be used when data are written to the database.
      Parameters:
      tableName - name of the table to cross reference to
      columnName - name of the column to cross reference to
      Returns:
      reference to the PamTableItem, or null if it can't be found. If the cross reference item cannot be found it will be searched for again when data are next required in getCrossReferenceItem
    • findTableItem

      public static PamTableItem findTableItem(String tableName, String columnName)
      Searches all Pamguard datablocks and SQLLoggers for a named table and column for use in cross referencing.
    • getShortValue

      public Short getShortValue()
    • getIntegerValue

      public int getIntegerValue()
      Returns an int, or 0 if the value is null
      Returns:
    • getIntegerObject

      public Integer getIntegerObject()
      Return an Integer object, or null if the value is null
      Returns:
    • getLongValue

      public long getLongValue()
    • getLongObject

      public Long getLongObject()
      Database is clever and returns Longs as ints if they are amll enough and as Doubles if they are too big !
      Returns:
    • getDoubleValue

      public double getDoubleValue()
      Returns:
      the double value or Double.NaN if the value is null
    • getFloatValue

      public float getFloatValue()
      Get a float value, being aware that some DBMS may have decided to store as a Double anyway. Return Float.NaN for null data
      Returns:
      float value or NaN
    • getBooleanValue

      public boolean getBooleanValue()
    • getStringValue

      public String getStringValue()
    • getPackedValue

      public Object getPackedValue()
    • getDescription

      public String getDescription()
      Returns:
      the description
    • setDescription

      public void setDescription(String description)
      Parameters:
      description - the description to set