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
  • Field Details

    • typelist

      public static java.util.HashMap<java.lang.Integer,​java.lang.String> typelist
    • attributes

      protected AttributeList attributes
    • value

      protected java.lang.Object value
    • isModified

      public boolean isModified
    • treeNode

      public DataFieldTreeNode 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 interface NamedObject
      Overrides:
      setName in class AbstractInterfaceObject
    • getName

      public java.lang.String getName()
      Description copied from interface: NamedObject
      Gets the name for this object.
      Specified by:
      getName in interface NamedObject
      Overrides:
      getName in class AbstractInterfaceObject
      Returns:
    • setLength

      public void setLength​(int length)
    • getLength

      public int getLength()
    • setDataTypeMap

      public void setDataTypeMap​(TypeMap map)
    • getDataTypeMap

      public TypeMap getDataTypeMap()
    • setDataType

      public void setDataType​(int datatype)
    • getDataType

      public int getDataType()
      Returns the data type for this field; see Types.
      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 class java.lang.Object
    • attributeUpdated

      public void attributeUpdated​(AttributeEvent e)
      Description copied from interface: AttributeListener
      Called when an Attribute's value has been updated.
      Specified by:
      attributeUpdated in interface AttributeListener
    • getTypeStr

      public java.lang.String getTypeStr()
    • setValue

      public void setValue​(java.lang.Object value) throws DataSourceException
      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

      public java.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....)
      Returns:
    • getObjectClass

      public java.lang.Class getObjectClass()
    • setTreeNode

      public void setTreeNode()
    • issueTreeNode

      public DataFieldTreeNode issueTreeNode()
      Description copied from class: AbstractInterfaceObject
      Issues a new tree node and sets it using AbstractInterfaceObject.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 method AbstractInterfaceObject.updateTreeNodes().
      Specified by:
      issueTreeNode in interface TreeObject
      Overrides:
      issueTreeNode in class AbstractInterfaceObject
      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

      public AttributeList getAttributeList()
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • getDTD

      public java.lang.String getDTD()
      Description copied from interface: XMLObject
      Returns the Data Type Declaration (DTD) for this object's XML representation

      See http://en.wikipedia.org/wiki/Document_Type_Definition for a description.

      Specified by:
      getDTD in interface XMLObject
      Returns:
    • getXMLSchema

      public java.lang.String getXMLSchema()
      Description copied from interface: XMLObject
      Returns the XML schema for this object's XML representation

      See http://en.wikipedia.org/wiki/XML_schema.

      Specified by:
      getXMLSchema in interface XMLObject
      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 the XMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater) functions to write larger objects to file.
      Specified by:
      getXML in interface XMLObject
      Returns:
    • 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 the XMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater) functions to write larger objects to file.
      Specified by:
      getXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the opening XML wrapper
      Returns:
    • 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 interface XMLObject
      Parameters:
      localName - Local name of the element
      attributes - Set of element attributes
      type - The XMLType 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 interface XMLObject
      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 interface XMLObject
      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 interface XMLObject
      Returns:
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOException
      Description 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 of XMLFormat.Ascii will be used.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      options - XMLOutputOptions defining the write parameters
      progress_bar - Optional progress updater (may be null)
      Throws:
      java.io.IOException
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes the XML representation of this object to file, as XMLType.Normal. The default format of XMLFormat.Ascii will be used. The basic contract for this method is that it should not write a newline character at its start or end.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      progress_bar - Optional progress updater (may be null)
      Throws:
      java.io.IOException
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer) throws java.io.IOException
      Description 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 of XMLFormat.Ascii will be used.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      Throws:
      java.io.IOException
    • 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 interface XMLObject
      Returns:
    • compareTo

      public int compareTo​(DataField field)
      Specified by:
      compareTo in interface java.lang.Comparable<DataField>