org.systemsbiology.gaggle.core.datatypes
Class Tuple
java.lang.Object
org.systemsbiology.gaggle.core.datatypes.Tuple
- All Implemented Interfaces:
- java.io.Serializable
public class Tuple
- extends java.lang.Object
- implements java.io.Serializable
If n = 1 we say "single", if n = 2 we say "double", and if
n is any arbitrary number, we call it a tuple. In other words, this is
just a list of Single objects.
todo: format this as HTML.
A discussion of Tuples as used within Gaggle:
A tuple is simply a list of items, in the case of Gaggle, a list of values with optional keys. It is more flexible than a HashMap and has therefore replaced the HashMap in the newest Gaggle API.
The name comes from the pattern single, double, triple, etc. Tuple means there can be an arbitrary number of items.
http://en.wikipedia.org/wiki/Tuple
This page shows the Javadoc for the class containing the core gaggle data types:
http://gaggle.systemsbiology.net/2007-04/javadoc/org/systemsbiology/gaggle/core/datatypes/package-summary.html
Tuples are composed as follows:
GaggleTupleList
TupleList
Tuple
Single
Every top-level gaggle datatype gaggle data type (that is, every object that gets sent from one goose to another) implements the interface GaggleData
(http://gaggle.systemsbiology.net/2007-04/javadoc/org/systemsbiology/gaggle/core/datatypes/GaggleData.html). You can see here that every broadcast includes a TupleList where you can stuff any sort of metadata along with your broadcast. A GaggleTupleList is simply a top-level Gaggle datatype where the data and metadata are both TupleLists.
An important concept in the way that Gaggle uses tuples is this: You can fill a tuple with whatever you want, however you want. The receiving goose must know how to "unpack" the tuple. Therefore there is an informal contract between these two geese. Other pairs of geese might honor a different contract.
Anyway, working down the class hierarchy, the next level down is a TupleList which is obviously a list of tuples.
The Tuple class (duh) represents a Tuple, which is composed of a name and a list of Singles.
A Single is the basic unit of data within a tuple and consists of an optional name and a value. The value is of type Serializable and must be an Integer, Double, String, or another Tuple, or a runtime exception will be thrown. This restriction allows complex list-of-lists behavior while keeping the basic data types to those commonly needed in systems biology, and avoiding complex object graphs and possible serialization problems.
The implementation of the classes described above is as simple as possible, and could probably be much more efficient. However, the simplicity exists for a reason. Because Gaggle uses Java RMI for inter-VM communication, the classes on either side of the communication must have the same set of method signatures. Otherwise an exception is thrown. This means these classes are essentially frozen and cannot be changed until a new version of Gaggle is released; otherwise all goose developers would immediately have to get the new class, to avoid communication failures between geese.
We are looking into augmenting and/or replacing RMI with a platform-neutral messaging technology which would ease these restrictions.
So the Tuple classes are basically POJOs or DTOs if you like, with as little actual code in them as possible.
We envision either static utility classes or wrapper classes which would do much of the heavy lifting as far as parsing and traversing tuples and retrieving specified components. These classes would not be top-level and could therefore be continually refined without breaking the Gaggle API.
- See Also:
Single,
Serialized Form
|
Constructor Summary |
Tuple()
|
Tuple(java.lang.String name)
|
Tuple(java.lang.String name,
java.util.List<Single> singleList)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Tuple
public Tuple()
Tuple
public Tuple(java.lang.String name,
java.util.List<Single> singleList)
Tuple
public Tuple(java.lang.String name)
getSingleList
public java.util.List<Single> getSingleList()
setSingleList
public void setSingleList(java.util.List<Single> singleList)
addSingle
public void addSingle(Single single)
getSingleAt
public Single getSingleAt(int index)
getName
public java.lang.String getName()
setName
public void setName(java.lang.String name)
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object