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 java.lang.ObjectDefines a base type for objects within a label.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.nio.channels.SeekableByteChannelchannelprotected DataObjectLocationdataObjectLocationprotected FilefileObjectprotected java.lang.StringlocalIdentifierprotected java.lang.Stringnameprotected longoffsetprotected java.net.URLparentDir
-
Constructor Summary
Constructors Modifier Constructor Description protectedDataObject(java.io.File parentDir, long offset, long size)protectedDataObject(java.io.File parentDir, File fileObject, long offset, long size)protectedDataObject(java.net.URL parentDir, File fileObject, long offset, long size, DataObjectLocation location)protectedDataObject(java.net.URL parentDir, File fileObject, long offset, long size, DataObjectLocation location, java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseChannel()Closes the underlying channel to the data.java.nio.channels.SeekableByteChannelgetChannel()Gets aSeekableByteChannelfor accessing the data object.java.net.URLgetDataFile()Gets a url that refers to the data file for this object.DataObjectLocationgetDataObjectLocation()java.io.InputStreamgetInputStream()Gets an input stream to the data object.java.lang.StringgetLocalIdentifier()java.lang.StringgetName()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.voidsetDataObjectLocation(DataObjectLocation dataObjectLocation)voidsetLocalIdentifier(java.lang.String localIdentifier)voidsetName(java.lang.String name)protected voidsetSize(long newSize)
-
-
-
Field Detail
-
parentDir
protected java.net.URL parentDir
-
fileObject
protected File fileObject
-
offset
protected long offset
-
name
protected java.lang.String name
-
localIdentifier
protected java.lang.String localIdentifier
-
channel
protected java.nio.channels.SeekableByteChannel channel
-
dataObjectLocation
protected DataObjectLocation dataObjectLocation
-
-
Constructor Detail
-
DataObject
protected DataObject(java.io.File parentDir, long offset, long size) throws java.io.IOException- Throws:
java.io.IOException
-
DataObject
protected DataObject(java.io.File parentDir, File fileObject, long offset, long size) throws java.io.IOException- Throws:
java.io.IOException
-
DataObject
protected DataObject(java.net.URL parentDir, File fileObject, long offset, long size, DataObjectLocation location) throws java.io.IOException, java.net.URISyntaxException- Throws:
java.io.IOExceptionjava.net.URISyntaxException
-
DataObject
protected DataObject(java.net.URL parentDir, File fileObject, long offset, long size, DataObjectLocation location, java.lang.String name) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Detail
-
getDataFile
public java.net.URL getDataFile() throws java.net.MalformedURLExceptionGets a url that refers to the data file for this object.- Returns:
- a
URLfor the file containing the data object - Throws:
java.net.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
public java.io.InputStream getInputStream() throws java.io.IOExceptionGets 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:
java.io.FileNotFoundException- if the data file cannot be foundjava.io.IOException- if there is an error reading the data file
-
getChannel
public java.nio.channels.SeekableByteChannel getChannel() throws java.io.IOExceptionGets 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:
java.io.IOException- if there is an error reading the data file
-
closeChannel
public void closeChannel()
Closes the underlying channel to the data.
-
getName
public java.lang.String getName()
-
setName
public void setName(java.lang.String name)
-
getDataObjectLocation
public DataObjectLocation getDataObjectLocation()
-
setDataObjectLocation
public void setDataObjectLocation(DataObjectLocation dataObjectLocation)
-
getLocalIdentifier
public java.lang.String getLocalIdentifier()
-
setLocalIdentifier
public void setLocalIdentifier(java.lang.String localIdentifier)
-
-