org.opengts.dbtools
Class DBField

java.lang.Object
  extended by org.opengts.dbtools.DBField

public class DBField
extends java.lang.Object

DBField represents a specific field in an SQL table.


Field Summary
static char ALT_INDEX_SEPARATOR
           
static java.lang.String ATTR_ALTKEY
           
static java.lang.String ATTR_AUTO_INCR
           
static java.lang.String ATTR_EDIT
           
static java.lang.String ATTR_EDITOR
           
static java.lang.String ATTR_ENUM
           
static java.lang.String ATTR_FORMAT
           
static java.lang.String ATTR_KEY
           
static java.lang.String ATTR_MASK
           
static java.lang.String ATTR_OPTIONAL
           
static java.lang.String ATTR_PRESEP
           
static java.lang.String ATTR_REQUIRED
           
static java.lang.String ATTR_UNIQUE
           
static java.lang.String ATTR_UNITS
           
static java.lang.String ATTR_UPDATE
           
static java.lang.String ATTR_UTF8
           
static int EDIT_ADMIN
           
static int EDIT_NEVER
           
static int EDIT_NEW
           
static int EDIT_PUBLIC
           
static char ENUM_TYPE_SEPARATOR
           
static char ENUM_VALUE_SEPARATOR
           
static char MASK_TYPE_SEPARATOR
           
static char MASK_VALUE_SEPARATOR
           
static java.lang.String SQL_AUTO_INCREMENT
           
static java.lang.String SQL_NOT_NULL
           
static java.lang.String TYPE_BLOB
           
static java.lang.String TYPE_BOOLEAN
           
static java.lang.String TYPE_DATETIME
           
static java.lang.String TYPE_DOUBLE
           
static java.lang.String TYPE_FLOAT
           
static java.lang.String TYPE_INT16
           
static java.lang.String TYPE_INT32
           
static java.lang.String TYPE_INT64
           
static java.lang.String TYPE_INT8
           
static java.lang.String TYPE_MBLOB
           
static java.lang.String TYPE_SBLOB
           
static java.lang.String TYPE_STRING
           
static java.lang.String TYPE_TEXT
           
static java.lang.String TYPE_UINT16
           
static java.lang.String TYPE_UINT32
           
static java.lang.String TYPE_UINT64
           
static java.lang.String TYPE_UINT8
           
 
Constructor Summary
DBField(java.lang.String fldName, java.lang.Class javaClass, java.lang.String dataType, I18N.Text title, java.lang.String attr)
          Constructor.
DBField(java.lang.String fldName, java.lang.Class javaClass, java.lang.String dataType, java.lang.String title, java.lang.String attr)
          Constructor.
DBField(java.lang.String utableName, java.lang.String colName, java.lang.String sqlType, boolean autoIncr, java.lang.String charSet, java.util.Set<java.lang.String> indexNames)
          Constructor.
 
Method Summary
 java.lang.Object _getDefaultValue()
          Gets the explicitly defined default value for this field
protected  java.lang.StringBuffer _getIndexNames(java.lang.StringBuffer sb)
          Returns a String list of index names for this field (for display purposes only)
 java.lang.String _getName()
          Gets the untranslated field name
 boolean _hasDefaultValue()
          Returns true if an explicit default value has been defined for this field
static boolean AllowUpdateKeyFields()
          (EXPERIMENTAL) Support/Allow updating key fields.
 boolean equals(java.lang.Object other)
          Returns true if the specified object is equivalent to this DBField
 boolean equalsAlternateIndexes(java.lang.String[] altIndexes)
          Returns true if this field defines the specified alternate indexes
 java.lang.String formatValue(java.lang.Object val)
          Returns the specified value as a String formatted appropriately for this field type
 java.lang.String[] getAlternateIndexes()
          Gets an array of alternate key index names
 boolean getBooleanAttribute(java.lang.String key, boolean dft)
          Returns the boolean value of the specified attribute key
 java.lang.String getCharacterSet()
          Gets the column character set
 java.lang.String getDataType()
          Gets the data type for this field
 java.lang.Object getDefaultValue()
          Gets a default value for this field
 int getEditMode()
          Gets the edit mode for this field
 java.lang.String getEditor()
          Gets the field editor name
 java.lang.Class<? extends java.lang.Enum> getEnumClass()
          Return the defined Enum class type for this field
 OrderedMap<java.lang.String,java.lang.Integer> getEnumValues()
          Gets the map of the valid enumerated values for this field
 long getErrorCount()
          Return error count
 java.lang.String[] getExtraAlternateIndexes(java.lang.String[] altIndexes)
          Returns a subset of the current field alternate key names that are not in the specified list of alternate keys.
 DBFactory getFactory()
          Gets the parent table DBFactory for this field
 java.lang.String getFieldDefinition()
          Gets the SQL definition of this field (NOTE: does not contain character set information!)
 java.lang.Object getFieldValue(DBRecord rcd)
          Returns the field value from the specified DBRecord
 java.lang.String getFormat()
          Returns the 'format' String attribute
 java.lang.String getFormat(java.lang.String dft)
          Returns the 'format' String attribute
 java.lang.String getIndexNames()
          Returns a String list of index names for this field (for display purposes only)
 int getIntAttribute(java.lang.String key, int dft)
          Returns the integer value of the specified attribute key
 java.lang.Class<? extends java.lang.Enum> getMaskClass()
          Return the defined Enum bitmask class type for this field
 OrderedMap<java.lang.String,java.lang.Long> getMaskValues()
          Gets the map of the valid enumerated values for this field
 java.lang.String[] getMissingAlternateIndexes(java.lang.String[] altIndexes)
          Returns a subset of the specified alternate key names that are not alternate key indices of the current field.
 java.lang.String getName()
          Gets the translated field name (as translated to the actual DB column name)
 java.lang.String getQValue(java.lang.Object v)
          Returns a quoted String value for the specified object
 java.lang.Object getResultSetValue(java.sql.ResultSet rs)
          Extracts and returns the value for this field from the specified ResultSet
 java.lang.String getSqlType()
          Gets the SQL type for this field
 java.lang.String getSqlType(boolean inclNotNull)
          Gets the SQL type for this field
 java.lang.String getStringAttribute(java.lang.String key, java.lang.String dft)
          Returns the String value of the specified attribute key
 int getStringLength()
          Gets the String length of this field, or '0' if the field is not a String
 I18N.Text getTitle()
          Gets the I18N title for this field
 java.lang.String getTitle(java.util.Locale locale)
          Returns the 'title' String attribute
 java.lang.Class getTypeClass()
          Gets the Java class for this field
 int getTypeMask()
          Gets the type mask for this field
 boolean hasAttribute(java.lang.String key)
          Returns true if this field contains the specified attribute
 boolean hasExtraAlternateIndexes(java.lang.String[] altIndexes)
          Returns true if the current field has additional alternate key fields not in the specified list.
 boolean hasMissingAlternateIndexes(java.lang.String[] altIndexes)
          Returns true if any alternate key name in the specified list is missing from the alternate keys in the current field.
static boolean IgnoreColumnError(java.lang.String table, java.lang.String column)
          Return true if column errors for the specified table.column should be ignored.
 long incrementErrorCount()
          Increment/return error count
 boolean isAlternateKey()
          Returns true if this field is an alternate index key
 boolean isAutoIncrement()
          Returns true if this field is "auto_increment"
 boolean isBinary()
          Returns true if this is a binary (blob) field
 boolean isBLOB()
          Returns true if this field type is binary/BLOB
 boolean isBoolean()
          Returns true if this is a boolean field
 boolean isCLOB()
          Returns true if this field type is TEXT/CLOB
 boolean isDecimal()
          Returns true if this is a decimal (floating point) field
 boolean isDefaultValue(java.lang.Object val)
          Returns true if the specified value matches a default value (currently, there can be only one default value)
 boolean isEditable(int mode)
          Returns true if this field is editable for the specified mode
 boolean isKeyField()
          Returns true if this is a key field (either primary or alternate)
 boolean isNumeric()
          Returns true if this is a numeric field (ie.
 boolean isPrimaryKey()
          Returns true if this field is a primary key
 boolean isRequired()
          Returns true if this field is required
 boolean isSqlField()
          Returns true if this field was loaded from the actual table columns
 boolean isString()
          Returns true if this is a String field
 boolean isTypeBLOB()
          Returns true if this field is a Byte[] type.
 boolean isTypeBoolean()
          Returns true if this field is a Boolean type.
 boolean isTypeDateTime()
          Returns true if this field is a DateTime type.
 boolean isTypeDouble()
          Returns true if this field is a Double type.
 boolean isTypeFloat()
          Returns true if this field is a Float type.
 boolean isTypeInteger()
          Returns true if this field is a Integer type.
 boolean isTypeLong()
          Returns true if this field is a Long type.
 boolean isTypeMatch()
          Returns true if this field matches the defined table field
(only meaningful for fields read from the actual table columns)
 boolean isTypeString()
          Returns true if this field is a String type.
 boolean isUniqueAltKey()
          Returns true if this field is a unique key
 boolean isUnsigned()
          Returns true if this is an unsigned integer field
 boolean isUpdateAllowed()
          Returns true if this field is allowed to be updated
 boolean isUTF8()
          Returns true if this field is defined as character set UTF8
static void main(java.lang.String[] argv)
           
static byte[] parseBlobString(java.lang.String val)
          Parses and returns a BLOB (byte[]) representation of the String value
static byte[] parseBlobString(java.lang.String val, byte[] dftBlob)
          Parses and returns a BLOB (byte[]) representation of the String value
 java.lang.Object parseStringValue(java.lang.String val)
          Parses the specified String and returns an Object appropriate for this field data type
static java.lang.String quote(java.lang.String s)
          Quotes and returns the specified String
static java.lang.String quote(java.lang.String s, char q, boolean escapeQuote)
          Quotes and returns the specified String
 boolean quoteValue()
          Returns true if values represented by this field data type must be quoted
 void setDataType(java.lang.String dataType)
          Sets the data type for this field.
(Allowed only for 'defined' fields)
 void setDefaultValue(java.lang.Object val)
          Sets a default value for this field Note: The data type of the specified default value is assumed to be correct for this field type.
 void setEditMode(int mode)
          Sets the edit mode for this field
 void setFactory(DBFactory factory)
          Sets the parent table DBFactory for this field
 void setFormat(java.lang.String format)
          Sets the 'format' String attribute
 void setTitle(I18N.Text title)
          Sets the I18N title for this field
 java.lang.String toString()
          Returns a String representation of this field (for display purposes only)
static java.lang.String TYPE_ACCT_ID()
           
static java.lang.String TYPE_ADDRESS()
           
static java.lang.String TYPE_CORR_ID()
           
static java.lang.String TYPE_DESC()
           
static java.lang.String TYPE_DEV_ID()
           
static java.lang.String TYPE_DRIVER_ID()
           
static java.lang.String TYPE_EMAIL_LIST()
           
static java.lang.String TYPE_ENTITY_ID()
           
static java.lang.String TYPE_GROUP_ID()
           
static java.lang.String TYPE_ID()
           
static java.lang.String TYPE_INT(java.lang.String i)
           
static java.lang.String TYPE_INT(java.lang.String T, java.lang.String I)
           
static java.lang.String TYPE_POI_ID()
           
static java.lang.String TYPE_PROP_ID()
           
static java.lang.String TYPE_ROLE_ID()
           
static java.lang.String TYPE_RULE_ID()
           
static java.lang.String TYPE_STOP_INDEX()
           
static java.lang.String TYPE_STRING(int n)
           
static java.lang.String TYPE_STRING(java.lang.String T, int D)
           
static java.lang.String TYPE_UNIQ_ID()
           
static java.lang.String TYPE_USER_ID()
           
static java.lang.String TYPE_XPORT_ID()
           
static java.lang.String TYPE_ZONE_ID()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_BOOLEAN

public static final java.lang.String TYPE_BOOLEAN
See Also:
Constant Field Values

TYPE_INT8

public static final java.lang.String TYPE_INT8
See Also:
Constant Field Values

TYPE_UINT8

public static final java.lang.String TYPE_UINT8
See Also:
Constant Field Values

TYPE_INT16

public static final java.lang.String TYPE_INT16
See Also:
Constant Field Values

TYPE_UINT16

public static final java.lang.String TYPE_UINT16
See Also:
Constant Field Values

TYPE_INT32

public static final java.lang.String TYPE_INT32
See Also:
Constant Field Values

TYPE_UINT32

public static final java.lang.String TYPE_UINT32
See Also:
Constant Field Values

TYPE_INT64

public static final java.lang.String TYPE_INT64
See Also:
Constant Field Values

TYPE_UINT64

public static final java.lang.String TYPE_UINT64
See Also:
Constant Field Values

TYPE_FLOAT

public static final java.lang.String TYPE_FLOAT
See Also:
Constant Field Values

TYPE_DOUBLE

public static final java.lang.String TYPE_DOUBLE
See Also:
Constant Field Values

TYPE_SBLOB

public static final java.lang.String TYPE_SBLOB
See Also:
Constant Field Values

TYPE_BLOB

public static final java.lang.String TYPE_BLOB
See Also:
Constant Field Values

TYPE_MBLOB

public static final java.lang.String TYPE_MBLOB
See Also:
Constant Field Values

TYPE_TEXT

public static final java.lang.String TYPE_TEXT
See Also:
Constant Field Values

TYPE_STRING

public static final java.lang.String TYPE_STRING
See Also:
Constant Field Values

TYPE_DATETIME

public static final java.lang.String TYPE_DATETIME
See Also:
Constant Field Values

SQL_AUTO_INCREMENT

public static final java.lang.String SQL_AUTO_INCREMENT
See Also:
Constant Field Values

SQL_NOT_NULL

public static final java.lang.String SQL_NOT_NULL
See Also:
Constant Field Values

EDIT_NEVER

public static final int EDIT_NEVER
See Also:
Constant Field Values

EDIT_NEW

public static final int EDIT_NEW
See Also:
Constant Field Values

EDIT_ADMIN

public static final int EDIT_ADMIN
See Also:
Constant Field Values

EDIT_PUBLIC

public static final int EDIT_PUBLIC
See Also:
Constant Field Values

ATTR_KEY

public static final java.lang.String ATTR_KEY
See Also:
Constant Field Values

ATTR_UNIQUE

public static final java.lang.String ATTR_UNIQUE
See Also:
Constant Field Values

ATTR_ALTKEY

public static final java.lang.String ATTR_ALTKEY
See Also:
Constant Field Values

ATTR_OPTIONAL

public static final java.lang.String ATTR_OPTIONAL
See Also:
Constant Field Values

ATTR_REQUIRED

public static final java.lang.String ATTR_REQUIRED
See Also:
Constant Field Values

ATTR_EDIT

public static final java.lang.String ATTR_EDIT
See Also:
Constant Field Values

ATTR_FORMAT

public static final java.lang.String ATTR_FORMAT
See Also:
Constant Field Values

ATTR_ENUM

public static final java.lang.String ATTR_ENUM
See Also:
Constant Field Values

ATTR_MASK

public static final java.lang.String ATTR_MASK
See Also:
Constant Field Values

ATTR_EDITOR

public static final java.lang.String ATTR_EDITOR
See Also:
Constant Field Values

ATTR_PRESEP

public static final java.lang.String ATTR_PRESEP
See Also:
Constant Field Values

ATTR_UPDATE

public static final java.lang.String ATTR_UPDATE
See Also:
Constant Field Values

ATTR_UTF8

public static final java.lang.String ATTR_UTF8
See Also:
Constant Field Values

ATTR_AUTO_INCR

public static final java.lang.String ATTR_AUTO_INCR
See Also:
Constant Field Values

ATTR_UNITS

public static final java.lang.String ATTR_UNITS
See Also:
Constant Field Values

ENUM_TYPE_SEPARATOR

public static final char ENUM_TYPE_SEPARATOR
See Also:
Constant Field Values

ENUM_VALUE_SEPARATOR

public static final char ENUM_VALUE_SEPARATOR
See Also:
Constant Field Values

MASK_TYPE_SEPARATOR

public static final char MASK_TYPE_SEPARATOR
See Also:
Constant Field Values

MASK_VALUE_SEPARATOR

public static final char MASK_VALUE_SEPARATOR
See Also:
Constant Field Values

ALT_INDEX_SEPARATOR

public static final char ALT_INDEX_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

DBField

public DBField(java.lang.String utableName,
               java.lang.String colName,
               java.lang.String sqlType,
               boolean autoIncr,
               java.lang.String charSet,
               java.util.Set<java.lang.String> indexNames)
Constructor. Used only by 'DBFactory.getExistingColumns' to load actual tables columns.

Parameters:
utableName - The untranslated name of the table containing this field
colName - The name of this field column
sqlType - The SQL field type
indexNames - A set of index names for this field (may include "PRIMARY")

DBField

public DBField(java.lang.String fldName,
               java.lang.Class javaClass,
               java.lang.String dataType,
               java.lang.String title,
               java.lang.String attr)
Constructor. Used within table definition modules to define fileds/columns.
The file attribute list should specify a String containing a list of "key=value" properties. The following attribute/property keys may be specified:

Parameters:
fldName - The field name
javaClass - The Java class representation of this field
dataType - The field SQL data type
title - The displayed field title
attr - The field attribute list

DBField

public DBField(java.lang.String fldName,
               java.lang.Class javaClass,
               java.lang.String dataType,
               I18N.Text title,
               java.lang.String attr)
Constructor. Used within table definition modules to define fileds/columns.
The file attribute list should specify a String containing a list of "key=value" properties. The following attribute/property keys may be specified:

Parameters:
fldName - The field name
javaClass - The Java class representation of this field
dataType - The field SQL data type
title - The displayed field title
attr - The field attribute list
Method Detail

TYPE_STRING

public static java.lang.String TYPE_STRING(int n)

TYPE_STRING

public static java.lang.String TYPE_STRING(java.lang.String T,
                                           int D)

TYPE_ID

public static java.lang.String TYPE_ID()

TYPE_ACCT_ID

public static java.lang.String TYPE_ACCT_ID()

TYPE_USER_ID

public static java.lang.String TYPE_USER_ID()

TYPE_DEV_ID

public static java.lang.String TYPE_DEV_ID()

TYPE_XPORT_ID

public static java.lang.String TYPE_XPORT_ID()

TYPE_GROUP_ID

public static java.lang.String TYPE_GROUP_ID()

TYPE_ROLE_ID

public static java.lang.String TYPE_ROLE_ID()

TYPE_RULE_ID

public static java.lang.String TYPE_RULE_ID()

TYPE_CORR_ID

public static java.lang.String TYPE_CORR_ID()

TYPE_DRIVER_ID

public static java.lang.String TYPE_DRIVER_ID()

TYPE_ENTITY_ID

public static java.lang.String TYPE_ENTITY_ID()

TYPE_ZONE_ID

public static java.lang.String TYPE_ZONE_ID()

TYPE_POI_ID

public static java.lang.String TYPE_POI_ID()

TYPE_PROP_ID

public static java.lang.String TYPE_PROP_ID()

TYPE_ADDRESS

public static java.lang.String TYPE_ADDRESS()

TYPE_EMAIL_LIST

public static java.lang.String TYPE_EMAIL_LIST()

TYPE_UNIQ_ID

public static java.lang.String TYPE_UNIQ_ID()

TYPE_DESC

public static java.lang.String TYPE_DESC()

TYPE_INT

public static java.lang.String TYPE_INT(java.lang.String i)

TYPE_INT

public static java.lang.String TYPE_INT(java.lang.String T,
                                        java.lang.String I)

TYPE_STOP_INDEX

public static java.lang.String TYPE_STOP_INDEX()

quote

public static java.lang.String quote(java.lang.String s)
Quotes and returns the specified String

Parameters:
s - The String to quote
Returns:
The quoted String

quote

public static java.lang.String quote(java.lang.String s,
                                     char q,
                                     boolean escapeQuote)
Quotes and returns the specified String

Parameters:
s - The String to quote
q - The quote character (either ' or ")
escapeQuote - True to include embedded quotes with \", false to include embedded quotes with ""
Returns:
The quoted String

AllowUpdateKeyFields

public static boolean AllowUpdateKeyFields()
(EXPERIMENTAL) Support/Allow updating key fields.


IgnoreColumnError

public static boolean IgnoreColumnError(java.lang.String table,
                                        java.lang.String column)
Return true if column errors for the specified table.column should be ignored. Useful for eliminating column "not found" errors in tables where the specific column should not be included.
Example:
db.ignoreColumnError.EventData.malfunctionLamp=true

Parameters:
table - The table name
column - The column name
Returns:
True to ignore any column errors, false otherwise.

setFactory

public void setFactory(DBFactory factory)
Sets the parent table DBFactory for this field

Parameters:
factory - The parent DBFactory instance

getFactory

public DBFactory getFactory()
Gets the parent table DBFactory for this field

Returns:
The parent DBFactory instance

getTypeClass

public java.lang.Class getTypeClass()
Gets the Java class for this field

Returns:
The Java class for this field

isTypeString

public boolean isTypeString()
Returns true if this field is a String type.

Returns:
True if this field is a String type.

isTypeInteger

public boolean isTypeInteger()
Returns true if this field is a Integer type.

Returns:
True if this field is a Integer type.

isTypeLong

public boolean isTypeLong()
Returns true if this field is a Long type.

Returns:
True if this field is a Long type.

isTypeFloat

public boolean isTypeFloat()
Returns true if this field is a Float type.

Returns:
True if this field is a Float type.

isTypeDouble

public boolean isTypeDouble()
Returns true if this field is a Double type.

Returns:
True if this field is a Double type.

isTypeBoolean

public boolean isTypeBoolean()
Returns true if this field is a Boolean type.

Returns:
True if this field is a Boolean type.

isTypeBLOB

public boolean isTypeBLOB()
Returns true if this field is a Byte[] type.

Returns:
True if this field is a Byte[] type.

isTypeDateTime

public boolean isTypeDateTime()
Returns true if this field is a DateTime type.

Returns:
True if this field is a DateTime type.

isAutoIncrement

public boolean isAutoIncrement()
Returns true if this field is "auto_increment"

Returns:
True if this field is "auto_increment"

isRequired

public boolean isRequired()
Returns true if this field is required

Returns:
True if this field is required

getCharacterSet

public java.lang.String getCharacterSet()
Gets the column character set

Returns:
The column character set

isUTF8

public boolean isUTF8()
Returns true if this field is defined as character set UTF8

Returns:
True if this field is defined as character set UTF8

isPrimaryKey

public boolean isPrimaryKey()
Returns true if this field is a primary key

Returns:
True if this field is a primary key

isKeyField

public boolean isKeyField()
Returns true if this is a key field (either primary or alternate)

Returns:
True if this is a key field

isAlternateKey

public boolean isAlternateKey()
Returns true if this field is an alternate index key

Returns:
True if this field is an alternate index key

isUniqueAltKey

public boolean isUniqueAltKey()
Returns true if this field is a unique key

Returns:
True if this field is a unique key

getAlternateIndexes

public java.lang.String[] getAlternateIndexes()
Gets an array of alternate key index names

Returns:
An array of alternate key index names, or null if this field has not alternate keys

equalsAlternateIndexes

public boolean equalsAlternateIndexes(java.lang.String[] altIndexes)
Returns true if this field defines the specified alternate indexes

Parameters:
altIndexes - The list of alternate indexes to check
Returns:
True if this field defines the specified alternate indexes

hasMissingAlternateIndexes

public boolean hasMissingAlternateIndexes(java.lang.String[] altIndexes)
Returns true if any alternate key name in the specified list is missing from the alternate keys in the current field.

Parameters:
altIndexes - The list of alternate indexes to check
Returns:
True if any alternate key name in the specified list is missing from the alternate keys in the current field.

getMissingAlternateIndexes

public java.lang.String[] getMissingAlternateIndexes(java.lang.String[] altIndexes)
Returns a subset of the specified alternate key names that are not alternate key indices of the current field.

Parameters:
altIndexes - The list of alternate indexes to check
Returns:
The subset of specified alternate key index names that are not alternate keys of this field, or null if no missing alternate key indexes found.

hasExtraAlternateIndexes

public boolean hasExtraAlternateIndexes(java.lang.String[] altIndexes)
Returns true if the current field has additional alternate key fields not in the specified list.

Parameters:
altIndexes - The list of alternate indexes to check
Returns:
True if the current field has additional alternate key fields.

getExtraAlternateIndexes

public java.lang.String[] getExtraAlternateIndexes(java.lang.String[] altIndexes)
Returns a subset of the current field alternate key names that are not in the specified list of alternate keys.

Parameters:
altIndexes - The list of alternate indexes to check
Returns:
The subset of the current field alternate key names that are not in the specified list of alternate keys.

isUpdateAllowed

public boolean isUpdateAllowed()
Returns true if this field is allowed to be updated

Returns:
True if this field is allowed to be updated

isSqlField

public boolean isSqlField()
Returns true if this field was loaded from the actual table columns

Returns:
True if this field was loaded from the actual table columns

getTypeMask

public int getTypeMask()
Gets the type mask for this field

Returns:
The type mask for this field

isBoolean

public boolean isBoolean()
Returns true if this is a boolean field

Returns:
True if this is a boolean field

isNumeric

public boolean isNumeric()
Returns true if this is a numeric field (ie. decimal, unsigned, etc)

Returns:
True if this is a numeric field

isDecimal

public boolean isDecimal()
Returns true if this is a decimal (floating point) field

Returns:
True if this is a decimal field

isUnsigned

public boolean isUnsigned()
Returns true if this is an unsigned integer field

Returns:
True if this is an unsigned integer field

isString

public boolean isString()
Returns true if this is a String field

Returns:
True if this is a String field

isBinary

public boolean isBinary()
Returns true if this is a binary (blob) field

Returns:
True if this is a binary field

setDataType

public void setDataType(java.lang.String dataType)
Sets the data type for this field.
(Allowed only for 'defined' fields)

Parameters:
dataType - The field data type

getDataType

public java.lang.String getDataType()
Gets the data type for this field

Returns:
The field data type

isTypeMatch

public boolean isTypeMatch()
Returns true if this field matches the defined table field
(only meaningful for fields read from the actual table columns)

Returns:
True if this field matches the defined table field

getSqlType

public java.lang.String getSqlType()
Gets the SQL type for this field

Returns:
The SQL type for this field

getSqlType

public java.lang.String getSqlType(boolean inclNotNull)
Gets the SQL type for this field

Parameters:
inclNotNull - True to include "NOT NULL" specification, false to strip this specification
Returns:
The SQL type for this field

getStringLength

public int getStringLength()
Gets the String length of this field, or '0' if the field is not a String

Returns:
The length of the String field

isCLOB

public boolean isCLOB()
Returns true if this field type is TEXT/CLOB

Returns:
True if this field type is TEXT/CLOB

isBLOB

public boolean isBLOB()
Returns true if this field type is binary/BLOB

Returns:
True if this field type is binary/BLOB

parseBlobString

public static byte[] parseBlobString(java.lang.String val)
Parses and returns a BLOB (byte[]) representation of the String value

Parameters:
val - The String value to parse
Returns:
The BLOB/byte[] representation

parseBlobString

public static byte[] parseBlobString(java.lang.String val,
                                     byte[] dftBlob)
Parses and returns a BLOB (byte[]) representation of the String value

Parameters:
val - The String value to parse
dftBlob - The default value returned if the String cannot be parsed
Returns:
The BLOB/byte[] representation

getResultSetValue

public java.lang.Object getResultSetValue(java.sql.ResultSet rs)
                                   throws java.sql.SQLException
Extracts and returns the value for this field from the specified ResultSet

Parameters:
rs - The ResultSet from which the value is extracted
Returns:
The extracted value for this field
Throws:
java.sql.SQLException

getFieldValue

public java.lang.Object getFieldValue(DBRecord rcd)
Returns the field value from the specified DBRecord

Parameters:
rcd - The DBRecord from which the value is returned
Returns:
The returned value for this field

parseStringValue

public java.lang.Object parseStringValue(java.lang.String val)
Parses the specified String and returns an Object appropriate for this field data type

Parameters:
val - The String value to parse
Returns:
An Object value appropriate for this field data type

setDefaultValue

public void setDefaultValue(java.lang.Object val)
Sets a default value for this field Note: The data type of the specified default value is assumed to be correct for this field type.

Parameters:
val - The default value

_hasDefaultValue

public boolean _hasDefaultValue()
Returns true if an explicit default value has been defined for this field

Returns:
True if an explicit default value has been defined for this field

_getDefaultValue

public java.lang.Object _getDefaultValue()
Gets the explicitly defined default value for this field

Returns:
The explicitly defined default field value

getDefaultValue

public java.lang.Object getDefaultValue()
Gets a default value for this field

Returns:
A default field value

isDefaultValue

public boolean isDefaultValue(java.lang.Object val)
Returns true if the specified value matches a default value (currently, there can be only one default value)

Returns:
True if the specified value matches a default value

quoteValue

public boolean quoteValue()
Returns true if values represented by this field data type must be quoted

Returns:
True if values represented by this field data type must be quoted

getQValue

public java.lang.String getQValue(java.lang.Object v)
Returns a quoted String value for the specified object

Parameters:
v - The Object to quote
Returns:
The quoted String value

hasAttribute

public boolean hasAttribute(java.lang.String key)
Returns true if this field contains the specified attribute

Parameters:
key - The attribute key
Returns:
True if this field contains the specified attribute

getBooleanAttribute

public boolean getBooleanAttribute(java.lang.String key,
                                   boolean dft)
Returns the boolean value of the specified attribute key

Parameters:
key - The attribute key
dft - The default boolean value if the attribute key does not exist
Returns:
The boolean value of the specified attribute key

getIntAttribute

public int getIntAttribute(java.lang.String key,
                           int dft)
Returns the integer value of the specified attribute key

Parameters:
key - The attribute key
dft - The default integer value if the attribute key does not exist
Returns:
The integer value of the specified attribute key

getStringAttribute

public java.lang.String getStringAttribute(java.lang.String key,
                                           java.lang.String dft)
Returns the String value of the specified attribute key

Parameters:
key - The attribute key
dft - The default 'String' if the attribute key is not defined
Returns:
The String value of the specified attribute key

setFormat

public void setFormat(java.lang.String format)
Sets the 'format' String attribute

Parameters:
format - The 'format' String attribute

getFormat

public java.lang.String getFormat()
Returns the 'format' String attribute

Returns:
The 'format' String attribute

getFormat

public java.lang.String getFormat(java.lang.String dft)
Returns the 'format' String attribute

Parameters:
dft - The default 'format' returned if undefined
Returns:
The 'format' String attribute

formatValue

public java.lang.String formatValue(java.lang.Object val)
Returns the specified value as a String formatted appropriately for this field type

Parameters:
val - The value to format
Returns:
The formated value

equals

public boolean equals(java.lang.Object other)
Returns true if the specified object is equivalent to this DBField

Overrides:
equals in class java.lang.Object
Returns:
True if the specified object is equivalent to this DBField

_getName

public java.lang.String _getName()
Gets the untranslated field name

Returns:
The field name

getName

public java.lang.String getName()
Gets the translated field name (as translated to the actual DB column name)

Returns:
The field name

getFieldDefinition

public java.lang.String getFieldDefinition()
Gets the SQL definition of this field (NOTE: does not contain character set information!)

Returns:
The SQL definition of this field

toString

public java.lang.String toString()
Returns a String representation of this field (for display purposes only)

Overrides:
toString in class java.lang.Object
Returns:
A String representation of this field

getIndexNames

public java.lang.String getIndexNames()
Returns a String list of index names for this field (for display purposes only)

Returns:
A String list of index names for this field

_getIndexNames

protected java.lang.StringBuffer _getIndexNames(java.lang.StringBuffer sb)
Returns a String list of index names for this field (for display purposes only)

Parameters:
sb - The StringBuffer where the index names will be placed
Returns:
The StringBuffer where the index names were placed

setTitle

public void setTitle(I18N.Text title)
Sets the I18N title for this field

Parameters:
title - The I18N title for this field

getTitle

public I18N.Text getTitle()
Gets the I18N title for this field

Returns:
The I18N title for this field

getTitle

public java.lang.String getTitle(java.util.Locale locale)
Returns the 'title' String attribute

Parameters:
locale - The Locale used for Localization purposes
Returns:
The 'title' String attribute

setEditMode

public void setEditMode(int mode)
Sets the edit mode for this field

Parameters:
mode - The edit mode for this field

getEditMode

public int getEditMode()
Gets the edit mode for this field

Returns:
The edit mode for this field

isEditable

public boolean isEditable(int mode)
Returns true if this field is editable for the specified mode

Parameters:
mode - The edit mode
Returns:
True if this field is editable for the specified mode

getEditor

public java.lang.String getEditor()
Gets the field editor name

Returns:
The field editor name

getEnumClass

public java.lang.Class<? extends java.lang.Enum> getEnumClass()
Return the defined Enum class type for this field

Returns:
The Enum class defined for this field

getEnumValues

public OrderedMap<java.lang.String,java.lang.Integer> getEnumValues()
Gets the map of the valid enumerated values for this field

Returns:
The map of the valid enumerated values for this field, or null if undefined

getMaskClass

public java.lang.Class<? extends java.lang.Enum> getMaskClass()
Return the defined Enum bitmask class type for this field

Returns:
The Enum bitmask class defined for this field

getMaskValues

public OrderedMap<java.lang.String,java.lang.Long> getMaskValues()
Gets the map of the valid enumerated values for this field

Returns:
The map of the valid enumerated values for this field, or null if undefined

incrementErrorCount

public long incrementErrorCount()
Increment/return error count

Returns:
current error count

getErrorCount

public long getErrorCount()
Return error count

Returns:
current error count

main

public static void main(java.lang.String[] argv)