Class Volume

java.lang.Object
com._1c.g5.v8.xmdb.impl.Volume

public class Volume extends Object
Wrapper around file with databse
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected FileChannel
     
    protected File
     
     
    protected final boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Volume(File file, boolean readOnly)
    Volume constructor, open or create volume file
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close volume
    static void
    copyFile(File sourceFile, File destFile)
    Copy file with all its contents
    void
    Drop volume (close and delete from disc)
    byte
    getByte(long offset)
    Read byte value from volume
    int
    getData(long offset, ByteBuffer bytes, int bytesPos, int size)
    Read data from volume
    Get volume file
    int
    getInt(long offset)
    Read integer value from volume
    long
    getLong(long offset)
    Read long value from volume
    boolean
    Test is volume empty (have zero size)
    long
    Get length of volume
    void
    putByte(long offset, byte value)
    Put byte value into volume
    void
    putData(long offset, ByteBuffer buf)
    Write entire buffer into volume
    void
    putData(long offset, ByteBuffer[] bufs)
    Write entire buffers into volume
    void
    putData(long offset, ByteBuffer data, int size)
    Write data from byteBuffer into volume
    void
    putInt(long offset, int value)
    Put integer value into volume
    void
    putLong(long offset, long value)
    Put long value into volume
    void
    renameTo(String newName)
    Rename db file to specified name
    void
    Reopen previously closed volume
    void
    Call sync command to write all cached data

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Volume

      public Volume(File file, boolean readOnly)
      Volume constructor, open or create volume file
      Parameters:
      file - the file where volume should store (not null)
      readOnly - open for read-only true flag (otherwise open in read-write mode)
  • Method Details

    • renameTo

      public void renameTo(String newName)
      Rename db file to specified name
      Parameters:
      newName - the new name (not null)
    • putData

      public void putData(long offset, ByteBuffer data, int size)
      Write data from byteBuffer into volume
      Parameters:
      offset - the offset in volume to where
      data - the buffer with data (reading from current bufer position) (not null)
      size - the size of data to write
    • getData

      public int getData(long offset, ByteBuffer bytes, int bytesPos, int size)
      Read data from volume
      Parameters:
      offset - the offset in volume
      bytes - the buffer to store readed data (not null)
      bytesPos - the offset in buffer to store data
      size - the size of data to read
      Returns:
      the number of bytes read.
    • putData

      public void putData(long offset, ByteBuffer buf)
      Write entire buffer into volume
      Parameters:
      offset - the offset in volume
      buf - buffer to write (not null)
    • putData

      public void putData(long offset, ByteBuffer[] bufs)
      Write entire buffers into volume
      Parameters:
      offset - the offset in volume
      bufs - the buffers to write (not null)
    • copyFile

      public static void copyFile(File sourceFile, File destFile)
      Copy file with all its contents
      Parameters:
      sourceFile - the source file (not null)
      destFile - the destination file (not null)
    • drop

      public void drop()
      Drop volume (close and delete from disc)
    • close

      public void close()
      Close volume
    • reopen

      public void reopen()
      Reopen previously closed volume
    • sync

      public void sync()
      Call sync command to write all cached data
    • isEmpty

      public boolean isEmpty()
      Test is volume empty (have zero size)
      Returns:
      true if volume is empty false otherwise.
    • length

      public long length()
      Get length of volume
      Returns:
      the volume length in bytes
    • getFile

      public File getFile()
      Get volume file
      Returns:
      volume file
    • putLong

      public void putLong(long offset, long value)
      Put long value into volume
      Parameters:
      offset - the offset in volume to write
      value - the value to write
    • getLong

      public long getLong(long offset)
      Read long value from volume
      Parameters:
      offset - the offset in volume to read from
      Returns:
      readed value
    • putInt

      public void putInt(long offset, int value)
      Put integer value into volume
      Parameters:
      offset - the offset in volume to write
      value - the valut to write
    • getInt

      public int getInt(long offset)
      Read integer value from volume
      Parameters:
      offset - the offset in volume to read from
      Returns:
      readed value
    • putByte

      public void putByte(long offset, byte value)
      Put byte value into volume
      Parameters:
      offset - the offset in volume to write
      value - the value to write
    • getByte

      public byte getByte(long offset)
      Read byte value from volume
      Parameters:
      offset - the offset in volume to read from
      Returns:
      readed value