Documentation of 'org.apache.derby.impl.jdbc.UTF8Reader' Java class
UTF8Reader
org.apache.derby.impl.jdbc

Class UTF8Reader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Readable


    public final class UTF8Reader
    extends java.io.Reader
    Class for reading characters from streams encoded in the modified UTF-8 format.

    Note that we often operate on a special Derby stream. A Derby stream is possibly different from a "normal" stream in two ways; an encoded length is inserted at the head of the stream, and if the encoded length is 0 a Derby-specific end of stream marker is appended to the data.

    If the underlying stream is capable of repositioning itself on request, this class supports multiple readers on the same source stream in such a way that the various readers do not interfere with each other (except for serializing access). Each reader instance will have its own pointer into the stream, and request that the stream repositions itself before calling read/skip on the stream.

    See Also:
    PositionedStoreStream
    • Constructor Summary

      Constructors 
      Constructor and Description
      UTF8Reader(CharacterStreamDescriptor csd, org.apache.derby.impl.jdbc.ConnectionChild conChild, java.lang.Object sync)
      Constructs a reader on top of the source UTF-8 encoded stream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void close()
      Close the reader, disallowing further reads.
      int read()
      Reads a single character from the stream.
      int read(char[] cbuf, int off, int len)
      Reads characters into an array.
      int readInto(java.lang.StringBuffer sb, int len)
      Reads characters from the stream.
      long skip(long len)
      Skips characters.
      • Methods inherited from class java.io.Reader

        mark, markSupported, read, read, ready, reset
      • Methods inherited from class java.lang.Object

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

      • UTF8Reader

        public UTF8Reader(CharacterStreamDescriptor csd,
                          org.apache.derby.impl.jdbc.ConnectionChild conChild,
                          java.lang.Object sync)
                   throws java.io.IOException
        Constructs a reader on top of the source UTF-8 encoded stream.
        Parameters:
        csd - a description of and reference to the source stream
        conChild - the parent object / connection child
        sync - synchronization object used when accessing the underlying data stream
        Throws:
        java.io.IOException - if reading from the underlying stream fails
    • Method Detail

      • read

        public int read()
                 throws java.io.IOException
        Reads a single character from the stream.
        Overrides:
        read in class java.io.Reader
        Returns:
        A character or -1 if end of stream has been reached.
        Throws:
        java.io.IOException - if the stream has been closed, or an exception is raised while reading from the underlying stream
      • read

        public int read(char[] cbuf,
                        int off,
                        int len)
                 throws java.io.IOException
        Reads characters into an array.
        Specified by:
        read in class java.io.Reader
        Returns:
        The number of characters read, or -1 if the end of the stream has been reached.
        Throws:
        java.io.IOException
      • skip

        public long skip(long len)
                  throws java.io.IOException
        Skips characters.
        Overrides:
        skip in class java.io.Reader
        Parameters:
        len - the numbers of characters to skip
        Returns:
        The number of characters actually skipped.
        Throws:
        java.lang.IllegalArgumentException - if the number of characters to skip is negative
        java.io.IOException - if accessing the underlying stream fails
      • close

        public void close()
        Close the reader, disallowing further reads.
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in class java.io.Reader
      • readInto

        public int readInto(java.lang.StringBuffer sb,
                            int len)
                     throws java.io.IOException
        Reads characters from the stream.

        Due to internal buffering a smaller number of characters than what is requested might be returned. To ensure that the request is fulfilled, call this method in a loop until the requested number of characters is read or -1 is returned.

        Parameters:
        sb - the destination buffer
        len - maximum number of characters to read
        Returns:
        The number of characters read, or -1 if the end of the stream is reached.
        Throws:
        java.io.IOException

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.