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

    • PamTableItem Link icon

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

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

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

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

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

    • getLength Link icon

      public int getLength()
    • setLength Link icon

      public void setLength(int length)
    • getName Link icon

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

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

      public void setName(String name)
    • isRequired Link icon

      public boolean isRequired()
    • setRequired Link icon

      public void setRequired(boolean required)
    • getSqlType Link icon

      public int getSqlType()
    • setSqlType Link icon

      public void setSqlType(int sqlType)
    • isPrimaryKey Link icon

      public boolean isPrimaryKey()
    • setPrimaryKey Link icon

      public void setPrimaryKey(boolean primaryKey)
    • isCounter Link icon

      public boolean isCounter()
    • setCounter Link icon

      public void setCounter(boolean isCounter)
    • getValue Link icon

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

      public String getDeblankedStringValue()
    • setValue Link icon

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

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

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

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

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

      public Short getShortValue()
    • getIntegerValue Link icon

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

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

      public long getLongValue()
    • getLongObject Link icon

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

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

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

      public boolean getBooleanValue()
    • getStringValue Link icon

      public String getStringValue()
    • getPackedValue Link icon

      public Object getPackedValue()
    • getDescription Link icon

      public String getDescription()
      Returns:
      the description
    • setDescription Link icon

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