Package org.opencms.jlan
Class CmsFileBuffer
- java.lang.Object
-
- org.opencms.jlan.CmsFileBuffer
-
public class CmsFileBuffer extends java.lang.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 CmsFileBuffer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getContents()Gets the contents of this buffer as a byte array.longgetLength()Gets the length of the file content.longgetPosition()Gets the current write position.voidinit(byte[] data)Initializes the file content data.intread(byte[] dest, int length, int bufferOffset, int fileOffset)Transfers data from this buffer to a byte array.voidseek(long newPos)Changes the write position.voidtruncate(int size)Changes the size of this buffer.voidwrite(byte[] data)Writes the data to the internal buffer.
-
-
-
Constructor Detail
-
CmsFileBuffer
public CmsFileBuffer()
-
-
Method Detail
-
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 arraylength- the number of bytes to transferbufferOffset- the start index for the target bufferfileOffset- 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
-
-