Package com.ericsson.otp.erlang
Class OtpErlangList
java.lang.Object
com.ericsson.otp.erlang.OtpErlangObject
com.ericsson.otp.erlang.OtpErlangList
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<OtpErlangObject>
- Direct Known Subclasses:
OtpErlangList.SubList
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.ericsson.otp.erlang.OtpErlangObject
OtpErlangObject.Hash
-
Field Summary
Fields inherited from class com.ericsson.otp.erlang.OtpErlangObject
hashCodeValue
-
Constructor Summary
ConstructorDescriptionCreate 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.Create a list from a stream containing an list encoded in Erlang external format.OtpErlangList
(String str) Create a list of Erlang integers representing Unicode codePoints. -
Method Summary
Modifier and TypeMethodDescriptionint
arity()
Get the arity of the list.<T> OtpErlangObject
bind
(T binds) Make new Erlang term replacing variables with the respective values from bindings argument(s).clone()
protected int
elementAt
(int i) Get the specified element from the list.elements()
Get all the elements from the list as an array.void
encode
(OtpOutputStream buf) Convert this list to the equivalent Erlang external representation.protected void
encode
(OtpOutputStream buf, int start) boolean
Determine if two lists are equal.getHead()
getNthTail
(int n) getTail()
boolean
isProper()
iterator()
<T> boolean
match
(OtpErlangObject term, T bindings) Perform match operation against given term.Convert a list of integers into a Unicode string, interpreting each integer as a Unicode code point value.toString()
Get the string representation of the list.protected String
toString
(int start) Methods inherited from class com.ericsson.otp.erlang.OtpErlangObject
decode, hashCode
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
OtpErlangList
public OtpErlangList()Create an empty list. -
OtpErlangList
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.
-
OtpErlangList
Create a list containing one element.- Parameters:
elem
- the elememet to make the list from.
-
OtpErlangList
Create a list from an array of arbitrary Erlang terms.- Parameters:
elems
- the array of terms from which to create the list.
-
OtpErlangList
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 listlastTail
-- Throws:
OtpErlangException
-
OtpErlangList
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.
-
OtpErlangList
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 Details
-
arity
public int arity()Get the arity of the list.- Returns:
- the number of elements contained in the list.
-
elementAt
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.
-
elements
Get all the elements from the list as an array.- Returns:
- an array containing all of the list's elements.
-
toString
Get the string representation of the list.- Specified by:
toString
in classOtpErlangObject
- Returns:
- the string representation of the list.
-
toString
-
encode
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:
encode
in classOtpErlangObject
- Parameters:
buf
- An output stream to which the encoded list should be written.
-
encode
-
equals
Determine if two lists are equal. Lists are equal if they have the same arity and all of the elements are equal.- Specified by:
equals
in classOtpErlangObject
- Parameters:
o
- the list to compare to.- Returns:
- true if the lists have the same arity and all the elements are equal.
-
match
Description copied from class:OtpErlangObject
Perform match operation against given term.- Overrides:
match
in classOtpErlangObject
- Parameters:
term
- the object to matchbindings
- variable bindings- Returns:
- true if match succeeded
-
bind
Description copied from class:OtpErlangObject
Make new Erlang term replacing variables with the respective values from bindings argument(s).- Overrides:
bind
in classOtpErlangObject
- Parameters:
binds
- variable bindings- Returns:
- new term
- Throws:
OtpErlangException
-
getLastTail
-
doHashCode
protected int doHashCode()- Overrides:
doHashCode
in classOtpErlangObject
-
clone
- Overrides:
clone
in classOtpErlangObject
-
iterator
- Specified by:
iterator
in interfaceIterable<OtpErlangObject>
-
isProper
public boolean isProper()- Returns:
- true if the list is proper, i.e. the last tail is nil
-
getHead
-
getTail
-
getNthTail
-
stringValue
Convert 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.InvalidParameterException
- if any integer is not within the Unicode range.- See Also:
-