## 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
implements java.io.Serializable, java.lang.Cloneable

Provides a Java representation of Erlang strings.

See Also:
  Serialized Form

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
`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 Summary
`protected int` `doHashCode()`
`void` `encode(OtpOutputStream buf)` Convert this string to the equivalent Erlang external representation.
`boolean` `equals(java.lang.Object o)` Determine if two strings are equal.
`static boolean` `isValidCodePoint(int cp)` Validate a code point according to Erlang definition; Unicode 3.0.
`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.
`static int[]` `stringToCodePoints(java.lang.String s)` Create Unicode code points from a String.
`java.lang.String` `stringValue()` Get the actual string contained in this object.
`java.lang.String` `toString()` Get the printable version of the string contained in this object.

Methods inherited from class com.ericsson.otp.erlang.OtpErlangObject
`clone, decode, hashCode`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### OtpErlangString

    public OtpErlangString(java.lang.String str)

  Create an Erlang string from the given string.

### OtpErlangString

    public 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.

### OtpErlangString

    public 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

### stringValue

    public 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()`

### toString

    public java.lang.String toString()

  Get the printable version of the string contained in this object.

  Specified by:
    `toString` in class `OtpErlangObject`
  Returns:
    the string contained in this object, quoted.
  See Also:
    `stringValue()`

### encode

    public void encode(OtpOutputStream buf)

  Convert this string to the equivalent Erlang external representation.

  Specified by:
    `encode` in class `OtpErlangObject`
  Parameters:
    `buf` - an output stream to which the encoded string should be written.

### equals

    public 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:
    `equals` in 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.

### doHashCode

    protected int doHashCode()

  Overrides:
    `doHashCode` in class `OtpErlangObject`

### stringToCodePoints

    public 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

### 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), nor U+FFFE..U+FFFF (non-characters).

  Parameters:
    `cp` - the code point value to validate
  Returns:
    true if the code point is valid, false otherwise.

### newString

    public 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.