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

## com.novell.java.io.spi
Interface DataAccessor

public interface DataAccessor

Provides an interface that allows read and/or write access to a given resource.

This interface is not needed or used by the user application layer, because it is an SPI interface, which provides for plugging a device into the com.novell.java.io Streams world.

The DataAccessor interface contains all the methods needed to implement InputStream, OutputStream, and RandomAccessFile. Any class that implements this interface can be accessed as a stream or a random access device if supported. It requires the construction of three fully instantiatable classes that operate on a DataAccessor: NInputStream, NOutputStream, and RandomAccess.

NInputStream, NOutputStream, and RandomAccess are the super classes of any corresponding classes that might extend them by supplying any custom data constructors. For example, NFileInputStream extends NInputStream by providing support for mode and data selector parameters that are custom to a file access.

For a device accessor to be able to operate, the device must be open. To facilitate the opening of a device, the DataAccessable interface is implemented.

Field Summary
`static int` | `RANDOM` RANDOM READ/WRITE Stream Type.
`static int` | `READ` Read/Input Stream Type.
`static int` | `WRITE` Write/Output Stream Type.

Method Summary
`int` | `available()` Returns the number of bytes left from the current stream position.
`void` | `close()` Closes the stream.
`void` | `flush()` Flushes all unwritten data.
`long` | `length()` Returns the total number of bytes in the stream.
`void` | `mark(int limit)` Marks the current stream position, which can be restored by calling reset().
`boolean` | `markSupported()` Determines whether the mark() and reset() methods are supported.
`int` | `read()` Reads and returns the next byte in the stream.
`int` | `read(byte[] b)` Reads bytes from the stream and fills a byte array with the data read.
`int` | `read(byte[] b, int off, int len)` Reads bytes from the stream and places the bytes at an offset within a byte array.
`void` | `reset()` Resets the stream position to the location saved by mark().
`long` | `seek(long pos)` Moves the stream position to an absolute position in the stream.
`void` | `setLength(long len)` Changes the stream length.
`long` | `skip(long n)` Moves the stream position forward a specified number of bytes.
`void` | `write(byte[] b)` Writes an array of bytes to the stream.
`void` | `write(byte[] b, int off, int len)` Writes a specified number of bytes from a byte array to the stream, starting at a specified offset in the array.
`void` | `write(int b)` Writes one byte to the stream.

Field Detail

### READ

    public static final int READ

  Read/Input Stream Type.

  (READ = 1)

### WRITE

    public static final int WRITE

  Write/Output Stream Type.

  (WRITE = 2)

### RANDOM

    public static final int RANDOM

  RANDOM READ/WRITE Stream Type.

  (RANDOM = 3)

Method Detail

### available

    public int available()
                  throws java.io.IOException

  Returns the number of bytes left from the current stream position.
  Returns:
    The number of bytes available to read (without blocking) from the current position in the stream.
  Throws:
    java.io.IOException - When there is an error getting the current stream position.

### close

    public void close()
               throws java.io.IOException

  Closes the stream.

  Any data that has been written to the stream but has not yet been written to actual resource is flushed before the stream is closed.

  Throws:
    java.io.IOException - When there is an error flushing data or closing the stream.

### flush

    public void flush()
               throws java.io.IOException

  Flushes all unwritten data.
  Throws:
    java.io.IOException - When there is an error writing the data.

### markSupported

    public boolean markSupported()

  Determines whether the mark() and reset() methods are supported.

  If this method returns FALSE, reset() will throw an exception if called.

  Returns:
    A boolean set to TRUE if mark() and reset() are supported; otherwise FALSE is returned.

### mark

    public void mark(int limit)

  Marks the current stream position, which can be restored by calling reset().
  Parameters:
    `limit` - The number of bytes that can be read before the mark is invalidated.

### read

    public int read()
             throws java.io.IOException

  Reads and returns the next byte in the stream.
  Returns:
    The next byte in the stream. Returns -1\ if end-of-file was reached.
  Throws:
    java.io.IOException - When an error occurs reading the next byte.

### read

    public int read(byte[] b)
             throws java.io.IOException

  Reads bytes from the stream and fills a byte array with the data read.

  'b.length' bytes are read and stored in 'b'. If less than 'b.length' bytes are read, the the end-of-file was reached. If no bytes are read and end-of-file was reached, then -1 is returned.

  Parameters:
    `b` - The byte array to which to write.
  Returns:
    The number of bytes actually read, or -1 if end-of-file was reached.
  Throws:
    java.io.IOException - When an error occurs reading bytes from the stream.

### read

    public int read(byte[] b,
                    int off,
                    int len)
             throws java.io.IOException

  Reads bytes from the stream and places the bytes at an offset within a byte array.

  'len' bytes are read into 'b' starting at position off. If less than 'len' bytes are read, then the end-of-file was reached. If no bytes are read and end-of-file was reached, -1 is returned.

  Parameters:
    `b` - The byte array to which to write.
    `off` - The array offset where writing should start.
    `len` - The number of bytes to read.
  Returns:
    The number of bytes actually read, or -1 if end-of-file was reached.
  Throws:
    java.io.IOException - When an error occurs reading bytes from the stream.

### write

    public void write(int b)
               throws java.io.IOException

  Writes one byte to the stream.
  Parameters:
    `b` - The byte to write.
  Throws:
    java.io.IOException - When an error occurs writing the byte.

### write

    public void write(byte[] b)
               throws java.io.IOException

  Writes an array of bytes to the stream.

  'b.length' bytes are written.

  Parameters:
    `b` - The byte array to write.
  Throws:
    java.io.IOException - When an error occurs writing the bytes.

### write

    public void write(byte[] b,
                      int off,
                      int len)
               throws java.io.IOException

  Writes a specified number of bytes from a byte array to the stream, starting at a specified offset in the array.
  Parameters:
    `b` - The source array.
    `off` - The array offset from which to start writing.
    `len` - The number of bytes to write.
  Throws:
    java.io.IOException - When an error occurs writing the bytes.

### reset

    public void reset()
               throws java.io.IOException

  Resets the stream position to the location saved by mark().

  If mark() and reset() are not supported by the stream, an exception is always thrown when reset() is called.

  Throws:
    java.io.IOException - When an error occurs moving the current stream position to the saved location.

### skip

    public long skip(long n)
              throws java.io.IOException

  Moves the stream position forward a specified number of bytes.
  Parameters:
    `n` - The number of bytes to skip.
  Returns:
    The number of bytes skipped.
  Throws:
    java.io.IOException - When an error occurs in changing the stream position.

### length

    public long length()
                throws java.io.IOException

  Returns the total number of bytes in the stream.
  Returns:
    The total number of bytes contained in the stream.
  Throws:
    java.io.IOException - When an error occurs getting the stream's length.

### seek

    public long seek(long pos)
              throws java.io.IOException

  Moves the stream position to an absolute position in the stream.
  Parameters:
    `pos` - The absolute position to which to move.
  Returns:
    The absolute position moved to.
  Throws:
    java.io.IOException - When an error occurs setting stream position.

### setLength

    public void setLength(long len)
                   throws java.io.IOException

  Changes the stream length.

  If the stream is smaller than the desired length, the stream is extended to the desired length using a byte value 0. If the stream is larger than the desired length, the stream is truncated at the desired length.

  Parameters:
    `len` - The desired absolute length of the stream.
  Throws:
    java.io.IOException - When an error occurs setting the length of the stream.

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