Package com.ericsson.otp.erlang
Class OtpErlangMap
- java.lang.Object
- 
- com.ericsson.otp.erlang.OtpErlangObject
- 
- com.ericsson.otp.erlang.OtpErlangMap
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Cloneable
 
 public class OtpErlangMap extends OtpErlangObject Provides a Java representation of Erlang maps. Maps are created from one or more arbitrary Erlang terms.The arity of the map is the number of elements it contains. The keys and values can be retrieved as arrays and the value for a key can be queried. - 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 OtpErlangMap()Create an empty map.OtpErlangMap(OtpErlangObject[] keys, int kstart, int kcount, OtpErlangObject[] values, int vstart, int vcount)Create a map from an array of terms.OtpErlangMap(OtpErlangObject[] keys, OtpErlangObject[] values)Create a map from an array of keys and an array of values.OtpErlangMap(OtpInputStream buf)Create a map from a stream containing a map encoded in Erlang external format.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intarity()Get the arity of the map.<T> OtpErlangObjectbind(T binds)Make new Erlang term replacing variables with the respective values from bindings argument(s).java.lang.Objectclone()protected intdoHashCode()voidencode(OtpOutputStream buf)Convert this map to the equivalent Erlang external representation.java.util.Set<java.util.Map.Entry<OtpErlangObject,OtpErlangObject>>entrySet()make Set view of the map key-value pairsbooleanequals(java.lang.Object o)Determine if two maps are equal.OtpErlangObjectget(OtpErlangObject key)Get the specified value from the map.OtpErlangObject[]keys()Get all the keys from the map as an array.<T> booleanmatch(OtpErlangObject term, T binds)Perform match operation against given term.OtpErlangObjectput(OtpErlangObject key, OtpErlangObject value)Put value corresponding to key into the map.OtpErlangObjectremove(OtpErlangObject key)removes mapping for the key if present.java.lang.StringtoString()Get the string representation of the map.OtpErlangObject[]values()Get all the values from the map as an array.- 
Methods inherited from class com.ericsson.otp.erlang.OtpErlangObjectdecode, hashCode
 
- 
 
- 
- 
- 
Constructor Detail- 
OtpErlangMappublic OtpErlangMap() Create an empty map.
 - 
OtpErlangMappublic OtpErlangMap(OtpErlangObject[] keys, OtpErlangObject[] values) Create a map from an array of keys and an array of values.- Parameters:
- keys- the array of terms to create the map keys from.
- values- the array of terms to create the map values from.
- Throws:
- java.lang.IllegalArgumentException- if any array is empty (null) or contains null elements.
 
 - 
OtpErlangMappublic OtpErlangMap(OtpErlangObject[] keys, int kstart, int kcount, OtpErlangObject[] values, int vstart, int vcount) Create a map from an array of terms.- Parameters:
- keys- the array of terms to create the map from.
- kstart- the offset of the first key to insert.
- kcount- the number of keys to insert.
- values- the array of values to create the map from.
- vstart- the offset of the first value to insert.
- vcount- the number of values to insert.
- Throws:
- java.lang.IllegalArgumentException- if any array is empty (null) or contains null elements.
- java.lang.IllegalArgumentException- if kcount and vcount differ.
 
 - 
OtpErlangMappublic OtpErlangMap(OtpInputStream buf) throws OtpErlangDecodeException Create a map from a stream containing a map encoded in Erlang external format.- Parameters:
- buf- the stream containing the encoded map.
- Throws:
- OtpErlangDecodeException- if the buffer does not contain a valid external representation of an Erlang map.
 
 
- 
 - 
Method Detail- 
aritypublic int arity() Get the arity of the map.- Returns:
- the number of elements contained in the map.
 
 - 
putpublic OtpErlangObject put(OtpErlangObject key, OtpErlangObject value) Put value corresponding to key into the map. For detailed behavior description seeMap.put(Object, Object).- Parameters:
- key- key to associate value with
- value- value to associate with key
- Returns:
- previous value associated with key or null
 
 - 
removepublic OtpErlangObject remove(OtpErlangObject key) removes mapping for the key if present.- Parameters:
- key- key for which mapping is to be remove
- Returns:
- value associated with key or null
 
 - 
getpublic OtpErlangObject get(OtpErlangObject key) Get the specified value from the map.- Parameters:
- key- the key of the requested value.
- Returns:
- the requested value, of null if key is not a valid key.
 
 - 
keyspublic OtpErlangObject[] keys() Get all the keys from the map as an array.- Returns:
- an array containing all of the map's keys.
 
 - 
valuespublic OtpErlangObject[] values() Get all the values from the map as an array.- Returns:
- an array containing all of the map's values.
 
 - 
entrySetpublic java.util.Set<java.util.Map.Entry<OtpErlangObject,OtpErlangObject>> entrySet() make Set view of the map key-value pairs- Returns:
- a set containing key-value pairs
 
 - 
toStringpublic java.lang.String toString() Get the string representation of the map.- Specified by:
- toStringin class- OtpErlangObject
- Returns:
- the string representation of the map.
 
 - 
encodepublic void encode(OtpOutputStream buf) Convert this map to the equivalent Erlang external representation.- Specified by:
- encodein class- OtpErlangObject
- Parameters:
- buf- an output stream to which the encoded map should be written.
 
 - 
equalspublic boolean equals(java.lang.Object o) Determine if two maps are equal. Maps are equal if they have the same arity and all of the elements are equal.- Specified by:
- equalsin class- OtpErlangObject
- Parameters:
- o- the map to compare to.
- Returns:
- true if the maps have the same arity and all the elements are equal.
 
 - 
matchpublic <T> boolean match(OtpErlangObject term, T binds) Description copied from class:OtpErlangObjectPerform match operation against given term.- Overrides:
- matchin class- OtpErlangObject
- Parameters:
- term- the object to match
- binds- 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
 
 
- 
 
-