Class CmsFileBuffer

java.lang.Object
org.opencms.jlan.CmsFileBuffer

public class CmsFileBuffer extends Object
Buffer class which holds file contents for JLAN file access in memory before they are written to the VFS.

This is implemented as a CmsByteBuffer instance together with a 'position' index which marks the next write position

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Gets the contents of this buffer as a byte array.
    long
    Gets the length of the file content.
    long
    Gets the current write position.
    void
    init(byte[] data)
    Initializes the file content data.
    int
    read(byte[] dest, int length, int bufferOffset, int fileOffset)
    Transfers data from this buffer to a byte array.
    void
    seek(long newPos)
    Changes the write position.
    void
    truncate(int size)
    Changes the size of this buffer.
    void
    write(byte[] data)
    Writes the data to the internal buffer.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • getContents

      public byte[] getContents()
      Gets the contents of this buffer as a byte array.

      Returns:
      the file content
    • getLength

      public long getLength()
      Gets the length of the file content.

      Returns:
      the content length
    • getPosition

      public long getPosition()
      Gets the current write position.

      Returns:
      the current write position
    • init

      public void init(byte[] data)
      Initializes the file content data.

      Parameters:
      data - the file content data
    • read

      public int read(byte[] dest, int length, int bufferOffset, int fileOffset)
      Transfers data from this buffer to a byte array.

      Parameters:
      dest - the target byte array
      length - the number of bytes to transfer
      bufferOffset - the start index for the target buffer
      fileOffset - the start index for this instance
      Returns:
      the number of bytes read, or -1 if we are at the end of the file
    • seek

      public void seek(long newPos)
      Changes the write position.

      Parameters:
      newPos - the new write position
    • truncate

      public void truncate(int size)
      Changes the size of this buffer.

      Parameters:
      size - the new size
    • write

      public void write(byte[] data)
      Writes the data to the internal buffer.

      Parameters:
      data - the data to write