Package gov.nasa.pds.label.object
Class DataObject
java.lang.Object
gov.nasa.pds.label.object.DataObject
- Direct Known Subclasses:
ArrayObject,GenericObject,TableObject
public abstract class DataObject extends Object
Defines a base type for objects within a label.
-
Constructor Summary
Constructors Modifier Constructor Description protectedDataObject(File parentDir, File fileObject, long offset, long size)protectedDataObject(URL parentDir, File fileObject, long offset, long size) -
Method Summary
Modifier and Type Method Description voidcloseChannel()Closes the underlying channel to the data.SeekableByteChannelgetChannel()Gets aSeekableByteChannelfor accessing the data object.URLgetDataFile()Gets a url that refers to the data file for this object.InputStreamgetInputStream()Gets an input stream to the data object.longgetOffset()Gets the offset within the data file where the object data begins.longgetSize()Gets the size of the data object within the data file.protected voidsetSize(long newSize)
-
Constructor Details
-
DataObject
- Throws:
IOException
-
DataObject
- Throws:
IOException
-
-
Method Details
-
getDataFile
Gets a url that refers to the data file for this object.- Returns:
- a
URLfor the file containing the data object - Throws:
MalformedURLException
-
getOffset
public long getOffset()Gets the offset within the data file where the object data begins.- Returns:
- the offset to the data
-
getSize
public long getSize()Gets the size of the data object within the data file.- Returns:
- the size of the data object, in bytes
-
setSize
protected void setSize(long newSize) -
getInputStream
Gets an input stream to the data object. This input stream will read from the first byte in the data object to the last byte within that object. Other bytes outside of the range for the data object will not be accessed.- Returns:
- an input stream to the data object
- Throws:
FileNotFoundException- if the data file cannot be foundIOException- if there is an error reading the data file
-
getChannel
Gets aSeekableByteChannelfor accessing the data object. The channel is read-only, and represents only the portion of the data file containing the data object. You must remember to call the closeChannel() method once reading of the data is finished.- Returns:
- a
SeekableByteChannelfor reading bytes from the data object - Throws:
IOException- if there is an error reading the data file
-
closeChannel
public void closeChannel()Closes the underlying channel to the data.
-