Package generalDatabase
Class PamTableItem
java.lang.Object
generalDatabase.PamTableItem
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
EnhancedTableItem
,FormsTableItem
Defines a single item (column) for a Pamguard database table
These are listed in PamTableDefinition for each table.
- Author:
- Doug Gillespie
- See Also:
-
Constructor Summary
ConstructorDescriptionPamTableItem
(String name, int sqlType) Generate a table itemPamTableItem
(String name, int sqlType, int length) Generate a table itemPamTableItem
(String name, int sqlType, int length, boolean required) PamTableItem
(String name, int sqlType, int length, String description) Generate a table itemPamTableItem
(String name, int sqlType, String description) Generate a table item -
Method Summary
Modifier and TypeMethodDescriptionstatic PamTableItem
findTableItem
(String tableName, String columnName) Searches all Pamguard datablocks and SQLLoggers for a named table and column for use in cross referencing.boolean
Gets the cross reference item.double
float
Get a float value, being aware that some DBMS may have decided to store as a Double anyway.Return an Integer object, or null if the value is nullint
Returns an int, or 0 if the value is nullint
Database is clever and returns Longs as ints if they are amll enough and as Doubles if they are too big !long
getName()
Get the column name, any spaces in the name will be filled with underscore charactersGet the name with any spaces left in place.int
getValue()
Gets the most recently used value written to or read from the database.boolean
boolean
boolean
void
setCounter
(boolean isCounter) setCrossReferenceItem
(PamTableItem crossReferenceItem) Sets the cross reference item.setCrossReferenceItem
(String tableName, String columnName) Sets the cross reference item.void
setDescription
(String description) void
setLength
(int length) void
void
setPrimaryKey
(boolean primaryKey) void
setRequired
(boolean required) void
setSqlType
(int sqlType) void
Sets the value of data to be written to the database column.
-
Constructor Details
-
PamTableItem
Generate a table item- Parameters:
name
- name of table itemsqlType
- SQL Type from java.sql.Types, e.g. Types.INTEGER
-
PamTableItem
Generate a table item- Parameters:
name
- name of table itemsqlType
- SQL Type from java.sql.Types, e.g. Types.INTEGERdescription
- optional description
-
PamTableItem
Generate a table item- Parameters:
name
- name of table itemsqlType
- SQL Type from java.sql.Types, e.g. Types.INTEGERlength
- length (only applicable to Types.CHAR types)
-
PamTableItem
Generate a table item- Parameters:
name
- name of table itemsqlType
- SQL Type from java.sql.Types, e.g. Types.INTEGERlength
- length (only applicable to Types.CHAR types)description
- optional description
-
PamTableItem
-
-
Method Details
-
getLength
public int getLength() -
setLength
public void setLength(int length) -
getName
Get the column name, any spaces in the name will be filled with underscore characters- Returns:
- a deblanked name
-
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
-
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
Gets the most recently used value written to or read from the database.- Returns:
- data read from or written to the database column
-
getDeblankedStringValue
-
setValue
Sets the value of data to be written to the database column.- Parameters:
value
-
-
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
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
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 tocolumnName
- 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
Searches all Pamguard datablocks and SQLLoggers for a named table and column for use in cross referencing. -
getShortValue
-
getIntegerValue
public int getIntegerValue()Returns an int, or 0 if the value is null- Returns:
-
getIntegerObject
Return an Integer object, or null if the value is null- Returns:
-
getLongValue
public long getLongValue() -
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
-
getPackedValue
-
getDescription
- Returns:
- the description
-
setDescription
- Parameters:
description
- the description to set
-