Package com.ericsson.otp.erlang
Class OtpErlangList
- java.lang.Object
- 
- com.ericsson.otp.erlang.OtpErlangObject
- 
- com.ericsson.otp.erlang.OtpErlangList
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Cloneable,- java.lang.Iterable<OtpErlangObject>
 - Direct Known Subclasses:
- OtpErlangList.SubList
 
 public class OtpErlangList extends OtpErlangObject implements java.lang.Iterable<OtpErlangObject> Provides a Java representation of Erlang lists. Lists are created from zero or more arbitrary Erlang terms.The arity of the list is the number of elements it contains. - See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classOtpErlangList.SubList- 
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 OtpErlangList()Create an empty list.OtpErlangList(OtpErlangObject elem)Create a list containing one element.OtpErlangList(OtpErlangObject[] elems)Create a list from an array of arbitrary Erlang terms.OtpErlangList(OtpErlangObject[] elems, int start, int count)Create a list from an array of arbitrary Erlang terms.OtpErlangList(OtpErlangObject[] elems, OtpErlangObject lastTail)Create a list from an array of arbitrary Erlang terms.OtpErlangList(OtpInputStream buf)Create a list from a stream containing an list encoded in Erlang external format.OtpErlangList(java.lang.String str)Create a list of Erlang integers representing Unicode codePoints.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intarity()Get the arity of the list.<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 list.OtpErlangObject[]elements()Get all the elements from the list as an array.voidencode(OtpOutputStream buf)Convert this list to the equivalent Erlang external representation.protected voidencode(OtpOutputStream buf, int start)booleanequals(java.lang.Object o)Determine if two lists are equal.OtpErlangObjectgetHead()OtpErlangObjectgetLastTail()OtpErlangObjectgetNthTail(int n)OtpErlangObjectgetTail()booleanisProper()java.util.Iterator<OtpErlangObject>iterator()<T> booleanmatch(OtpErlangObject term, T bindings)Perform match operation against given term.java.lang.StringstringValue()Convert a list of integers into a Unicode string, interpreting each integer as a Unicode code point value.java.lang.StringtoString()Get the string representation of the list.protected java.lang.StringtoString(int start)- 
Methods inherited from class com.ericsson.otp.erlang.OtpErlangObjectdecode, hashCode
 
- 
 
- 
- 
- 
Constructor Detail- 
OtpErlangListpublic OtpErlangList() Create an empty list.
 - 
OtpErlangListpublic OtpErlangList(java.lang.String str) Create a list of Erlang integers representing Unicode codePoints. This method does not check if the string contains valid code points.- Parameters:
- str- the characters from which to create the list.
 
 - 
OtpErlangListpublic OtpErlangList(OtpErlangObject elem) Create a list containing one element.- Parameters:
- elem- the elememet to make the list from.
 
 - 
OtpErlangListpublic OtpErlangList(OtpErlangObject[] elems) Create a list from an array of arbitrary Erlang terms.- Parameters:
- elems- the array of terms from which to create the list.
 
 - 
OtpErlangListpublic OtpErlangList(OtpErlangObject[] elems, OtpErlangObject lastTail) throws OtpErlangException Create a list from an array of arbitrary Erlang terms. Tail can be specified, if not null, the list will not be proper.- Parameters:
- elems- array of terms from which to create the list
- lastTail-
- Throws:
- OtpErlangException
 
 - 
OtpErlangListpublic OtpErlangList(OtpErlangObject[] elems, int start, int count) Create a list from an array of arbitrary Erlang terms.- Parameters:
- elems- the array of terms from which to create the list.
- start- the offset of the first term to insert.
- count- the number of terms to insert.
 
 - 
OtpErlangListpublic OtpErlangList(OtpInputStream buf) throws OtpErlangDecodeException Create a list from a stream containing an list encoded in Erlang external format.- Parameters:
- buf- the stream containing the encoded list.
- Throws:
- OtpErlangDecodeException- if the buffer does not contain a valid external representation of an Erlang list.
 
 
- 
 - 
Method Detail- 
aritypublic int arity() Get the arity of the list.- Returns:
- the number of elements contained in the list.
 
 - 
elementAtpublic OtpErlangObject elementAt(int i) Get the specified element from the list.- Parameters:
- i- the index of the requested element. List 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 list as an array.- Returns:
- an array containing all of the list's elements.
 
 - 
toStringpublic java.lang.String toString() Get the string representation of the list.- Specified by:
- toStringin class- OtpErlangObject
- Returns:
- the string representation of the list.
 
 - 
toStringprotected java.lang.String toString(int start) 
 - 
encodepublic void encode(OtpOutputStream buf) Convert this list to the equivalent Erlang external representation. Note that this method never encodes lists as strings, even when it is possible to do so.- Specified by:
- encodein class- OtpErlangObject
- Parameters:
- buf- An output stream to which the encoded list should be written.
 
 - 
encodeprotected void encode(OtpOutputStream buf, int start) 
 - 
equalspublic boolean equals(java.lang.Object o) Determine if two lists are equal. Lists are equal if they have the same arity and all of the elements are equal.- Specified by:
- equalsin class- OtpErlangObject
- Parameters:
- o- the list to compare to.
- Returns:
- true if the lists 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
 
 - 
getLastTailpublic OtpErlangObject getLastTail() 
 - 
doHashCodeprotected int doHashCode() - Overrides:
- doHashCodein class- OtpErlangObject
 
 - 
clonepublic java.lang.Object clone() - Overrides:
- clonein class- OtpErlangObject
 
 - 
iteratorpublic java.util.Iterator<OtpErlangObject> iterator() - Specified by:
- iteratorin interface- java.lang.Iterable<OtpErlangObject>
 
 - 
isProperpublic boolean isProper() - Returns:
- true if the list is proper, i.e. the last tail is nil
 
 - 
getHeadpublic OtpErlangObject getHead() 
 - 
getTailpublic OtpErlangObject getTail() 
 - 
getNthTailpublic OtpErlangObject getNthTail(int n) 
 - 
stringValuepublic java.lang.String stringValue() throws OtpErlangExceptionConvert a list of integers into a Unicode string, interpreting each integer as a Unicode code point value.- Returns:
- A java.lang.String object created through its constructor String(int[], int, int).
- Throws:
- OtpErlangException- for non-proper and non-integer lists.
- OtpErlangRangeException- if any integer does not fit into a Java int.
- java.security.InvalidParameterException- if any integer is not within the Unicode range.
- See Also:
- String(int[], int, int)
 
 
- 
 
-