public class OtpErlangTuple extends OtpErlangObject
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.
OtpErlangObject.Hash
hashCodeValue
Constructor and Description |
---|
OtpErlangTuple(OtpErlangObject elem)
Create a unary tuple containing the given element.
|
OtpErlangTuple(OtpErlangObject[] elems)
Create a tuple from an array of terms.
|
OtpErlangTuple(OtpErlangObject[] elems,
int start,
int count)
Create a tuple from an array of terms.
|
OtpErlangTuple(OtpInputStream buf)
Create a tuple from a stream containing an tuple encoded in Erlang
external format.
|
Modifier and Type | Method and Description |
---|---|
int |
arity()
Get the arity of the tuple.
|
<T> OtpErlangObject |
bind(T binds)
Make new Erlang term replacing variables with the respective values from
bindings argument(s).
|
java.lang.Object |
clone() |
protected int |
doHashCode() |
OtpErlangObject |
elementAt(int i)
Get the specified element from the tuple.
|
OtpErlangObject[] |
elements()
Get all the elements from the tuple as an array.
|
void |
encode(OtpOutputStream buf)
Convert this tuple to the equivalent Erlang external representation.
|
boolean |
equals(java.lang.Object o)
Determine if two tuples are equal.
|
<T> boolean |
match(OtpErlangObject term,
T bindings)
Perform match operation against given term.
|
java.lang.String |
toString()
Get the string representation of the tuple.
|
decode, hashCode
public OtpErlangTuple(OtpErlangObject elem)
elem
- the element to create the tuple from.java.lang.IllegalArgumentException
- if the element is null.public OtpErlangTuple(OtpErlangObject[] elems)
elems
- the array of terms to create the tuple from.java.lang.IllegalArgumentException
- if the array is empty (null) or contains null elements.public OtpErlangTuple(OtpErlangObject[] elems, int start, int count)
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.java.lang.IllegalArgumentException
- if the array is empty (null) or contains null elements.public OtpErlangTuple(OtpInputStream buf) throws OtpErlangDecodeException
buf
- the stream containing the encoded tuple.OtpErlangDecodeException
- if the buffer does not contain a valid external
representation of an Erlang tuple.public int arity()
public OtpErlangObject elementAt(int i)
i
- the index of the requested element. Tuple elements are
numbered as array elements, starting at 0.public OtpErlangObject[] elements()
public java.lang.String toString()
toString
in class OtpErlangObject
public void encode(OtpOutputStream buf)
encode
in class OtpErlangObject
buf
- an output stream to which the encoded tuple should be written.public boolean equals(java.lang.Object o)
equals
in class OtpErlangObject
o
- the tuple to compare to.public <T> boolean match(OtpErlangObject term, T bindings)
OtpErlangObject
match
in class OtpErlangObject
term
- the object to matchbindings
- variable bindingspublic <T> OtpErlangObject bind(T binds) throws OtpErlangException
OtpErlangObject
bind
in class OtpErlangObject
binds
- variable bindingsOtpErlangException
protected int doHashCode()
doHashCode
in class OtpErlangObject
public java.lang.Object clone()
clone
in class OtpErlangObject