Package gov.nasa.pds.label.object
Class DataObject
java.lang.Object
gov.nasa.pds.label.object.DataObject
- Direct Known Subclasses:
ArrayObject,GenericObject,TableObject
Defines a base type for objects within a label.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SeekableByteChannelprotected DataObjectLocationprotected Fileprotected Stringprotected Stringprotected longprotected URL -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDataObject(File parentDir, long offset, long size) protectedDataObject(File parentDir, File fileObject, long offset, long size) protectedDataObject(URL parentDir, File fileObject, long offset, long size, DataObjectLocation location) protectedDataObject(URL parentDir, File fileObject, long offset, long size, DataObjectLocation location, String name) -
Method Summary
Modifier and TypeMethodDescriptionvoidCloses the underlying channel to the data.Gets aSeekableByteChannelfor accessing the data object.Gets a url that refers to the data file for this object.Gets an input stream to the data object.getName()longGets the offset within the data file where the object data begins.longgetSize()Gets the size of the data object within the data file.voidsetDataObjectLocation(DataObjectLocation dataObjectLocation) voidsetLocalIdentifier(String localIdentifier) voidprotected voidsetSize(long newSize)
-
Field Details
-
parentDir
-
fileObject
-
offset
protected long offset -
name
-
localIdentifier
-
channel
-
dataObjectLocation
-
-
Constructor Details
-
DataObject
- Throws:
IOException
-
DataObject
- Throws:
IOException
-
DataObject
protected DataObject(URL parentDir, File fileObject, long offset, long size, DataObjectLocation location) throws IOException, URISyntaxException - Throws:
IOExceptionURISyntaxException
-
DataObject
protected DataObject(URL parentDir, File fileObject, long offset, long size, DataObjectLocation location, String name) throws IOException - 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. -
getName
-
setName
-
getDataObjectLocation
-
setDataObjectLocation
-
getLocalIdentifier
-
setLocalIdentifier
-