Package gov.nasa.pds.objectAccess
Class ByteWiseFileAccessor
java.lang.Object
gov.nasa.pds.objectAccess.ByteWiseFileAccessor
public class ByteWiseFileAccessor extends Object
Class that provides common I/O functionality for PDS data objects.
- 
Constructor SummaryConstructors Constructor Description ByteWiseFileAccessor(File file, long offset, int length, int records)Constructs aByteWiseFileAccessorobject which maps a region of a data file into memory.ByteWiseFileAccessor(URL url, long offset, int length)Constructor.ByteWiseFileAccessor(URL url, long offset, int length, int records)Constructs aByteWiseFileAccessorobject which maps a region of a data file into memory.ByteWiseFileAccessor(URL url, long offset, int length, int records, boolean checkSize)Constructs aByteWiseFileAccessorobject which maps a region of a data file into memory.
- 
Method SummaryModifier and Type Method Description longgetCurrentPosition()longgetFileContentSize()booleanhasRemaining()Checks to see if the buffer can still be read.voidmark()Marks the buffer.bytereadByte()Reads a byte from the buffer.byte[]readRecordBytes(int recordNum, int offset, int length)Readslengthbytes of data from a specified record at the given offset.voidreset()Resets the buffer.
- 
Constructor Details- 
ByteWiseFileAccessorpublic ByteWiseFileAccessor(File file, long offset, int length, int records) throws FileNotFoundException, IOExceptionConstructs aByteWiseFileAccessorobject which maps a region of a data file into memory.- Parameters:
- file- the data file
- offset- the offset within the data file
- length- the record length in bytes
- records- the number of records
- Throws:
- FileNotFoundException- If- filedoes not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading
- IOException- If an I/O error occurs
 
- 
ByteWiseFileAccessorpublic ByteWiseFileAccessor(URL url, long offset, int length, int records) throws FileNotFoundException, IOExceptionConstructs aByteWiseFileAccessorobject which maps a region of a data file into memory.- Parameters:
- url- the data file
- offset- the offset within the data file
- length- the record length in bytes
- records- the number of records
- Throws:
- FileNotFoundException- If- filedoes not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading
- IOException- If an I/O error occurs
 
- 
ByteWiseFileAccessorpublic ByteWiseFileAccessor(URL url, long offset, int length, int records, boolean checkSize) throws FileNotFoundException, IOExceptionConstructs aByteWiseFileAccessorobject which maps a region of a data file into memory.- Parameters:
- url- the data file
- offset- the offset within the data file
- length- the record length in bytes
- records- the number of records
- checkSize- check that the size of the data file is equal to the size of the table (length * records) + offset.
- Throws:
- FileNotFoundException- If- filedoes not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading
- IOException- If an I/O error occurs
 
- 
ByteWiseFileAccessorConstructor.- Parameters:
- url- The data file.
- offset- The offset within the data file.
- Throws:
- IOException- If an I/O error occurs.
 
 
- 
- 
Method Details- 
readRecordBytespublic byte[] readRecordBytes(int recordNum, int offset, int length)Readslengthbytes of data from a specified record at the given offset.- Parameters:
- recordNum- the record number to read bytes from (1-relative)
- offset- an offset within the record
- length- the number of bytes to read from the record
- Returns:
- an array of bytes
 
- 
readBytepublic byte readByte()Reads a byte from the buffer.- Returns:
- A byte.
 
- 
markpublic void mark()Marks the buffer.
- 
resetpublic void reset()Resets the buffer.
- 
hasRemainingpublic boolean hasRemaining()Checks to see if the buffer can still be read.- Returns:
- 'true' if there are more bytes to be read. 'false' otherwise.
 
- 
getCurrentPositionpublic long getCurrentPosition()
- 
getFileContentSizepublic long getFileContentSize()
 
-