Class Surrogate.Parser

  • Enclosing class:
    Surrogate

    public static class Surrogate.Parser
    extends java.lang.Object
    Surrogate parsing support. Charset implementations may use instances of this class to handle the details of parsing UTF-16 surrogate pairs.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int character  
      private java.nio.charset.CoderResult error  
      private boolean isPair  
    • Constructor Summary

      Constructors 
      Constructor Description
      Parser()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int character()
      Returns the UCS-4 character previously parsed.
      java.nio.charset.CoderResult error()
      If the previous parse operation detected an error, return the object describing that error.
      int increment()
      Returns the number of UTF-16 characters consumed by the previous parse.
      boolean isPair()
      Tells whether or not the previously-parsed UCS-4 character was originally represented by a surrogate pair.
      int parse​(char c, char[] ia, int ip, int il)
      Parses a UCS-4 character from the given source buffer, handling surrogates.
      int parse​(char c, java.nio.CharBuffer in)
      Parses a UCS-4 character from the given source buffer, handling surrogates.
      java.nio.charset.CoderResult unmappableResult()
      Returns an unmappable-input result object, with the appropriate input length, for the previously-parsed character.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • character

        private int character
      • error

        private java.nio.charset.CoderResult error
      • isPair

        private boolean isPair
    • Constructor Detail

      • Parser

        public Parser()
    • Method Detail

      • character

        public int character()
        Returns the UCS-4 character previously parsed.
      • isPair

        public boolean isPair()
        Tells whether or not the previously-parsed UCS-4 character was originally represented by a surrogate pair.
      • increment

        public int increment()
        Returns the number of UTF-16 characters consumed by the previous parse.
      • error

        public java.nio.charset.CoderResult error()
        If the previous parse operation detected an error, return the object describing that error.
      • unmappableResult

        public java.nio.charset.CoderResult unmappableResult()
        Returns an unmappable-input result object, with the appropriate input length, for the previously-parsed character.
      • parse

        public int parse​(char c,
                         java.nio.CharBuffer in)
        Parses a UCS-4 character from the given source buffer, handling surrogates.
        Parameters:
        c - The first character
        in - The source buffer, from which one more character will be consumed if c is a high surrogate
        Returns:
        Either a parsed UCS-4 character, in which case the isPair() and increment() methods will return meaningful values, or -1, in which case error() will return a descriptive result object
      • parse

        public int parse​(char c,
                         char[] ia,
                         int ip,
                         int il)
        Parses a UCS-4 character from the given source buffer, handling surrogates.
        Parameters:
        c - The first character
        ia - The input array, from which one more character will be consumed if c is a high surrogate
        ip - The input index
        il - The input limit
        Returns:
        Either a parsed UCS-4 character, in which case the isPair() and increment() methods will return meaningful values, or -1, in which case error() will return a descriptive result object