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>>
cache
protected boolean
cached
protected DataSource
data_source
protected java.lang.String
data_table
protected DataIndex<T>
index
protected java.lang.String
link_field
protected DataRecordSet
record_set
protected double
unknown_value
Fields inherited from class mgui.interfaces.AbstractInterfaceObject
isDestroyed, tree_nodes
-
Constructor Summary
Constructors Modifier Constructor Description protected
LinkedDataStream()
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 void
clearCache()
DataSource
getDataSource()
static javax.swing.Icon
getIcon()
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 ofLinkedDataStream
of the correct generic type, based on the data type of the linked field.java.lang.String
getLinkField()
java.lang.String
getLinkTable()
java.util.ArrayList<java.lang.String>
getNumericFields()
Returns all fields which are numeric.double
getNumericValue(T key, java.lang.String field)
Returns the value forfield
at record where link field equalskey
.javax.swing.Icon
getObjectIcon()
Returns theIcon
associated with this object.protected java.lang.String
getSQLForKey(java.lang.String key)
java.lang.String
getTreeLabel()
Returns the label text to appear in a tree node.double
getUnknownValue()
Value to use when a key is not found in the linked sourcejava.lang.Object
getValue(T key, java.lang.String field)
void
refresh()
void
setTreeNode(InterfaceTreeNode treeNode)
Sets the children for this node'sInterfaceTreeNode
.void
setUnknownValue(double value)
Methods inherited from class mgui.interfaces.AbstractInterfaceObject
clean, destroy, getName, isDestroyed, issueTreeNode, setName, updateTreeNodes
Methods 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 ofLinkedDataStream
of 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:IconObject
Returns theIcon
associated with this object.- Specified by:
getObjectIcon
in 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 forfield
at 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:TreeObject
Sets the children for this node'sInterfaceTreeNode
.- Specified by:
setTreeNode
in interfaceTreeObject
- Overrides:
setTreeNode
in classAbstractInterfaceObject
-
getTreeLabel
public java.lang.String getTreeLabel()Description copied from interface:TreeObject
Returns the label text to appear in a tree node.- Specified by:
getTreeLabel
in interfaceTreeObject
- Overrides:
getTreeLabel
in classAbstractInterfaceObject
- Returns:
-