public abstract class TrianaType extends java.lang.Object implements java.io.Serializable, SequenceInterface
The main data objects in TrianaType are:
TrianaType implements a number of methods for setting and examining these data. In addition, the class defines two groups of methods that must be implemented for each Triana data type. These include
TrianaType also implements a mechanism for allowing Units to attach data to TrianaType data objects. These attachments are called ClipIns, and the attachment holder is called theClip. See the ClipIn interface for details of how these optional attachments work. TrianaType includes a number of methods for attaching, inspecting, and deleting ClipIns.
Type programmers note: Please take note of this class and implement the functions within it when creating new Triana types. For example, the copyMe group of methods is essential to the running of the units, for the reason given in the next paragraph.
OldUnit programmers note: To avoid memory problems, units should normally modify an input data object and output it, rather than copy it. If an output data object is to be of the same type as an input object, then programmers can usually use the copyMe method of the input data to create the new object and then modify its data appropriately. This is easier than instantiating a new object with its Constructors.
GraphType
,
TrianaImage
,
Document
,
Journal
,
Serialized FormModifier and Type | Field and Description |
---|---|
static TrianaType |
NOT_CONNECTED
If the input node is set to essential (the default) and there is no cable connected to this input node this
constant is returned
|
static TrianaType |
NOT_READY
A TrianaType which represents that the data is not ready.
|
static TrianaType |
OUT_OF_RANGE |
Modifier | Constructor and Description |
---|---|
protected |
TrianaType()
Creates an empty TrianaType, adds a message to the description saying when it was created, and constructs the
Journal from this description.
|
Modifier and Type | Method and Description |
---|---|
int |
containerSize()
Returns the actual number of elements stored in the dataContainer Hashtable.
|
protected void |
copyData(TrianaType source)
Copies data held in dataContainer from the argument object to the current object.
|
abstract TrianaType |
copyMe()
This is one of the most important methods of Triana data.
|
protected void |
copyParameters(TrianaType source)
Copies modifiable parameters from the argument object to the current object.
|
boolean |
dataExists(java.lang.Object k)
Returns true if the dataContainer Hashtable contains an object with the given argument k as
a key.
|
boolean |
deleteFromContainer(java.lang.Object k)
Deletes the element from the dataContainer Hashtable that is associated with the given key k.
|
java.util.Hashtable |
getDataContainer()
Returns the dataContainer Hashtable.
|
java.lang.Object |
getFromContainer(java.lang.Object k)
Returns the Object from the dataContainer associated with the given argument key k.
|
int |
getSequenceNumber() |
void |
insertIntoContainer(java.lang.Object k,
java.lang.Object d)
Inserts the given Object d (second argument) into the dataContainer Hashtable with the argument
Object k (first argument) as a key.
|
java.util.Enumeration |
inspectDataContainer()
Returns an Enumeration containing the keys identifying the contents of the dataContainer Hashtable.
|
void |
setDataContainer(java.util.Hashtable h)
Initializes the dataContainer Hashtable.
|
void |
setSequenceNumber(int sequenceNumber) |
protected void |
updateObsoletePointers() |
public static final TrianaType NOT_READY
public static final TrianaType NOT_CONNECTED
public static final TrianaType OUT_OF_RANGE
protected TrianaType()
public void setDataContainer(java.util.Hashtable h)
h
- Any Hashtable that may contain suitable data.public java.util.Hashtable getDataContainer()
public java.util.Enumeration inspectDataContainer()
public void insertIntoContainer(java.lang.Object k, java.lang.Object d)
k
- The key to the item being stored in the Hashtabled
- The data item being storedpublic boolean deleteFromContainer(java.lang.Object k)
k
- The key of the object being deletedpublic int containerSize()
public boolean dataExists(java.lang.Object k)
k
- The keypublic java.lang.Object getFromContainer(java.lang.Object k)
k
- The key to the element being soughtpublic abstract TrianaType copyMe()
To override, the programmer should not invoke the super.copyMe method. Instead, create an object of the current type and call methods copyData and copyParameters. If these have been written correctly, then they will do the copying. The code should createTool, for type YourType:
YourType y = null; try { y = (YourType)getClass().newInstance(); y.copyData( this ); y.copyParameters( this ); y.setLegend( this.getLegend() ); } catch (IllegalAccessException ee) { System.out.println("Illegal Access: " + ee.getMessage()); } catch (InstantiationException ee) { System.out.println("Couldn't be instantiated: " + ee.getMessage()); } return y;
The copied object's data should be identical to the original. The method here modifies only one item: a String indicating that the object was created as a copy is added to the description StringVector.
protected void copyData(TrianaType source)
This method must be overridden if subclasses add more data to dataContainer, and the overriding method should invoke its super method. This method is called by copyMe().
source
- Object that contains the data to be copied.protected void copyParameters(TrianaType source)
In this method, the old description is not copied, since it will turn up in the journal list (if history tracking is turned on). A new description line is added to note that this is a copy. Then the legend is copied.
This must be overridden by any subclass that defines new parameters. The overriding method should invoke its super method. It should use the set... and get... methods for the parameters in question. This method is protected so that it cannot be called except by objects that inherit from this one. It is called by copyMe().
source
- Object that contains the data to be copied.protected void updateObsoletePointers()
public int getSequenceNumber()
getSequenceNumber
in interface SequenceInterface
public void setSequenceNumber(int sequenceNumber)
setSequenceNumber
in interface SequenceInterface
sequenceNumber
- the identifying number of this data type in the sequence.