Class UTF16Buffer


  • public final class UTF16Buffer
    extends java.lang.Object
    An UTF-16 buffer that knows the start and end indeces of its unconsumed content.
    Version:
    $Id$
    Author:
    hsivonen
    • Constructor Summary

      Constructors 
      Constructor Description
      UTF16Buffer​(char[] buffer, int start, int end)
      Constructor for wrapping an existing UTF-16 code unit array.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void adjust​(boolean lastWasCR)
      Adjusts the start index to skip over the first character if it is a line feed and the previous character was a carriage return.
      char[] getBuffer()
      Returns the backing buffer.
      int getEnd()
      Returns the end index.
      int getStart()
      Returns the start index.
      boolean hasMore()
      Checks if the buffer has data left.
      void setEnd​(int end)
      Sets the end index.
      void setStart​(int start)
      Sets the start index.
      • Methods inherited from class java.lang.Object

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

      • UTF16Buffer

        public UTF16Buffer​(char[] buffer,
                           int start,
                           int end)
        Constructor for wrapping an existing UTF-16 code unit array.
        Parameters:
        buffer - the backing buffer
        start - the index of the first character to consume
        end - the index immediately after the last character to consume
    • Method Detail

      • getStart

        public int getStart()
        Returns the start index.
        Returns:
        the start index
      • setStart

        public void setStart​(int start)
        Sets the start index.
        Parameters:
        start - the start index
      • getBuffer

        public char[] getBuffer()
        Returns the backing buffer.
        Returns:
        the backing buffer
      • getEnd

        public int getEnd()
        Returns the end index.
        Returns:
        the end index
      • hasMore

        public boolean hasMore()
        Checks if the buffer has data left.
        Returns:
        true if there's data left
      • adjust

        public void adjust​(boolean lastWasCR)
        Adjusts the start index to skip over the first character if it is a line feed and the previous character was a carriage return.
        Parameters:
        lastWasCR - whether the previous character was a carriage return
      • setEnd

        public void setEnd​(int end)
        Sets the end index.
        Parameters:
        end - the end index