Package mgui.datasources
Class DataTable
java.lang.Object
mgui.interfaces.AbstractInterfaceObject
mgui.datasources.DataTable
- All Implemented Interfaces:
java.lang.Cloneable,DataFieldListener,DataSourceItem,SQLObject,InterfaceObject,PopupMenuObject,NamedObject,TreeObject,CleanableObject,XMLObject,IconObject
public class DataTable extends AbstractInterfaceObject implements java.lang.Cloneable, IconObject, PopupMenuObject, DataSourceItem, DataFieldListener
General data table object specifying the organization of data into fields.
- 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 DataSourcedataSourceprotected java.util.HashMap<java.lang.String,DataField>fieldsprotected java.util.HashMap<java.lang.String,DataIndex<?>>indexesprotected booleansort_fieldsjava.util.ArrayList<java.lang.String>sortFieldsDataSetTreeNodetreeNodeFields inherited from class mgui.interfaces.AbstractInterfaceObject
isDestroyed, tree_nodes -
Constructor Summary
-
Method Summary
Modifier and Type Method Description booleanaddField(DataField field)Adds a new field to this table.voidaddIndex(java.lang.String name, DataIndex<?> index)java.lang.Objectclone()voiddataFieldChanged(DataFieldEvent e)AttributeListgetAttributeList()DataSourcegetDataSource()java.lang.StringgetDTD()Returns the Data Type Declaration (DTD) for this object's XML representationDataFieldgetField(java.lang.String name)java.lang.Class<? extends java.lang.Comparable<?>>getFieldClass(java.lang.String name)java.util.ArrayList<DataField>getFieldList()java.util.HashMap<java.lang.String,DataField>getFields()DataTablegetFilteredByList(java.util.ArrayList<java.lang.Comparable> list, java.lang.String filter_field)Enumerates the indices of records in this table wherefilter_fieldmatches an element inlist.static javax.swing.IcongetIcon()DataIndex<?>getIndex(java.lang.String name)java.util.HashMap<java.lang.String,DataIndex<?>>getIndexes()java.util.ArrayList<java.lang.String>getKeyFields()Returns a list of this table's key fields.java.lang.StringgetLocalName()Returns the local name associated with this XML object.javax.swing.IcongetObjectIcon()Returns theIconassociated with this object.InterfacePopupMenugetPopupMenu()Produces and returns a popup menu for this object.InterfacePopupMenugetPopupMenu(java.util.List<java.lang.Object> selected)Produces and returns a popup menu for this object.java.util.ArrayList<java.lang.String>getPrimaryKeys()Returns a list of the primary keys in this tablejava.lang.StringgetShortXML(int tab)Returns a short XML representation of this object.java.lang.StringgetSQLSortStr()java.lang.StringgetSQLSortStr(java.lang.String[] sort_fields)java.lang.StringgetSQLSortStr(java.lang.String[] sort_fields, DataSourceDriver driver)java.lang.StringgetSQLSortStr(DataSourceDriver driver)java.lang.StringgetSQLStatement()Produces an SQL statement with the default character setjava.lang.StringgetSQLStatement(java.lang.String[] sort_fields)java.lang.StringgetSQLStatement(java.lang.String[] sort_fields, DataSourceDriver driver)java.lang.StringgetSQLStatement(DataSourceDriver driver)Produces an SQL statement with a driver-specific character setjava.lang.StringgetTreeLabel()Returns the label text to appear in a tree node.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 representationvoidhandlePopupEvent(java.awt.event.ActionEvent e)Handles an event on this object's popup menu.voidhandleXMLElementEnd(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.booleanhasField(java.lang.String name)booleanhasSortedFields()protected voidinit()booleanremoveField(java.lang.String field)booleanremoveField(DataField field)voidsetDataSource(DataSource ds)voidsetFields(java.util.ArrayList<DataField> f)booleansetKeyField(java.lang.String name)voidsetSortedFields(boolean b)voidsetTreeNode(InterfaceTreeNode treeNode)Sets the children for this node'sInterfaceTreeNode.voidshowPopupMenu(java.awt.event.MouseEvent e)Shows a popup menu at the point of the givenMouseEvent.java.lang.StringtoString()booleanunsetKeyField(java.lang.String name)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, getName, isDestroyed, issueTreeNode, setName, updateTreeNodesMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface mgui.interfaces.util.CleanableObject
cleanMethods inherited from interface mgui.interfaces.InterfaceObject
destroy, isDestroyedMethods inherited from interface mgui.interfaces.NamedObject
getName, setNameMethods inherited from interface mgui.interfaces.trees.TreeObject
issueTreeNode
-
Field Details
-
sortFields
public java.util.ArrayList<java.lang.String> sortFields -
fields
-
indexes
-
treeNode
-
dataSource
-
sort_fields
protected boolean sort_fields
-
-
Constructor Details
-
DataTable
public DataTable() -
DataTable
public DataTable(java.lang.String name)
-
-
Method Details
-
getIcon
public static javax.swing.Icon getIcon() -
getObjectIcon
public javax.swing.Icon getObjectIcon()Description copied from interface:IconObjectReturns theIconassociated with this object.- Specified by:
getObjectIconin interfaceIconObject- Returns:
-
init
protected void init() -
setDataSource
- Specified by:
setDataSourcein interfaceDataSourceItem
-
getDataSource
- Specified by:
getDataSourcein interfaceDataSourceItem
-
hasSortedFields
public boolean hasSortedFields()- Specified by:
hasSortedFieldsin interfaceDataSourceItem
-
setSortedFields
public void setSortedFields(boolean b) -
setFields
-
getKeyFields
public java.util.ArrayList<java.lang.String> getKeyFields()Returns a list of this table's key fields.- Returns:
-
getSQLStatement
public java.lang.String getSQLStatement(java.lang.String[] sort_fields) -
getSQLStatement
public java.lang.String getSQLStatement()Description copied from interface:SQLObjectProduces an SQL statement with the default character set- Specified by:
getSQLStatementin interfaceSQLObject- Returns:
-
getSQLStatement
-
getSQLStatement
Description copied from interface:SQLObjectProduces an SQL statement with a driver-specific character set- Specified by:
getSQLStatementin interfaceSQLObject- Returns:
-
getSQLSortStr
public java.lang.String getSQLSortStr(java.lang.String[] sort_fields) -
getSQLSortStr
-
getSQLSortStr
public java.lang.String getSQLSortStr() -
getSQLSortStr
-
addField
Adds a new field to this table. Note: this does not update the data source. To add a field to a live table, useDataSource.addField.- Parameters:
field-- Returns:
-
hasField
public boolean hasField(java.lang.String name) -
removeField
-
removeField
public boolean removeField(java.lang.String field) -
getFields
-
getFieldList
-
getField
-
setKeyField
public boolean setKeyField(java.lang.String name) -
unsetKeyField
public boolean unsetKeyField(java.lang.String name) -
getFieldClass
public java.lang.Class<? extends java.lang.Comparable<?>> getFieldClass(java.lang.String name) -
addIndex
-
getIndexes
-
getIndex
-
getFilteredByList
public DataTable getFilteredByList(java.util.ArrayList<java.lang.Comparable> list, java.lang.String filter_field) throws DataSourceExceptionEnumerates the indices of records in this table wherefilter_fieldmatches an element inlist. Creates a temporary table in this table'sDataSourceand returns that table.If an error is encountered in the table creation process, a
DataSourceExceptionis thrown.- Parameters:
list-join_field-- Returns:
- Throws:
DataSourceException
-
clone
public java.lang.Object clone()- Overrides:
clonein classjava.lang.Object
-
setTreeNode
Description copied from interface:TreeObjectSets the children for this node'sInterfaceTreeNode.- Specified by:
setTreeNodein interfaceTreeObject- Overrides:
setTreeNodein classAbstractInterfaceObject
-
getTreeLabel
public java.lang.String getTreeLabel()Description copied from interface:TreeObjectReturns the label text to appear in a tree node.- Specified by:
getTreeLabelin interfaceTreeObject- Overrides:
getTreeLabelin classAbstractInterfaceObject- Returns:
-
getPopupMenu
Description copied from interface:PopupMenuObjectProduces and returns a popup menu for this object.- Specified by:
getPopupMenuin interfacePopupMenuObject- Returns:
-
getPopupMenu
Description copied from interface:PopupMenuObjectProduces and returns a popup menu for this object. Allows an associated list of objects to be passed as an argument.- Specified by:
getPopupMenuin interfacePopupMenuObject- Returns:
-
handlePopupEvent
public void handlePopupEvent(java.awt.event.ActionEvent e)Description copied from interface:PopupMenuObjectHandles an event on this object's popup menu.- Specified by:
handlePopupEventin interfacePopupMenuObject
-
showPopupMenu
public void showPopupMenu(java.awt.event.MouseEvent e)Description copied from interface:PopupMenuObjectShows a popup menu at the point of the givenMouseEvent.- Specified by:
showPopupMenuin interfacePopupMenuObject
-
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) throws org.xml.sax.SAXExceptionDescription 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- Throws:
org.xml.sax.SAXException
-
handleXMLElementEnd
public void handleXMLElementEnd(java.lang.String localName) throws org.xml.sax.SAXExceptionDescription copied from interface:XMLObjectHandles the end of an XML element.- Specified by:
handleXMLElementEndin interfaceXMLObject- Parameters:
localName- Local name of the element- Throws:
org.xml.sax.SAXException
-
handleXMLString
public void handleXMLString(java.lang.String s) throws org.xml.sax.SAXExceptionDescription copied from interface:XMLObjectHandles a string within an XML element.- Specified by:
handleXMLStringin interfaceXMLObject- Parameters:
s- String to handle- Throws:
org.xml.sax.SAXException
-
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:
-
getPrimaryKeys
public java.util.ArrayList<java.lang.String> getPrimaryKeys()Returns a list of the primary keys in this table- Returns:
-
dataFieldChanged
- Specified by:
dataFieldChangedin interfaceDataFieldListener
-