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 AttributeListattributesbooleanisModifiedDataFieldTreeNodetreeNodestatic java.util.HashMap<java.lang.Integer,java.lang.String>typelistprotected java.lang.ObjectvalueFields inherited from class mgui.interfaces.AbstractInterfaceObject
isDestroyed, tree_nodes -
Constructor Summary
-
Method Summary
Modifier and Type Method Description voidattributeUpdated(AttributeEvent e)Called when an Attribute's value has been updated.java.lang.Objectclone()intcompareTo(DataField field)AttributeListgetAttributeList()intgetDataType()Returns the data type for this field; seeTypes.TypeMapgetDataTypeMap()java.lang.StringgetDataTypeStr()java.lang.ObjectgetDefaultValue()java.lang.StringgetDTD()Returns the Data Type Declaration (DTD) for this object's XML representationjava.lang.StringgetLabel()intgetLength()java.lang.StringgetLocalName()Returns the local name associated with this XML object.java.lang.StringgetName()Gets the name for this object.doublegetNumericValue()java.lang.ClassgetObjectClass()java.lang.StringgetShortXML(int tab)Returns a short XML representation of this object.java.lang.StringgetSQLString()Returns an SQL string representing this fieldjava.lang.StringgetSQLString(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.StringgetTextValue()java.lang.StringgetTextValue(java.lang.String format)java.lang.StringgetTypeStr()java.lang.ObjectgetValue()java.lang.StringgetXML()Returns this object's XML representation as a single string.java.lang.StringgetXML(int tab)Returns this object's XML representation as a single string.java.lang.StringgetXMLSchema()Returns the XML schema for this object's XML representationvoidhandleXMLElementEnd(java.lang.String localName)Handles the end of an XML element.voidhandleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)Handles the start of an XML element.voidhandleXMLString(java.lang.String s)Handles a string within an XML element.booleanisBoolean()booleanisComparable()booleanisDate()booleanisEditable()booleanisKeyField()booleanisNumeric()booleanisRequired()DataFieldTreeNodeissueTreeNode()Issues a new tree node and sets it usingAbstractInterfaceObject.setTreeNode(mgui.interfaces.trees.InterfaceTreeNode).booleanisText()booleanisTimestamp()booleanisUnique()voidsetDataType(int datatype)voidsetDataTypeMap(TypeMap map)voidsetDefaultValue(java.lang.Object value)voidsetIsEditable(boolean b)voidsetIsKeyField(boolean b)voidsetIsRequired(boolean b)voidsetIsUnique(boolean b)voidsetLabel(java.lang.String label)voidsetLength(int length)voidsetName(java.lang.String name)Sets the name for this object.voidsetTreeNode()voidsetValue(java.lang.Object value)java.lang.StringtoString()booleanupdateRecordSet(java.sql.ResultSet recordSet)Update a result set with this field, mapped to its data type /*voidwriteXML(int tab, java.io.Writer writer)Writes the XML representation of this object to file.voidwriteXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar)Writes the XML representation of this object to file, asXMLType.Normal.voidwriteXML(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, updateTreeNodesMethods 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:NamedObjectSets the name for this object.- Specified by:
setNamein interfaceNamedObject- Overrides:
setNamein classAbstractInterfaceObject
-
getName
public java.lang.String getName()Description copied from interface:NamedObjectGets the name for this object.- Specified by:
getNamein interfaceNamedObject- Overrides:
getNamein 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:
clonein classjava.lang.Object
-
attributeUpdated
Description copied from interface:AttributeListenerCalled when an Attribute's value has been updated.- Specified by:
attributeUpdatedin 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:AbstractInterfaceObjectIssues 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:
issueTreeNodein interfaceTreeObject- Overrides:
issueTreeNodein 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:
toStringin classjava.lang.Object
-
getDTD
public java.lang.String getDTD()Description copied from interface:XMLObjectReturns 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:XMLObjectReturns the XML schema for this object's XML representation- Specified by:
getXMLSchemain interfaceXMLObject- Returns:
-
getXML
public java.lang.String getXML()Description copied from interface:XMLObjectReturns 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:XMLObjectReturns 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:XMLObjectHandles the start of an XML element.- Specified by:
handleXMLElementStartin interfaceXMLObject- Parameters:
localName- Local name of the elementattributes- Set of element attributestype- TheXMLTypeof this element
-
handleXMLElementEnd
public void handleXMLElementEnd(java.lang.String localName)Description copied from interface:XMLObjectHandles the end of an XML element.- Specified by:
handleXMLElementEndin interfaceXMLObject- Parameters:
localName- Local name of the element
-
handleXMLString
public void handleXMLString(java.lang.String s)Description copied from interface:XMLObjectHandles a string within an XML element.- Specified by:
handleXMLStringin interfaceXMLObject- Parameters:
s- String to handle
-
getLocalName
public java.lang.String getLocalName()Description copied from interface:XMLObjectReturns the local name associated with this XML object.- Specified by:
getLocalNamein interfaceXMLObject- Returns:
-
writeXML
public void writeXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObjectWrites 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.Asciiwill be used. -
writeXML
public void writeXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObjectWrites the XML representation of this object to file, asXMLType.Normal. The default format ofXMLFormat.Asciiwill 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:XMLObjectWrites 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.Asciiwill be used. -
getShortXML
public java.lang.String getShortXML(int tab)Description copied from interface:XMLObjectReturns a short XML representation of this object.- Specified by:
getShortXMLin interfaceXMLObject- Returns:
-
compareTo
- Specified by:
compareToin interfacejava.lang.Comparable<DataField>
-