Package org.opencms.jlan
Class CmsFileBuffer
java.lang.Object
org.opencms.jlan.CmsFileBuffer
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
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
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.
-
Constructor Details
-
CmsFileBuffer
public CmsFileBuffer()
-
-
Method Details
-
getContents
Gets the contents of this buffer as a byte array.- Returns:
- the file content
-
getLength
Gets the length of the file content.- Returns:
- the content length
-
getPosition
Gets the current write position.- Returns:
- the current write position
-
init
Initializes the file content data.- Parameters:
data
- the file content data
-
read
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
Changes the write position.- Parameters:
newPos
- the new write position
-
truncate
Changes the size of this buffer.- Parameters:
size
- the new size
-
write
Writes the data to the internal buffer.- Parameters:
data
- the data to write
-