Package com.ericsson.otp.erlang
Class OtpErlangString
java.lang.Object
com.ericsson.otp.erlang.OtpErlangObject
com.ericsson.otp.erlang.OtpErlangString
- All Implemented Interfaces:
Serializable
,Cloneable
Provides a Java representation of Erlang strings.
- 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
ConstructorDescriptionOtpErlangString
(OtpErlangList list) Create an Erlang string from a list of integers.Create an Erlang string from a stream containing a string encoded in Erlang external format.OtpErlangString
(String str) Create an Erlang string from the given string. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
void
encode
(OtpOutputStream buf) Convert this string to the equivalent Erlang external representation.boolean
Determine if two strings are equal.static boolean
isValidCodePoint
(int cp) Validate a code point according to Erlang definition; Unicode 3.0.static 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.static int[]
Create Unicode code points from a String.Get the actual string contained in this object.toString()
Get the printable version of the string contained in this object.
-
Constructor Details
-
OtpErlangString
Create an Erlang string from the given string. -
OtpErlangString
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.
-
OtpErlangString
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 Details
-
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
Get the printable version of the string contained in this object.- Specified by:
toString
in classOtpErlangObject
- Returns:
- the string contained in this object, quoted.
- See Also:
-
encode
Convert this string to the equivalent Erlang external representation.- Specified by:
encode
in classOtpErlangObject
- Parameters:
buf
- an output stream to which the encoded string should be written.
-
equals
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:
equals
in classOtpErlangObject
- Parameters:
o
- the OtpErlangString or String to compare to.- Returns:
- true if the strings consist of the same sequence of characters, false otherwise.
-
doHashCode
protected int doHashCode()- Overrides:
doHashCode
in classOtpErlangObject
-
stringToCodePoints
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
-
isValidCodePoint
public 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.
-
newString
Construct a String from a Latin-1 (ISO-8859-1) encoded byte array, if Latin-1 is available, otherwise use the default encoding.
-