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 SummaryFields Modifier and Type Field Description protected java.nio.channels.SeekableByteChannelchannelprotected DataObjectLocationdataObjectLocationprotected FilefileObjectprotected java.lang.StringlocalIdentifierprotected java.lang.Stringnameprotected longoffsetprotected java.net.URLparentDir
 - 
Constructor SummaryConstructors 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 SummaryAll 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- 
parentDirprotected java.net.URL parentDir 
 - 
fileObjectprotected File fileObject 
 - 
offsetprotected long offset 
 - 
nameprotected java.lang.String name 
 - 
localIdentifierprotected java.lang.String localIdentifier 
 - 
channelprotected java.nio.channels.SeekableByteChannel channel 
 - 
dataObjectLocationprotected DataObjectLocation dataObjectLocation 
 
- 
 - 
Constructor Detail- 
DataObjectprotected DataObject(java.io.File parentDir, long offset, long size) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
DataObjectprotected DataObject(java.io.File parentDir, File fileObject, long offset, long size) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
DataObjectprotected DataObject(java.net.URL parentDir, File fileObject, long offset, long size, DataObjectLocation location) throws java.io.IOException, java.net.URISyntaxException- Throws:
- java.io.IOException
- java.net.URISyntaxException
 
 - 
DataObjectprotected 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- 
getDataFilepublic 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
 
 - 
getOffsetpublic long getOffset() Gets the offset within the data file where the object data begins.- Returns:
- the offset to the data
 
 - 
getSizepublic long getSize() Gets the size of the data object within the data file.- Returns:
- the size of the data object, in bytes
 
 - 
setSizeprotected void setSize(long newSize) 
 - 
getInputStreampublic 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 found
- java.io.IOException- if there is an error reading the data file
 
 - 
getChannelpublic 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
 
 - 
closeChannelpublic void closeChannel() Closes the underlying channel to the data.
 - 
getNamepublic java.lang.String getName() 
 - 
setNamepublic void setName(java.lang.String name) 
 - 
getDataObjectLocationpublic DataObjectLocation getDataObjectLocation() 
 - 
setDataObjectLocationpublic void setDataObjectLocation(DataObjectLocation dataObjectLocation) 
 - 
getLocalIdentifierpublic java.lang.String getLocalIdentifier() 
 - 
setLocalIdentifierpublic void setLocalIdentifier(java.lang.String localIdentifier) 
 
- 
 
-