Package mgui.datasources
Class DataField
java.lang.Object
mgui.interfaces.AbstractInterfaceObject
mgui.datasources.DataField
- All Implemented Interfaces:
java.lang.Cloneable
,java.lang.Comparable<DataField>
,AttributeListener
,InterfaceObject
,NamedObject
,TreeObject
,CleanableObject
,XMLObject
public class DataField extends AbstractInterfaceObject implements java.lang.Cloneable, AttributeListener, XMLObject, java.lang.Comparable<DataField>
Object to specify a field data type and length.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Nested Class Summary
Nested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject
XMLObject.XMLEncoding, XMLObject.XMLType
-
Field Summary
Fields Modifier and Type Field Description protected AttributeList
attributes
boolean
isModified
DataFieldTreeNode
treeNode
static java.util.HashMap<java.lang.Integer,java.lang.String>
typelist
protected java.lang.Object
value
Fields inherited from class mgui.interfaces.AbstractInterfaceObject
isDestroyed, tree_nodes
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description void
attributeUpdated(AttributeEvent e)
Called when an Attribute's value has been updated.java.lang.Object
clone()
int
compareTo(DataField field)
AttributeList
getAttributeList()
int
getDataType()
Returns the data type for this field; seeTypes
.TypeMap
getDataTypeMap()
java.lang.String
getDataTypeStr()
java.lang.Object
getDefaultValue()
java.lang.String
getDTD()
Returns the Data Type Declaration (DTD) for this object's XML representationjava.lang.String
getLabel()
int
getLength()
java.lang.String
getLocalName()
Returns the local name associated with this XML object.java.lang.String
getName()
Gets the name for this object.double
getNumericValue()
java.lang.Class
getObjectClass()
java.lang.String
getShortXML(int tab)
Returns a short XML representation of this object.java.lang.String
getSQLString()
Returns an SQL string representing this fieldjava.lang.String
getSQLString(DataSourceDriver driver)
Returns an SQL string representing this field, formatted to suit a specific driver (since the JDBC standard is not always used in a standard way....)java.lang.String
getTextValue()
java.lang.String
getTextValue(java.lang.String format)
java.lang.String
getTypeStr()
java.lang.Object
getValue()
java.lang.String
getXML()
Returns this object's XML representation as a single string.java.lang.String
getXML(int tab)
Returns this object's XML representation as a single string.java.lang.String
getXMLSchema()
Returns the XML schema for this object's XML representationvoid
handleXMLElementEnd(java.lang.String localName)
Handles the end of an XML element.void
handleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)
Handles the start of an XML element.void
handleXMLString(java.lang.String s)
Handles a string within an XML element.boolean
isBoolean()
boolean
isComparable()
boolean
isDate()
boolean
isEditable()
boolean
isKeyField()
boolean
isNumeric()
boolean
isRequired()
DataFieldTreeNode
issueTreeNode()
Issues a new tree node and sets it usingAbstractInterfaceObject.setTreeNode(mgui.interfaces.trees.InterfaceTreeNode)
.boolean
isText()
boolean
isTimestamp()
boolean
isUnique()
void
setDataType(int datatype)
void
setDataTypeMap(TypeMap map)
void
setDefaultValue(java.lang.Object value)
void
setIsEditable(boolean b)
void
setIsKeyField(boolean b)
void
setIsRequired(boolean b)
void
setIsUnique(boolean b)
void
setLabel(java.lang.String label)
void
setLength(int length)
void
setName(java.lang.String name)
Sets the name for this object.void
setTreeNode()
void
setValue(java.lang.Object value)
java.lang.String
toString()
boolean
updateRecordSet(java.sql.ResultSet recordSet)
Update a result set with this field, mapped to its data type /*void
writeXML(int tab, java.io.Writer writer)
Writes the XML representation of this object to file.void
writeXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar)
Writes the XML representation of this object to file, asXMLType.Normal
.void
writeXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar)
Writes the XML representation of this object to file.Methods inherited from class mgui.interfaces.AbstractInterfaceObject
clean, destroy, getTreeLabel, isDestroyed, setTreeNode, updateTreeNodes
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
typelist
public static java.util.HashMap<java.lang.Integer,java.lang.String> typelist -
attributes
-
value
protected java.lang.Object value -
isModified
public boolean isModified -
treeNode
-
-
Constructor Details
-
DataField
public DataField() -
DataField
public DataField(java.lang.String thisName, int thisType) -
DataField
public DataField(java.lang.String thisName, int thisType, int length)
-
-
Method Details
-
getDefaultValue
public java.lang.Object getDefaultValue() -
setDefaultValue
public void setDefaultValue(java.lang.Object value) -
setName
public void setName(java.lang.String name)Description copied from interface:NamedObject
Sets the name for this object.- Specified by:
setName
in interfaceNamedObject
- Overrides:
setName
in classAbstractInterfaceObject
-
getName
public java.lang.String getName()Description copied from interface:NamedObject
Gets the name for this object.- Specified by:
getName
in interfaceNamedObject
- Overrides:
getName
in classAbstractInterfaceObject
- Returns:
-
setLength
public void setLength(int length) -
getLength
public int getLength() -
setDataTypeMap
-
getDataTypeMap
-
setDataType
public void setDataType(int datatype) -
getDataType
public int getDataType()Returns the data type for this field; seeTypes
.- Returns:
-
getDataTypeStr
public java.lang.String getDataTypeStr() -
getLabel
public java.lang.String getLabel() -
setLabel
public void setLabel(java.lang.String label) -
setIsUnique
public void setIsUnique(boolean b) -
isUnique
public boolean isUnique() -
setIsEditable
public void setIsEditable(boolean b) -
isEditable
public boolean isEditable() -
isComparable
public boolean isComparable() -
setIsKeyField
public void setIsKeyField(boolean b) -
isKeyField
public boolean isKeyField() -
setIsRequired
public void setIsRequired(boolean b) -
isRequired
public boolean isRequired() -
clone
public java.lang.Object clone()- Overrides:
clone
in classjava.lang.Object
-
attributeUpdated
Description copied from interface:AttributeListener
Called when an Attribute's value has been updated.- Specified by:
attributeUpdated
in interfaceAttributeListener
-
getTypeStr
public java.lang.String getTypeStr() -
setValue
- Throws:
DataSourceException
-
getValue
public java.lang.Object getValue() -
isNumeric
public boolean isNumeric() -
isText
public boolean isText() -
isBoolean
public boolean isBoolean() -
isDate
public boolean isDate() -
isTimestamp
public boolean isTimestamp() -
getNumericValue
public double getNumericValue() -
getTextValue
public java.lang.String getTextValue() -
getTextValue
public java.lang.String getTextValue(java.lang.String format) -
getSQLString
public java.lang.String getSQLString()Returns an SQL string representing this field- Returns:
-
getSQLString
Returns an SQL string representing this field, formatted to suit a specific driver (since the JDBC standard is not always used in a standard way....)- Returns:
-
getObjectClass
public java.lang.Class getObjectClass() -
setTreeNode
public void setTreeNode() -
issueTreeNode
Description copied from class:AbstractInterfaceObject
Issues a new tree node and sets it usingAbstractInterfaceObject.setTreeNode(mgui.interfaces.trees.InterfaceTreeNode)
. The tree node is stored in this object, which facilitates their destruction when necessary (e.g., when this object is destroyed). All issued tree nodes can informed of changes to their user object using the methodAbstractInterfaceObject.updateTreeNodes()
.- Specified by:
issueTreeNode
in interfaceTreeObject
- Overrides:
issueTreeNode
in classAbstractInterfaceObject
- Returns:
- a new
InterfaceTreeNode
-
updateRecordSet
public boolean updateRecordSet(java.sql.ResultSet recordSet)Update a result set with this field, mapped to its data type /*- Parameters:
recordSet
- ResultSet to update- Returns:
- true is update is successful, otherwise false
-
getAttributeList
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
getDTD
public java.lang.String getDTD()Description copied from interface:XMLObject
Returns the Data Type Declaration (DTD) for this object's XML representationSee http://en.wikipedia.org/wiki/Document_Type_Definition for a description.
-
getXMLSchema
public java.lang.String getXMLSchema()Description copied from interface:XMLObject
Returns the XML schema for this object's XML representation- Specified by:
getXMLSchema
in interfaceXMLObject
- Returns:
-
getXML
public java.lang.String getXML()Description copied from interface:XMLObject
Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)
functions to write larger objects to file. -
getXML
public java.lang.String getXML(int tab)Description copied from interface:XMLObject
Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)
functions to write larger objects to file. -
handleXMLElementStart
public void handleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)Description copied from interface:XMLObject
Handles the start of an XML element.- Specified by:
handleXMLElementStart
in interfaceXMLObject
- Parameters:
localName
- Local name of the elementattributes
- Set of element attributestype
- TheXMLType
of this element
-
handleXMLElementEnd
public void handleXMLElementEnd(java.lang.String localName)Description copied from interface:XMLObject
Handles the end of an XML element.- Specified by:
handleXMLElementEnd
in interfaceXMLObject
- Parameters:
localName
- Local name of the element
-
handleXMLString
public void handleXMLString(java.lang.String s)Description copied from interface:XMLObject
Handles a string within an XML element.- Specified by:
handleXMLString
in interfaceXMLObject
- Parameters:
s
- String to handle
-
getLocalName
public java.lang.String getLocalName()Description copied from interface:XMLObject
Returns the local name associated with this XML object.- Specified by:
getLocalName
in interfaceXMLObject
- Returns:
-
writeXML
public void writeXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObject
Writes the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format ofXMLFormat.Ascii
will be used. -
writeXML
public void writeXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObject
Writes the XML representation of this object to file, asXMLType.Normal
. The default format ofXMLFormat.Ascii
will be used. The basic contract for this method is that it should not write a newline character at its start or end. -
writeXML
public void writeXML(int tab, java.io.Writer writer) throws java.io.IOExceptionDescription copied from interface:XMLObject
Writes the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format ofXMLFormat.Ascii
will be used. -
getShortXML
public java.lang.String getShortXML(int tab)Description copied from interface:XMLObject
Returns a short XML representation of this object.- Specified by:
getShortXML
in interfaceXMLObject
- Returns:
-
compareTo
- Specified by:
compareTo
in interfacejava.lang.Comparable<DataField>
-