Module org.cloudi

Class OtpErlangString

    • Constructor Detail

      • OtpErlangString

        public OtpErlangString​(String str)
        Create an Erlang string from the given string.
      • 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 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 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​(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.
      • stringToCodePoints

        public static int[] stringToCodePoints​(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).
        Parameters:
        cp - the code point value to validate
        Returns:
        true if the code point is valid, false otherwise.
      • newString

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