Package org.jspace

Class Tuple

java.lang.Object
org.jspace.Tuple
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<java.lang.Object>

public final class Tuple
extends java.lang.Object
implements java.lang.Iterable<java.lang.Object>, java.io.Serializable
A tuple identifies the basic information item. It consists of a sequence of values that can be collected into a knowledge repository.
See Also:
Serialized Form
  • Constructor Summary

    Constructors
    Constructor Description
    Tuple​(java.lang.Object... fields)
    Creates a new tuple.
  • Method Summary

    Modifier and Type Method Description
    boolean equals​(java.lang.Object obj)  
    java.lang.Object getElementAt​(int i)
    Returns the element at index i.
    <T> T getElementAt​(java.lang.Class<T> c, int i)
    Returns the instance of class c at element i.
    java.lang.Object[] getTuple()  
    java.lang.Class<?> getTypeAt​(int i)
    Returns the class c of the element with index i .
    int hashCode()  
    boolean isInstance​(java.lang.Class<?> c, int i)
    Checks if the element at position i is instance of c.
    java.util.Iterator<java.lang.Object> iterator()  
    int length()
    Returns the tuple length.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

    • Tuple

      public Tuple​(java.lang.Object... fields)
      Creates a new tuple.
      Parameters:
      fields - fields of new created tuple.
  • Method Details

    • length

      public int length()
      Returns the tuple length.
      Returns:
      the tuple length.
    • getElementAt

      public java.lang.Object getElementAt​(int i)
      Returns the element at index i.
      Parameters:
      i - element index.
      Returns:
      the element at index i.
    • getTypeAt

      public java.lang.Class<?> getTypeAt​(int i)
      Returns the class c of the element with index i .
      Parameters:
      i - element index
      Returns:
      the class c of the element with index i .
    • getElementAt

      public <T> T getElementAt​(java.lang.Class<T> c, int i)
      Returns the instance of class c at element i. This method is equivalent to c.cast(getElementAt(i)). A ClassCastException is thrown if the i-th element of the tuple is not an instance if c.
      Parameters:
      c - expected class
      i - element index
      Returns:
      the instance of class c at element i.
    • isInstance

      public boolean isInstance​(java.lang.Class<?> c, int i)
      Checks if the element at position i is instance of c.
      Parameters:
      c - Class
      i - Element index
      Returns:
      true if element at i is instance of c.
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • iterator

      public java.util.Iterator<java.lang.Object> iterator()
      Specified by:
      iterator in interface java.lang.Iterable<java.lang.Object>
    • getTuple

      public java.lang.Object[] getTuple()