Xerces-J API: Class ChunkyByteArray

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.xerces.utils
Class ChunkyByteArray

    java.lang.Object
      |
      +--java.io.InputStream
            |
            +--org.apache.xerces.utils.ChunkyByteArray

public final class ChunkyByteArray
extends java.io.InputStream

This class is used for accessing the data provided by an InputStream. There are two ways in which this class is used. The first occurs when we are prescanning the start of the stream to determine the encoding being used. Since we do not require that the stream be positionable, we wrap it with an instance of this class. The first "chunk" of the file is read and the data may be accessed directly using the byteAt(offset) method. After we have determined the encoding of the byte stream, the instance of this class is passed on to the EntityReader that will process the data for the scanner. At this point, the reader may continue to access this instance using the byteAt method, which will continue to read the contents into chunks as required until end of input. An example of this is the UCSReader. Alternatively, the reader may access this instance as an InputStream which will first return any data that has been reading into the chunks, and will then return the remaining data from the original InputStream directly.

Version:

Constructor Summary
`ChunkyByteArray(java.io.InputStream is)` Constructor Reads the first chunk.

Method Summary
`boolean` | `atEOF(int offset)` Test to see if an offset is at the end of the input data.
`byte` | `byteAt(int offset)` Return a byte of input data at the given offset.
`void` | `close()` Closes this input Stream
`int` | `read()` Read a byte.
`int` | `read(byte[] buffer, int offset, int length)` Read bytes.
`void` | `rewind()` Reset position within the data stream back to the very beginning.

Methods inherited from class java.io.InputStream
`available, mark, markSupported, read, reset, skip`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ChunkyByteArray

    public ChunkyByteArray(java.io.InputStream is)
                    throws java.io.IOException

  Constructor Reads the first chunk.
  Parameters:
    `is` - The input stream containing the data of the entity.

Method Detail

### read

    public int read()
             throws java.io.IOException

  Read a byte.
  Overrides:
    read in class java.io.InputStream
  Returns:
    The next byte of the input data or -1 if there is no more data.

### read

    public int read(byte[] buffer,
                    int offset,
                    int length)
             throws java.io.IOException

  Read bytes.
  Overrides:
    read in class java.io.InputStream
  Parameters:
    `buffer` - The destination for the bytes returned. If null, then the data will discarded instead of returned.
    `offset` - The offset within the buffer where the first returned byte should be placed.
    `length` - The maximum number of bytes to place in the buffer or discard.
  Returns:
    The number of bytes actually placed in the buffer or discarded.

### rewind

    public void rewind()

  Reset position within the data stream back to the very beginning.

### byteAt

    public byte byteAt(int offset)
                throws java.io.IOException

  Return a byte of input data at the given offset.
  Parameters:
    `offset` - The offset in the data stream.
  Returns:
    The byte at the specified position within the data stream.

### atEOF

    public boolean atEOF(int offset)

  Test to see if an offset is at the end of the input data.
  Parameters:
    `offset` - A position in the data stream.
  Returns:
    `true` if the position is at the end of the data stream; `false` otherwise.

### close

    public void close()
               throws java.io.IOException

  Closes this input Stream
  Overrides:
    close in class java.io.InputStream
  Throws:
    java.io.IOException -

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999-2001 Apache XML Project. All Rights Reserved.