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 indexi
.<T> T
getElementAt(java.lang.Class<T> c, int i)
Returns the instance of classc
at elementi
.java.lang.Object[]
getTuple()
java.lang.Class<?>
getTypeAt(int i)
Returns the classc
of the element with indexi
.int
hashCode()
boolean
isInstance(java.lang.Class<?> c, int i)
Checks if the element at positioni
is instance ofc
.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 indexi
.- Parameters:
i
- element index.- Returns:
- the element at index
i
.
-
getTypeAt
public java.lang.Class<?> getTypeAt(int i)Returns the classc
of the element with indexi
.- Parameters:
i
- element index- Returns:
- the class
c
of the element with indexi
.
-
getElementAt
public <T> T getElementAt(java.lang.Class<T> c, int i)Returns the instance of classc
at elementi
. This method is equivalent toc.cast(getElementAt(i))
. AClassCastException
is thrown if thei
-th element of the tuple is not an instance ifc
.- Parameters:
c
- expected classi
- element index- Returns:
- the instance of class
c
at elementi
.
-
isInstance
public boolean isInstance(java.lang.Class<?> c, int i)Checks if the element at positioni
is instance ofc
.- Parameters:
c
- Classi
- Element index- Returns:
- true if element at
i
is instance ofc
.
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
iterator
public java.util.Iterator<java.lang.Object> iterator()- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.Object>
-
getTuple
public java.lang.Object[] getTuple()
-