Package com.ericsson.otp.erlang
Class OtpErlangTuple
- java.lang.Object
- 
- com.ericsson.otp.erlang.OtpErlangObject
- 
- com.ericsson.otp.erlang.OtpErlangTuple
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Cloneable
 
 public class OtpErlangTuple extends OtpErlangObject Provides a Java representation of Erlang tuples. Tuples are created from one or more arbitrary Erlang 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:
- Serialized Form
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class com.ericsson.otp.erlang.OtpErlangObjectOtpErlangObject.Hash
 
- 
 - 
Field Summary- 
Fields inherited from class com.ericsson.otp.erlang.OtpErlangObjecthashCodeValue
 
- 
 - 
Constructor SummaryConstructors Constructor 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.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intarity()Get the arity of the tuple.<T> OtpErlangObjectbind(T binds)Make new Erlang term replacing variables with the respective values from bindings argument(s).java.lang.Objectclone()protected intdoHashCode()OtpErlangObjectelementAt(int i)Get the specified element from the tuple.OtpErlangObject[]elements()Get all the elements from the tuple as an array.voidencode(OtpOutputStream buf)Convert this tuple to the equivalent Erlang external representation.booleanequals(java.lang.Object o)Determine if two tuples are equal.<T> booleanmatch(OtpErlangObject term, T bindings)Perform match operation against given term.java.lang.StringtoString()Get the string representation of the tuple.- 
Methods inherited from class com.ericsson.otp.erlang.OtpErlangObjectdecode, hashCode
 
- 
 
- 
- 
- 
Constructor Detail- 
OtpErlangTuplepublic OtpErlangTuple(OtpErlangObject elem) Create a unary tuple containing the given element.- Parameters:
- elem- the element to create the tuple from.
- Throws:
- java.lang.IllegalArgumentException- if the element is null.
 
 - 
OtpErlangTuplepublic OtpErlangTuple(OtpErlangObject[] elems) Create a tuple from an array of terms.- Parameters:
- elems- the array of terms to create the tuple from.
- Throws:
- java.lang.IllegalArgumentException- if the array is empty (null) or contains null elements.
 
 - 
OtpErlangTuplepublic OtpErlangTuple(OtpErlangObject[] 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:
- java.lang.IllegalArgumentException- if the array is empty (null) or contains null elements.
 
 - 
OtpErlangTuplepublic OtpErlangTuple(OtpInputStream buf) throws OtpErlangDecodeException Create a tuple from a stream containing an tuple encoded in Erlang external format.- Parameters:
- buf- the stream containing the encoded tuple.
- Throws:
- OtpErlangDecodeException- if the buffer does not contain a valid external representation of an Erlang tuple.
 
 
- 
 - 
Method Detail- 
aritypublic int arity() Get the arity of the tuple.- Returns:
- the number of elements contained in the tuple.
 
 - 
elementAtpublic OtpErlangObject 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.
 
 - 
elementspublic OtpErlangObject[] elements() Get all the elements from the tuple as an array.- Returns:
- an array containing all of the tuple's elements.
 
 - 
toStringpublic java.lang.String toString() Get the string representation of the tuple.- Specified by:
- toStringin class- OtpErlangObject
- Returns:
- the string representation of the tuple.
 
 - 
encodepublic void encode(OtpOutputStream buf) Convert this tuple to the equivalent Erlang external representation.- Specified by:
- encodein class- OtpErlangObject
- Parameters:
- buf- an output stream to which the encoded tuple should be written.
 
 - 
equalspublic boolean equals(java.lang.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:
- equalsin class- OtpErlangObject
- Parameters:
- o- the tuple to compare to.
- Returns:
- true if the tuples have the same arity and all the elements are equal.
 
 - 
matchpublic <T> boolean match(OtpErlangObject term, T bindings) Description copied from class:OtpErlangObjectPerform match operation against given term.- Overrides:
- matchin class- OtpErlangObject
- Parameters:
- term- the object to match
- bindings- variable bindings
- Returns:
- true if match succeeded
 
 - 
bindpublic <T> OtpErlangObject bind(T binds) throws OtpErlangException Description copied from class:OtpErlangObjectMake new Erlang term replacing variables with the respective values from bindings argument(s).- Overrides:
- bindin class- OtpErlangObject
- Parameters:
- binds- variable bindings
- Returns:
- new term
- Throws:
- OtpErlangException
 
 - 
doHashCodeprotected int doHashCode() - Overrides:
- doHashCodein class- OtpErlangObject
 
 - 
clonepublic java.lang.Object clone() - Overrides:
- clonein class- OtpErlangObject
 
 
- 
 
-