public class FileSegment extends Object
Contains the details of a segment of file data.
Constructor and Description |
---|
FileSegment(FileSegmentInfo info,
boolean writeable)
Class constructor
|
Modifier and Type | Method and Description |
---|---|
void |
closeFile()
Close the temporary file
|
static FileSegment |
createSegment(FileSegmentInfo info,
String fname,
File tempDir,
boolean writeable)
Create a file segment
|
static FileSegment |
createSegment(FileSegmentInfo info,
String prefix,
String fname,
File tempDir,
boolean writeable)
Create a file segment
|
void |
createTemporaryFile()
Create the temporary file
|
void |
deleteTemporaryFile()
Delete the temporary file associated with this file segment
|
boolean |
fileExists()
Check if the temporary file exists
|
protected void |
finalize()
Object is about to be garbage collected
|
void |
flush()
Flush buffered output to the file
|
long |
getFileLength()
Return the temporary file length, or -1 if the file is not open
|
FileSegmentInfo |
getInfo()
Return the file segment information
|
boolean |
getLoadLock()
Get the load lock for this file.
|
long |
getReadableLength()
Return the readable file data length
|
String |
getTemporaryFile()
Return the temporary file path
|
boolean |
hasLoadError()
Check if the file load had an error
|
int |
hasStatus()
Return the segment status
|
boolean |
isDataAvailable()
Check if the file data is available
|
boolean |
isDataLoading()
Check if the file data is loaded or queued for loading
|
boolean |
isLoading()
Check if the file segment is being loaded
|
boolean |
isOpen()
Check if the temporary file is open
|
boolean |
isQueued()
Check if the file segment has a file request queued
|
boolean |
isSaveQueued()
Check if a save request is queued for this file segment
|
boolean |
isSaving()
Check if the file segment is being saved
|
boolean |
isUpdated()
Check if the file segment has been updated
|
boolean |
isWriteable()
Check if the file is writeable
|
void |
openFile()
Open the temporary file
|
int |
readBytes(byte[] buf,
int len,
int pos,
long fileOff)
Read a block of data from the segment file
|
void |
setReadableLength(long readable)
Set the readable data length for the file, used during data loading to allow the file to be read before
the file load completes.
|
void |
setStatus(int sts)
Set the segment load/update status
|
void |
setStatus(int sts,
boolean queued)
Set the segment load/update status and queued status
|
void |
signalDataAvailable()
Signal that the file data is available, any threads using the waitForData() method
will return so that the threads can access the file data.
|
String |
toString()
Return the file segment details as a string
|
void |
truncate(long siz)
Truncate the file to the specified size
|
void |
waitForData(long tmo)
Wait for another thread to load the file data
|
void |
writeBytes(byte[] buf,
int len,
int pos,
long fileOff)
Write a block of data to the segment file
|
public FileSegment(FileSegmentInfo info, boolean writeable)
Create a file segment to hold all data for a file.
info
- FileSegmentInfowriteable
- booleanpublic final long getFileLength() throws IOException
IOException
public final FileSegmentInfo getInfo()
public final long getReadableLength()
public final String getTemporaryFile()
public final boolean isDataLoading()
public final boolean isDataAvailable()
public final int hasStatus()
public final boolean hasLoadError()
public final void setReadableLength(long readable)
readable
- longpublic final void setStatus(int sts)
sts
- intpublic final void setStatus(int sts, boolean queued)
sts
- intqueued
- booleanpublic final boolean isOpen()
public final boolean isUpdated()
public final boolean isQueued()
public final boolean isSaveQueued()
public final boolean isSaving()
public final boolean isLoading()
public final boolean isWriteable()
public final boolean getLoadLock() throws InterruptedException
InterruptedException
public final void waitForData(long tmo)
tmo
- longpublic final void signalDataAvailable()
public final boolean fileExists()
public final void createTemporaryFile() throws IOException
IOException
public final void closeFile() throws IOException
IOException
public final void openFile() throws IOException
IOException
public final int readBytes(byte[] buf, int len, int pos, long fileOff) throws IOException
buf
- byte[]len
- intpos
- intfileOff
- longIOException
public final void writeBytes(byte[] buf, int len, int pos, long fileOff) throws IOException
buf
- byte[]len
- intpos
- intfileOff
- longIOException
public final void flush() throws IOException
IOException
public final void truncate(long siz) throws IOException
siz
- longIOException
public final void deleteTemporaryFile() throws IOException
IOException
public static final FileSegment createSegment(FileSegmentInfo info, String prefix, String fname, File tempDir, boolean writeable) throws IOException
info
- FileSegmentInfoprefix
- Stringfname
- StringtempDir
- Filewriteable
- booleanIOException
public static final FileSegment createSegment(FileSegmentInfo info, String fname, File tempDir, boolean writeable) throws IOException
info
- FileSegmentInfofname
- StringtempDir
- Filewriteable
- booleanIOException
public String toString()
Copyright © 2005–2018 Alfresco Software. All rights reserved.