|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opengts.dbtools.DBField
public class DBField
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 |
---|
public static final java.lang.String TYPE_BOOLEAN
public static final java.lang.String TYPE_INT8
public static final java.lang.String TYPE_UINT8
public static final java.lang.String TYPE_INT16
public static final java.lang.String TYPE_UINT16
public static final java.lang.String TYPE_INT32
public static final java.lang.String TYPE_UINT32
public static final java.lang.String TYPE_INT64
public static final java.lang.String TYPE_UINT64
public static final java.lang.String TYPE_FLOAT
public static final java.lang.String TYPE_DOUBLE
public static final java.lang.String TYPE_SBLOB
public static final java.lang.String TYPE_BLOB
public static final java.lang.String TYPE_MBLOB
public static final java.lang.String TYPE_TEXT
public static final java.lang.String TYPE_STRING
public static final java.lang.String TYPE_DATETIME
public static final java.lang.String SQL_AUTO_INCREMENT
public static final java.lang.String SQL_NOT_NULL
public static final int EDIT_NEVER
public static final int EDIT_NEW
public static final int EDIT_ADMIN
public static final int EDIT_PUBLIC
public static final java.lang.String ATTR_KEY
public static final java.lang.String ATTR_UNIQUE
public static final java.lang.String ATTR_ALTKEY
public static final java.lang.String ATTR_OPTIONAL
public static final java.lang.String ATTR_REQUIRED
public static final java.lang.String ATTR_EDIT
public static final java.lang.String ATTR_FORMAT
public static final java.lang.String ATTR_ENUM
public static final java.lang.String ATTR_MASK
public static final java.lang.String ATTR_EDITOR
public static final java.lang.String ATTR_PRESEP
public static final java.lang.String ATTR_UPDATE
public static final java.lang.String ATTR_UTF8
public static final java.lang.String ATTR_AUTO_INCR
public static final java.lang.String ATTR_UNITS
public static final char ENUM_TYPE_SEPARATOR
public static final char ENUM_VALUE_SEPARATOR
public static final char MASK_TYPE_SEPARATOR
public static final char MASK_VALUE_SEPARATOR
public static final char ALT_INDEX_SEPARATOR
Constructor Detail |
---|
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)
utableName
- The untranslated name of the table containing this fieldcolName
- The name of this field columnsqlType
- The SQL field typeindexNames
- A set of index names for this field (may include "PRIMARY")public DBField(java.lang.String fldName, java.lang.Class javaClass, java.lang.String dataType, java.lang.String title, java.lang.String attr)
fldName
- The field namejavaClass
- The Java class representation of this fielddataType
- The field SQL data typetitle
- The displayed field titleattr
- The field attribute listpublic DBField(java.lang.String fldName, java.lang.Class javaClass, java.lang.String dataType, I18N.Text title, java.lang.String attr)
fldName
- The field namejavaClass
- The Java class representation of this fielddataType
- The field SQL data typetitle
- The displayed field titleattr
- The field attribute listMethod Detail |
---|
public static java.lang.String TYPE_STRING(int n)
public static java.lang.String TYPE_STRING(java.lang.String T, int D)
public static java.lang.String TYPE_ID()
public static java.lang.String TYPE_ACCT_ID()
public static java.lang.String TYPE_USER_ID()
public static java.lang.String TYPE_DEV_ID()
public static java.lang.String TYPE_XPORT_ID()
public static java.lang.String TYPE_GROUP_ID()
public static java.lang.String TYPE_ROLE_ID()
public static java.lang.String TYPE_RULE_ID()
public static java.lang.String TYPE_CORR_ID()
public static java.lang.String TYPE_DRIVER_ID()
public static java.lang.String TYPE_ENTITY_ID()
public static java.lang.String TYPE_ZONE_ID()
public static java.lang.String TYPE_POI_ID()
public static java.lang.String TYPE_PROP_ID()
public static java.lang.String TYPE_ADDRESS()
public static java.lang.String TYPE_EMAIL_LIST()
public static java.lang.String TYPE_UNIQ_ID()
public static java.lang.String TYPE_DESC()
public static java.lang.String TYPE_INT(java.lang.String i)
public static java.lang.String TYPE_INT(java.lang.String T, java.lang.String I)
public static java.lang.String TYPE_STOP_INDEX()
public static java.lang.String quote(java.lang.String s)
s
- The String to quote
public static java.lang.String quote(java.lang.String s, char q, boolean escapeQuote)
s
- The String to quoteq
- The quote character (either ' or ")escapeQuote
- True to include embedded quotes with \", false to include embedded quotes with ""
public static boolean AllowUpdateKeyFields()
public static boolean IgnoreColumnError(java.lang.String table, java.lang.String column)
table
- The table namecolumn
- The column name
public void setFactory(DBFactory factory)
factory
- The parent DBFactory instancepublic DBFactory getFactory()
public java.lang.Class getTypeClass()
public boolean isTypeString()
public boolean isTypeInteger()
public boolean isTypeLong()
public boolean isTypeFloat()
public boolean isTypeDouble()
public boolean isTypeBoolean()
public boolean isTypeBLOB()
public boolean isTypeDateTime()
public boolean isAutoIncrement()
public boolean isRequired()
public java.lang.String getCharacterSet()
public boolean isUTF8()
public boolean isPrimaryKey()
public boolean isKeyField()
public boolean isAlternateKey()
public boolean isUniqueAltKey()
public java.lang.String[] getAlternateIndexes()
public boolean equalsAlternateIndexes(java.lang.String[] altIndexes)
altIndexes
- The list of alternate indexes to check
public boolean hasMissingAlternateIndexes(java.lang.String[] altIndexes)
altIndexes
- The list of alternate indexes to check
public java.lang.String[] getMissingAlternateIndexes(java.lang.String[] altIndexes)
altIndexes
- The list of alternate indexes to check
public boolean hasExtraAlternateIndexes(java.lang.String[] altIndexes)
altIndexes
- The list of alternate indexes to check
public java.lang.String[] getExtraAlternateIndexes(java.lang.String[] altIndexes)
altIndexes
- The list of alternate indexes to check
public boolean isUpdateAllowed()
public boolean isSqlField()
public int getTypeMask()
public boolean isBoolean()
public boolean isNumeric()
public boolean isDecimal()
public boolean isUnsigned()
public boolean isString()
public boolean isBinary()
public void setDataType(java.lang.String dataType)
dataType
- The field data typepublic java.lang.String getDataType()
public boolean isTypeMatch()
public java.lang.String getSqlType()
public java.lang.String getSqlType(boolean inclNotNull)
inclNotNull
- True to include "NOT NULL" specification, false to strip this specification
public int getStringLength()
public boolean isCLOB()
public boolean isBLOB()
public static byte[] parseBlobString(java.lang.String val)
val
- The String value to parse
public static byte[] parseBlobString(java.lang.String val, byte[] dftBlob)
val
- The String value to parsedftBlob
- The default value returned if the String cannot be parsed
public java.lang.Object getResultSetValue(java.sql.ResultSet rs) throws java.sql.SQLException
rs
- The ResultSet from which the value is extracted
java.sql.SQLException
public java.lang.Object getFieldValue(DBRecord rcd)
rcd
- The DBRecord from which the value is returned
public java.lang.Object parseStringValue(java.lang.String val)
val
- The String value to parse
public void setDefaultValue(java.lang.Object val)
val
- The default valuepublic boolean _hasDefaultValue()
public java.lang.Object _getDefaultValue()
public java.lang.Object getDefaultValue()
public boolean isDefaultValue(java.lang.Object val)
public boolean quoteValue()
public java.lang.String getQValue(java.lang.Object v)
v
- The Object to quote
public boolean hasAttribute(java.lang.String key)
key
- The attribute key
public boolean getBooleanAttribute(java.lang.String key, boolean dft)
key
- The attribute keydft
- The default boolean value if the attribute key does not exist
public int getIntAttribute(java.lang.String key, int dft)
key
- The attribute keydft
- The default integer value if the attribute key does not exist
public java.lang.String getStringAttribute(java.lang.String key, java.lang.String dft)
key
- The attribute keydft
- The default 'String' if the attribute key is not defined
public void setFormat(java.lang.String format)
format
- The 'format' String attributepublic java.lang.String getFormat()
public java.lang.String getFormat(java.lang.String dft)
dft
- The default 'format' returned if undefined
public java.lang.String formatValue(java.lang.Object val)
val
- The value to format
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public java.lang.String _getName()
public java.lang.String getName()
public java.lang.String getFieldDefinition()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getIndexNames()
protected java.lang.StringBuffer _getIndexNames(java.lang.StringBuffer sb)
sb
- The StringBuffer where the index names will be placed
public void setTitle(I18N.Text title)
title
- The I18N title for this fieldpublic I18N.Text getTitle()
public java.lang.String getTitle(java.util.Locale locale)
locale
- The Locale used for Localization purposes
public void setEditMode(int mode)
mode
- The edit mode for this fieldpublic int getEditMode()
public boolean isEditable(int mode)
mode
- The edit mode
public java.lang.String getEditor()
public java.lang.Class<? extends java.lang.Enum> getEnumClass()
public OrderedMap<java.lang.String,java.lang.Integer> getEnumValues()
public java.lang.Class<? extends java.lang.Enum> getMaskClass()
public OrderedMap<java.lang.String,java.lang.Long> getMaskValues()
public long incrementErrorCount()
public long getErrorCount()
public static void main(java.lang.String[] argv)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |