Package mgui.datasources
Class LinkedDataStream<T extends java.lang.Comparable<T>>
java.lang.Object
mgui.interfaces.AbstractInterfaceObject
mgui.datasources.LinkedDataStream<T>
- All Implemented Interfaces:
InterfaceObject,NamedObject,TreeObject,CleanableObject,IconObject
public class LinkedDataStream<T extends java.lang.Comparable<T>> extends AbstractInterfaceObject implements IconObject
Provides a link to a data source, using a unique field as the link field.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<T,java.util.HashMap<java.lang.String,java.lang.Object>>cacheprotected booleancachedprotected DataSourcedata_sourceprotected java.lang.Stringdata_tableprotected DataIndex<T>indexprotected java.lang.Stringlink_fieldprotected DataRecordSetrecord_setprotected doubleunknown_valueFields inherited from class mgui.interfaces.AbstractInterfaceObject
isDestroyed, tree_nodes -
Constructor Summary
Constructors Modifier Constructor Description protectedLinkedDataStream()LinkedDataStream(DataSource data_source, java.lang.String data_table, java.lang.String link_field)LinkedDataStream(DataSource data_source, java.lang.String data_table, java.lang.String link_field, boolean cached)LinkedDataStream(DataSource data_source, java.lang.String data_table, java.lang.String link_field, boolean cached, java.lang.String name)LinkedDataStream(DataSource data_source, java.lang.String data_table, java.lang.String link_field, java.lang.String name) -
Method Summary
Modifier and Type Method Description voidclearCache()DataSourcegetDataSource()static javax.swing.IcongetIcon()static LinkedDataStream<?>getInstance(DataSource data_source, java.lang.String data_table, java.lang.String link_field, boolean cached, java.lang.String name, boolean is_name_map)Returns an instance ofLinkedDataStreamof the correct generic type, based on the data type of the linked field.java.lang.StringgetLinkField()java.lang.StringgetLinkTable()java.util.ArrayList<java.lang.String>getNumericFields()Returns all fields which are numeric.doublegetNumericValue(T key, java.lang.String field)Returns the value forfieldat record where link field equalskey.javax.swing.IcongetObjectIcon()Returns theIconassociated with this object.protected java.lang.StringgetSQLForKey(java.lang.String key)java.lang.StringgetTreeLabel()Returns the label text to appear in a tree node.doublegetUnknownValue()Value to use when a key is not found in the linked sourcejava.lang.ObjectgetValue(T key, java.lang.String field)voidrefresh()voidsetTreeNode(InterfaceTreeNode treeNode)Sets the children for this node'sInterfaceTreeNode.voidsetUnknownValue(double value)Methods inherited from class mgui.interfaces.AbstractInterfaceObject
clean, destroy, getName, isDestroyed, issueTreeNode, setName, updateTreeNodesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
link_field
protected java.lang.String link_field -
data_table
protected java.lang.String data_table -
data_source
-
cached
protected boolean cached -
cache
-
record_set
-
index
-
unknown_value
protected double unknown_value
-
-
Constructor Details
-
LinkedDataStream
protected LinkedDataStream() -
LinkedDataStream
public LinkedDataStream(DataSource data_source, java.lang.String data_table, java.lang.String link_field) throws DataSourceException- Throws:
DataSourceException
-
LinkedDataStream
public LinkedDataStream(DataSource data_source, java.lang.String data_table, java.lang.String link_field, boolean cached) throws DataSourceException- Throws:
DataSourceException
-
LinkedDataStream
public LinkedDataStream(DataSource data_source, java.lang.String data_table, java.lang.String link_field, java.lang.String name) throws DataSourceException- Throws:
DataSourceException
-
LinkedDataStream
public LinkedDataStream(DataSource data_source, java.lang.String data_table, java.lang.String link_field, boolean cached, java.lang.String name) throws DataSourceException- Throws:
DataSourceException
-
-
Method Details
-
getInstance
public static LinkedDataStream<?> getInstance(DataSource data_source, java.lang.String data_table, java.lang.String link_field, boolean cached, java.lang.String name, boolean is_name_map) throws DataSourceExceptionReturns an instance ofLinkedDataStreamof the correct generic type, based on the data type of the linked field.- Parameters:
data_source-data_table-link_field-cached-name-has_name_map-- Returns:
- A new instance of the correct generic type
- Throws:
DataSourceException
-
getObjectIcon
public javax.swing.Icon getObjectIcon()Description copied from interface:IconObjectReturns theIconassociated with this object.- Specified by:
getObjectIconin interfaceIconObject- Returns:
-
getIcon
public static javax.swing.Icon getIcon() -
refresh
- Throws:
DataSourceException
-
getLinkTable
public java.lang.String getLinkTable() -
getLinkField
public java.lang.String getLinkField() -
setUnknownValue
public void setUnknownValue(double value) -
getUnknownValue
public double getUnknownValue()Value to use when a key is not found in the linked source- Returns:
-
getDataSource
-
getNumericFields
public java.util.ArrayList<java.lang.String> getNumericFields()Returns all fields which are numeric.- Returns:
-
getNumericValue
Returns the value forfieldat record where link field equalskey.- Parameters:
key-field-- Returns:
- Throws:
DataSourceException- if no record exists forkey
-
getValue
- Throws:
DataSourceException
-
clearCache
public void clearCache() -
getSQLForKey
protected java.lang.String getSQLForKey(java.lang.String key) -
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:
-