Package com.ericsson.otp.erlang
Class OtpErlangString
- java.lang.Object
- 
- com.ericsson.otp.erlang.OtpErlangObject
- 
- com.ericsson.otp.erlang.OtpErlangString
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Cloneable
 
 public class OtpErlangString extends OtpErlangObject Provides a Java representation of Erlang strings.- 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 OtpErlangString(OtpErlangList list)Create an Erlang string from a list of integers.OtpErlangString(OtpInputStream buf)Create an Erlang string from a stream containing a string encoded in Erlang external format.OtpErlangString(java.lang.String str)Create an Erlang string from the given string.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intdoHashCode()voidencode(OtpOutputStream buf)Convert this string to the equivalent Erlang external representation.booleanequals(java.lang.Object o)Determine if two strings are equal.static booleanisValidCodePoint(int cp)Validate a code point according to Erlang definition; Unicode 3.0.static java.lang.StringnewString(byte[] bytes)Construct a String from a Latin-1 (ISO-8859-1) encoded byte array, if Latin-1 is available, otherwise use the default encoding.static int[]stringToCodePoints(java.lang.String s)Create Unicode code points from a String.java.lang.StringstringValue()Get the actual string contained in this object.java.lang.StringtoString()Get the printable version of the string contained in this object.
 
- 
- 
- 
Constructor Detail- 
OtpErlangStringpublic OtpErlangString(java.lang.String str) Create an Erlang string from the given string.
 - 
OtpErlangStringpublic OtpErlangString(OtpErlangList list) throws OtpErlangException Create an Erlang string from a list of integers.- Throws:
- OtpErlangException- for non-proper and non-integer lists.
- OtpErlangRangeException- if an integer in the list is not a valid Unicode code point according to Erlang.
 
 - 
OtpErlangStringpublic OtpErlangString(OtpInputStream buf) throws OtpErlangDecodeException Create an Erlang string from a stream containing a string encoded in Erlang external format.- Parameters:
- buf- the stream containing the encoded string.
- Throws:
- OtpErlangDecodeException- if the buffer does not contain a valid external representation of an Erlang string.
 
 
- 
 - 
Method Detail- 
stringValuepublic java.lang.String stringValue() Get the actual string contained in this object.- Returns:
- the raw string contained in this object, without regard to Erlang quoting rules.
- See Also:
- toString()
 
 - 
toStringpublic java.lang.String toString() Get the printable version of the string contained in this object.- Specified by:
- toStringin class- OtpErlangObject
- Returns:
- the string contained in this object, quoted.
- See Also:
- stringValue()
 
 - 
encodepublic void encode(OtpOutputStream buf) Convert this string to the equivalent Erlang external representation.- Specified by:
- encodein class- OtpErlangObject
- Parameters:
- buf- an output stream to which the encoded string should be written.
 
 - 
equalspublic boolean equals(java.lang.Object o) Determine if two strings are equal. They are equal if they represent the same sequence of characters. This method can be used to compare OtpErlangStrings with each other and with Strings.- Specified by:
- equalsin class- OtpErlangObject
- Parameters:
- o- the OtpErlangString or String to compare to.
- Returns:
- true if the strings consist of the same sequence of characters, false otherwise.
 
 - 
doHashCodeprotected int doHashCode() - Overrides:
- doHashCodein class- OtpErlangObject
 
 - 
stringToCodePointspublic static int[] stringToCodePoints(java.lang.String s) Create Unicode code points from a String.- Parameters:
- s- a String to convert to an Unicode code point array
- Returns:
- the corresponding array of integers representing Unicode code points
 
 - 
isValidCodePointpublic static boolean isValidCodePoint(int cp) Validate a code point according to Erlang definition; Unicode 3.0. That is; valid in the range U+0..U+10FFFF, but not in the range U+D800..U+DFFF (surrogat pairs).- Parameters:
- cp- the code point value to validate
- Returns:
- true if the code point is valid, false otherwise.
 
 - 
newStringpublic static java.lang.String newString(byte[] bytes) Construct a String from a Latin-1 (ISO-8859-1) encoded byte array, if Latin-1 is available, otherwise use the default encoding.
 
- 
 
-