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

## org.basex.io
Class DataAccess

    java.lang.Object
      org.basex.io.DataAccess

    public final class DataAccess

extends Object

This class allows positional read and write access to a database file.

Author:
  Workgroup DBIS, University of Konstanz 2005-10, ISC License, Christian Gruen

Constructor Summary
`DataAccess(File f)` Constructor, initializing the file reader.

Method Summary
`void` | `close()` Closes the data access.
`org.basex.io.Buffer` | `cursor(long p)` Sets the disk cursor.
`void` | `flush()` Flushes the buffered data.
`long` | `length()` Returns file length.
`boolean` | `more()` Checks if more bytes can be read.
`long` | `pos()` Returns the current file position.
`byte` | `read1()` Reads a byte value.
`int` | `read4()` Reads an integer value.
`int` | `read4(long p)` Reads an integer value from the specified position.
`long` | `read5()` Reads a 5-byte value.
`long` | `read5(long p)` Reads a 5-byte value from the specified file offset.
`byte[]` | `readBytes(long from, long to)` Reads a number of bytes in range from -> to and returns them as array.
`int` | `readNum()` Reads the next compressed number and returns it as integer.
`int` | `readNum(long p)` Reads a `Num` value from disk.
`byte[]` | `readToken(long p)` Reads a token from disk.
`void` | `writeBytes(long p, byte[] v)` Appends a value to the file and return it's offset.
`void` | `writeInt(int v)` Writes an integer value to the specified output stream.

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

Constructor Detail

### DataAccess

    public DataAccess(File f)
               throws IOException

  Constructor, initializing the file reader.

  Parameters:
    `f` - the file to be read
  Throws:
    `IOException` - IO Exception

Method Detail

### flush

    public void flush()
               throws IOException

  Flushes the buffered data.

  Throws:
    `IOException` - I/O exception

### close

    public void close()
               throws IOException

  Closes the data access.

  Throws:
    `IOException` - I/O exception

### pos

    public long pos()

  Returns the current file position.

  Returns:
    text as byte array

### length

    public long length()

  Returns file length.

  Returns:
    file length

### more

    public boolean more()

  Checks if more bytes can be read.

  Returns:
    result of check

### read1

    public byte read1()

  Reads a byte value.

  Returns:
    integer value

### read4

    public int read4()

  Reads an integer value.

  Returns:
    integer value

### read4

    public int read4(long p)

  Reads an integer value from the specified position.

  Parameters:
    `p` - position
  Returns:
    integer value

### read5

    public long read5(long p)

  Reads a 5-byte value from the specified file offset.

  Parameters:
    `p` - position
  Returns:
    long value

### read5

    public long read5()

  Reads a 5-byte value.

  Returns:
    long value

### readNum

    public int readNum(long p)

  Reads a `Num` value from disk.

  Parameters:
    `p` - text position
  Returns:
    read num

### readToken

    public byte[] readToken(long p)

  Reads a token from disk.

  Parameters:
    `p` - text position
  Returns:
    text as byte array

### readBytes

    public byte[] readBytes(long from,
                            long to)

  Reads a number of bytes in range from -> to and returns them as array.

  Parameters:
    `from` - starting position for reading
    `to` - ending position for reading
  Returns:
    byte array

### writeBytes

    public void writeBytes(long p,
                           byte[] v)

  Appends a value to the file and return it's offset.

  Parameters:
    `p` - write position
    `v` - byte array to be appended

### cursor

    public org.basex.io.Buffer cursor(long p)

  Sets the disk cursor.

  Parameters:
    `p` - read position
  Returns:
    buffer

### readNum

    public int readNum()

  Reads the next compressed number and returns it as integer.

  Returns:
    next integer

### writeInt

    public void writeInt(int v)

  Writes an integer value to the specified output stream.

  Parameters:
    `v` - value to be written

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