generalDatabase
Class PamTableItem

java.lang.Object
  extended by generalDatabase.PamTableItem

public class PamTableItem
extends java.lang.Object

Defines a single item (column) for a Pamguard database table These are listed in PamTableDefinition for each table.

Author:
Doug Gillespie
See Also:
PamTableDefinition

Field Summary
private  PamTableItem crossReferenceItem
           
private  boolean isCounter
          IS an autoincrementing counter can only be used if sqlType is integer
private  int length
          lengh of character type fields.
private  java.lang.String name
          name of the database column
private  boolean primaryKey
          Is a primary key
private  boolean required
          required field (cannot be null)
private  int sqlType
          the SQL type (as defined in java.sql.Types) for the database column
private  java.lang.Object value
          Contains the last value logged to or read from the database.
private  java.lang.String xRefColumn
           
private  java.lang.String xRefTable
           
 
Constructor Summary
PamTableItem(java.lang.String name, int sqlType)
           
PamTableItem(java.lang.String name, int sqlType, int length)
           
PamTableItem(java.lang.String name, int sqlType, int length, boolean required)
           
 
Method Summary
static PamTableItem findTableItem(java.lang.String tableName, java.lang.String columnName)
          Searches all Pamguard datablocks and SQLLoggers for a named table and column for use in cross referencing.
 boolean getBooleanValue()
           
 PamTableItem getCrossReferenceItem()
          Gets the cross reference item.
 java.lang.String getDeblankedStringValue()
           
 double getDoubleValue()
           
 int getIntegerValue()
           
 int getLength()
           
 java.lang.String getName()
           
 java.lang.Short getShortValue()
           
 int getSqlType()
           
 java.lang.String getStringValue()
           
 java.lang.Object getValue()
          Gets the most recently used value written to or read from the database.
 boolean isCounter()
           
 boolean isPrimaryKey()
           
 boolean isRequired()
           
 void setCounter(boolean isCounter)
           
 PamTableItem setCrossReferenceItem(PamTableItem crossReferenceItem)
          Sets the cross reference item.
 PamTableItem setCrossReferenceItem(java.lang.String tableName, java.lang.String columnName)
          Sets the cross reference item.
 void setLength(int length)
           
 void setName(java.lang.String name)
           
 void setPrimaryKey(boolean primaryKey)
           
 void setRequired(boolean required)
           
 void setSqlType(int sqlType)
           
 void setValue(java.lang.Object value)
          Sets the value of data to be written to the database column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private java.lang.String name
name of the database column


sqlType

private int sqlType
the SQL type (as defined in java.sql.Types) for the database column


length

private int length
lengh of character type fields.


required

private boolean required
required field (cannot be null)


primaryKey

private boolean primaryKey
Is a primary key


isCounter

private boolean isCounter
IS an autoincrementing counter can only be used if sqlType is integer


value

private java.lang.Object value
Contains the last value logged to or read from the database.


crossReferenceItem

private PamTableItem crossReferenceItem

xRefTable

private java.lang.String xRefTable

xRefColumn

private java.lang.String xRefColumn
Constructor Detail

PamTableItem

public PamTableItem(java.lang.String name,
                    int sqlType)

PamTableItem

public PamTableItem(java.lang.String name,
                    int sqlType,
                    int length)

PamTableItem

public PamTableItem(java.lang.String name,
                    int sqlType,
                    int length,
                    boolean required)
Method Detail

getLength

public int getLength()

setLength

public void setLength(int length)

getName

public java.lang.String getName()

setName

public void setName(java.lang.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 java.lang.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 java.lang.String getDeblankedStringValue()

setValue

public void setValue(java.lang.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(java.lang.String tableName,
                                          java.lang.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(java.lang.String tableName,
                                         java.lang.String columnName)
Searches all Pamguard datablocks and SQLLoggers for a named table and column for use in cross referencing.


getShortValue

public java.lang.Short getShortValue()

getIntegerValue

public int getIntegerValue()

getDoubleValue

public double getDoubleValue()

getBooleanValue

public boolean getBooleanValue()

getStringValue

public java.lang.String getStringValue()