public class FileDataset extends java.lang.Object implements FileAccess
FileAccess
dataset interface.Constructor and Description |
---|
FileDataset(byte[] marshalledBytes) |
FileDataset(java.lang.String datasetIdentifier,
java.lang.String datasetDescription) |
Modifier and Type | Method and Description |
---|---|
void |
addFile(java.lang.String filename,
java.lang.String permissions)
Adds a file with the specified permission "r", "w" or "rw" to this
dataset.
|
boolean |
close()
Close access to this dataset.
|
byte[] |
getBytes()
A serialized representation of this dataset, which would allow one to
reconstruct and initialize it from this marshalled representation.
|
DataAvailabilityNotifier |
getDataAvailabilityNotifier()
Retrieve the data availability notifier for this dataset.
|
int |
getDatasetType()
Retrieve the type of the data set
|
java.lang.String |
getDescription()
Retrieve a description of the dataset
|
java.util.Enumeration |
getFilenames()
Retrieves the list of files in this dataset
|
java.lang.String |
getIdentifier()
Retrieve the identifier for this dataset.
|
java.util.Properties |
getInitializationDirectives() |
long |
getLastModificationTime()
Retrieve the last update to this dataset
|
long |
getPosition(java.lang.String fileName)
Retrieves the position of filePointer for the given dataset
|
boolean |
initializeDataset()
Invokes the initialization of the dataset.
|
boolean |
isAvailable()
A check to see if the dataset is available
|
boolean |
isDataAvailable()
This polls the dataset to see if data is available for consumption.
|
boolean |
isInitialized()
Check to see if the dataset has been initialized
|
boolean |
isPartOfDataset(java.lang.String fileName)
Checks to see if the file is part of a given dataset
|
static void |
main(java.lang.String[] args) |
boolean |
needsInitialization()
Indicates whether the dataset needs to be initialized prior to being
used.
|
int |
read(java.lang.String filename,
byte[] bytesToRead)
Attempts to read a set of bytes from the underlying file.
|
int |
read(java.lang.String fileName,
java.nio.ByteBuffer readBuffer)
Attempts to read a set of bytes from the underlying file.
|
void |
removeFile(java.lang.String filename)
Removes a file from this dataset.
|
void |
setPosition(java.lang.String fileName,
long newPosition)
Sets the position of filePointer for one of the file in the given
dataset.
|
long |
size(java.lang.String fileName)
Returns the current size of the file in question
|
boolean |
supportsDataAvailabilityNotifications()
Indicates whether this dataset supports dynamic data availability
notifications
|
int |
write(java.lang.String fileName,
byte[] bytesToWrite)
Writes a byte[] to a give file.
|
int |
write(java.lang.String fileName,
java.nio.ByteBuffer writeBuffer)
Write the specified Buffer to the file corresponding to the specified
file.
|
public FileDataset(java.lang.String datasetIdentifier, java.lang.String datasetDescription)
public FileDataset(byte[] marshalledBytes) throws java.io.IOException, DatasetException
java.io.IOException
DatasetException
public byte[] getBytes() throws java.io.IOException
Dataset
public java.util.Enumeration getFilenames()
FileAccess
getFilenames
in interface FileAccess
public boolean close() throws DatasetException
Dataset
close
in interface Dataset
true
if a graceful closure of this dataset was
performed;false
otherwise.DatasetException
public void addFile(java.lang.String filename, java.lang.String permissions) throws DatasetException
FileAccess
addFile
in interface FileAccess
filename
- The name of the filepermissions
- The permissions associated with this fileDatasetException
- If there are problems adding this filepublic void removeFile(java.lang.String filename) throws DatasetException
FileAccess
removeFile
in interface FileAccess
filename
- The name of the fileDatasetException
- If there are problems removing this filepublic DataAvailabilityNotifier getDataAvailabilityNotifier()
Dataset
getDataAvailabilityNotifier
in interface Dataset
public int getDatasetType()
Dataset
getDatasetType
in interface Dataset
public java.lang.String getDescription()
Dataset
getDescription
in interface Dataset
public java.lang.String getIdentifier()
Dataset
getIdentifier
in interface Dataset
public long getLastModificationTime()
Dataset
getLastModificationTime
in interface Dataset
public java.util.Properties getInitializationDirectives()
public boolean initializeDataset() throws DatasetException
Dataset
initializeDataset
in interface Dataset
true
if the dataset has been initialized;
false
otherwise.DatasetException
public boolean isAvailable()
Dataset
isAvailable
in interface Dataset
true
if the dataset is available;false
otherwise.public boolean isDataAvailable()
Dataset
isDataAvailable
in interface Dataset
true
if data is available on this dataset;
false
otherwise.public boolean needsInitialization()
Dataset
needsInitialization
in interface Dataset
true
if the dataset need initialization;
false
otherwise.public boolean isInitialized()
Dataset
isInitialized
in interface Dataset
true
if the dataset is initialized;
false
otherwise.public boolean supportsDataAvailabilityNotifications()
Dataset
supportsDataAvailabilityNotifications
in interface Dataset
true
if this dataset supports data availability
notifications;false
otherwise.public int read(java.lang.String filename, byte[] bytesToRead) throws DatasetException, java.io.IOException
FileAccess
read
in interface FileAccess
filename
- The file to be readbytesToRead
- The byte[] to be read intoDatasetException
- If there are problems retrieving the FileChannel
corresponding to the filejava.io.IOException
- If there are IO problems in performing the operationpublic int read(java.lang.String fileName, java.nio.ByteBuffer readBuffer) throws DatasetException, java.io.IOException
FileAccess
read
in interface FileAccess
fileName
- The file to be readreadBuffer
- The buffer to be read intoDatasetException
- If there are problems retrieving the FileChannel
corresponding to the filejava.io.IOException
- If there are IO problems in performing the operationpublic int write(java.lang.String fileName, byte[] bytesToWrite) throws DatasetException, java.io.IOException
FileAccess
write
in interface FileAccess
fileName
- The file to be written tobytesToWrite
- The byte[] to be written.DatasetException
- If there are problems retrieving the FileChannel
corresponding to the filejava.io.IOException
- If there are IO problems in performing the operationpublic int write(java.lang.String fileName, java.nio.ByteBuffer writeBuffer) throws DatasetException, java.io.IOException
FileAccess
write
in interface FileAccess
fileName
- The file to be written towriteBuffer
- The buffer holding the bytes to be writtenDatasetException
- If there are problems retrieving the FileChannel
corresponding to the filejava.io.IOException
- If there are IO problems in performing the operationpublic long getPosition(java.lang.String fileName) throws DatasetException, java.io.IOException
FileAccess
getPosition
in interface FileAccess
fileName
- The name of the file.DatasetException
- If there are problems retrieving the FileChannel
corresponding to the filejava.io.IOException
- If there are IO problems in performing the operationpublic void setPosition(java.lang.String fileName, long newPosition) throws DatasetException, java.io.IOException
FileAccess
setPosition
in interface FileAccess
fileName
- The filenewPosition
- The new position for the pointerDatasetException
- If there are problems retrieving the FileChannel
corresponding to the filejava.io.IOException
- If there are IO problems in performing the operationpublic long size(java.lang.String fileName) throws DatasetException, java.io.IOException
FileAccess
size
in interface FileAccess
fileName
- The name of the fileDatasetException
- If there are problems retrieving the FileChannel
corresponding to the filejava.io.IOException
- If there are IO problems in completing the operation.public boolean isPartOfDataset(java.lang.String fileName)
FileAccess
isPartOfDataset
in interface FileAccess
fileName
- The name of the filetrue
if the file is a part of the dataset;
false
otherwise.public static void main(java.lang.String[] args)
args
-