Class ConfETuple

Object
com.tailf.proto.ConfEObject
com.tailf.proto.ConfETuple
All Implemented Interfaces:
Serializable, Cloneable

public class ConfETuple extends ConfEObject implements Serializable, Cloneable
Provides a Java representation of E tuples. Tuples are created from one or more arbitrary E terms.

The arity of the tuple is the number of elements it contains. Elements are indexed from 0 to (arity-1) and can be retrieved individually by using the appropriate index.

See Also:
  • Constructor Details

    • ConfETuple

      public ConfETuple(ConfEObject elem)
      Create a unary tuple containing the given element.
      Parameters:
      elem - the element to create the tuple from.
      Throws:
      IllegalArgumentException - if the array is empty (null).
    • ConfETuple

      public ConfETuple(ConfEObject[] elems)
      Create a tuple from an array of terms.
      Parameters:
      elems - the array of terms to create the tuple from.
      Throws:
      IllegalArgumentException - if the array is empty (null) or contains null elements.
    • ConfETuple

      public ConfETuple(ConfEObject[] elems, int start, int count)
      Create a tuple from an array of terms.
      Parameters:
      elems - the array of terms to create the tuple from.
      start - the offset of the first term to insert.
      count - the number of terms to insert.
      Throws:
      IllegalArgumentException - if the array is empty (null) or contains null elements.
    • ConfETuple

      public ConfETuple(ConfInputStream buf) throws ConfEDecodeException
      Create a tuple from a stream containing an tuple encoded in E external format.
      Parameters:
      buf - the stream containing the encoded tuple.
      Throws:
      ConfEDecodeException - if the buffer does not contain a valid external representation of an E tuple.
  • Method Details

    • arity

      public int arity()
      Get the arity of the tuple.
      Returns:
      the number of elements contained in the tuple.
    • elementAt

      public ConfEObject elementAt(int i)
      Get the specified element from the tuple.
      Parameters:
      i - the index of the requested element. Tuple elements are numbered as array elements, starting at 0.
      Returns:
      the requested element, of null if i is not a valid element index.
    • elements

      public ConfEObject[] elements()
      Get all the elements from the tuple as an array.
      Returns:
      an array containing all of the tuple's elements.
    • toString

      public String toString()
      Get the string representation of the tuple.
      Specified by:
      toString in class ConfEObject
      Returns:
      the string representation of the tuple.
    • encode

      public void encode(ConfOutputStream buf)
      Convert this tuple to the equivalent E external representation.
      Specified by:
      encode in class ConfEObject
      Parameters:
      buf - an output stream to which the encoded tuple should be written.
    • equals

      public boolean equals(Object o)
      Determine if two tuples are equal. Tuples are equal if they have the same arity and all of the elements are equal.
      Specified by:
      equals in class ConfEObject
      Parameters:
      o - the tuple to compare to.
      Returns:
      true if the tuples have the same arity and all the elements are equal.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • clone

      public Object clone()
      Overrides:
      clone in class ConfEObject