Class jada.Tuple
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jada.Tuple

java.lang.Object
   |
   +----jada.Tuple

public class Tuple
extends Object
implements JadaItem
Base tuple class.
A tuple is a ordered set of items. Each item of a Jada tuple can be either an Integer, a String, a class that implements JadaItem (and we say it is "actual") or a Class (and we say it is "formal")
A Jada tuple can have as much as 10 items and 10 constructors are provided in order to ease the creation of a new tuple.
Tuples are used for the tuple space operations in an associative way using a matching operation. This operation is performed by the matches method. Two tuples are matching if they have the same no. of items and the i-th field of the first tuple matches the i-th field of the second one for each i.
Two items are matching if:
  • they are Integers and they represent the same value
  • they are String and they have the same contents
  • they implement JadaItem and the matchItem method returns true
  • they are Class and they represent the same class
  • one is a Class and the other is an instance of that class
    so the tuple
    Tuple ta = new Tuple(new Integer(3), "three")
    will match the tuple
    Tuple tb = new Tuple(new Integer(3), new String().getClass())
    Note that Tuple implements JadaItem so you can use a tuple as an item of another tuple.
    A tuple can be converted to a string using toString()
    A tuple string format is a list of items between brackets separated by commas. Items can be actual or formal. If an item is formal it starts with a ? followed the name of the class it represents ("i" and "s" are used as short formats for Integer and String respectively). If it's actual the toString() method is used to represent its value.
    Note: if you don't follow the rules for writing a JadaItem some method of this class (notably buildItem) may generate a class-related exception which is caught and is printed to the System.err stream.

    Constructor Index

     o Tuple()
    Constructor: builds an empty tuple.
     o Tuple(Object)
    Constructor: buils a tuple with the item item This is first of a set of 10 constructors that differ on the items number.
     o Tuple(Object, Object)
     o Tuple(Object, Object, Object)
     o Tuple(Object, Object, Object, Object)
     o Tuple(Object, Object, Object, Object, Object)
     o Tuple(Object, Object, Object, Object, Object, Object)
     o Tuple(Object, Object, Object, Object, Object, Object, Object)
     o Tuple(Object, Object, Object, Object, Object, Object, Object, Object)
     o Tuple(Object, Object, Object, Object, Object, Object, Object, Object, Object)
     o Tuple(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)
     o Tuple(Tuple)
    Constructor: build a tuple copying the given one.

    Method Index

     o buildItem(InputStream)
    From the JadaItem interface: builds this tuple from an input stream
     o cloneItem(Object)
    From the JadaItem interface: clone a tuple given a "source" one
     o dumpItem(OutputStream)
    From the JadaItem interface: dumps this tuple to a output stream
     o formal()
    Returns the Class for a tuple, useful when we want a tuple as a formal field for another tuple.
     o getIndex()
    Returns the index of this tuple if it is a result for a multiple in or read operation.
     o getItem(int)
    Returns the Object at the given position.
     o I()
    Short form for IntegerClass.
     o initFromString(String)
    Allocates basic data and sets the tuple reading its regular string representation.
     o IntegerClass()
    Returns the Class for an Integer object.
     o matchesItem(JadaItem)
    Checks for the given tuple to match the current one.
     o S()
    Short form for StringClass.
     o setItem(int, Object)
    Sets an item of the tuple.
    Watch out: just String, Integer and JadaItem are valid object types.
     o setItems(int)
    Sets the number of items for this tuple.
     o StringClass()
    Returns the Class for a String object.
     o toString()
    Override Object.toString().

    Constructors

     o Tuple
      public Tuple()
    
    Constructor: builds an empty tuple.
     o Tuple
      public Tuple(Tuple source)
    
    Constructor: build a tuple copying the given one.
     o Tuple
      public Tuple(Object item)
    
    Constructor: buils a tuple with the item item This is first of a set of 10 constructors that differ on the items number.
     o Tuple
      public Tuple(Object item1,
                   Object item2)
    
     o Tuple
      public Tuple(Object item1,
                   Object item2,
                   Object item3)
    
     o Tuple
      public Tuple(Object item1,
                   Object item2,
                   Object item3,
                   Object item4)
    
     o Tuple
      public Tuple(Object item1,
                   Object item2,
                   Object item3,
                   Object item4,
                   Object item5)
    
     o Tuple
      public Tuple(Object item1,
                   Object item2,
                   Object item3,
                   Object item4,
                   Object item5,
                   Object item6)
    
     o Tuple
      public Tuple(Object item1,
                   Object item2,
                   Object item3,
                   Object item4,
                   Object item5,
                   Object item6,
                   Object item7)
    
     o Tuple
      public Tuple(Object item1,
                   Object item2,
                   Object item3,
                   Object item4,
                   Object item5,
                   Object item6,
                   Object item7,
                   Object item8)
    
     o Tuple
      public Tuple(Object item1,
                   Object item2,
                   Object item3,
                   Object item4,
                   Object item5,
                   Object item6,
                   Object item7,
                   Object item8,
                   Object item9)
    
     o Tuple
      public Tuple(Object item1,
                   Object item2,
                   Object item3,
                   Object item4,
                   Object item5,
                   Object item6,
                   Object item7,
                   Object item8,
                   Object item9,
                   Object item10)
    

    Methods

     o setItems
      public void setItems(int items)
    
    Sets the number of items for this tuple. Useful when you want to build a tuple using setItem
     o getIndex
      public int getIndex()
    
    Returns the index of this tuple if it is a result for a multiple in or read operation.
     o IntegerClass
      public static Class IntegerClass()
    
    Returns the Class for an Integer object. Useful for a Integer formal tuple item.
    See Also:
    I
     o StringClass
      public static Class StringClass()
    
    Returns the Class for a String object. Useful for a String formal tuple item.
    See Also:
    S
     o I
      public static Class I()
    
    Short form for IntegerClass.
    See Also:
    IntegerClass
     o S
      public static Class S()
    
    Short form for StringClass.
    See Also:
    StringClass
     o formal
      public static Class formal()
    
    Returns the Class for a tuple, useful when we want a tuple as a formal field for another tuple.
     o initFromString
      protected void initFromString(String s) throws JadaFormatException, ClassNotFoundException
    
    Allocates basic data and sets the tuple reading its regular string representation.
     o setItem
      public void setItem(int index,
                          Object value)
    
    Sets an item of the tuple.
    Watch out: just String, Integer and JadaItem are valid object types.
    See Also:
    getItem
     o getItem
      public Object getItem(int index)
    
    Returns the Object at the given position.
    See Also:
    setItem
     o matchesItem
      public boolean matchesItem(JadaItem object)
    
    Checks for the given tuple to match the current one.
     o toString
      public String toString()
    
    Override Object.toString(). Uses the same representation initFromString uses to init a tuple
    Overrides:
    toString in class Object
    See Also:
    initFromString
     o cloneItem
      public void cloneItem(Object object_source)
    
    From the JadaItem interface: clone a tuple given a "source" one
     o dumpItem
      public void dumpItem(OutputStream os) throws JadaItemIsNotStreamableException, IOException
    
    From the JadaItem interface: dumps this tuple to a output stream
     o buildItem
      public void buildItem(InputStream is) throws JadaItemIsNotStreamableException, IOException
    
    From the JadaItem interface: builds this tuple from an input stream

    All Packages  Class Hierarchy  This Package  Previous  Next  Index