gov.nasa.pds.label.object
Class DataObject

java.lang.Object
  extended by 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
protected DataObject(File parentDir, File fileObject, long offset, long size)
           
 
Method Summary
 ByteBuffer getBuffer()
          Gets a ByteBuffer for accessing the data object.
 File getDataFile()
          Gets a file that refers to the data file for this object.
 InputStream getInputStream()
          Gets an input stream to the data object.
 long getOffset()
          Gets the offset within the data file where the object data begins.
 long getSize()
          Gets the size of the data object within the data file.
protected  void setSize(long newSize)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataObject

protected DataObject(File parentDir,
                     File fileObject,
                     long offset,
                     long size)
Method Detail

getDataFile

public File getDataFile()
Gets a file that refers to the data file for this object.

Returns:
a File for the file containing the data object

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 InputStream getInputStream()
                           throws FileNotFoundException,
                                  IOException
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 found
IOException - if there is an error reading the data file

getBuffer

public ByteBuffer getBuffer()
                     throws FileNotFoundException,
                            IOException
Gets a ByteBuffer for accessing the data object. The buffer is read-only, and represents only the portion of the data file containing the data object.

Returns:
a ByteBuffer for reading bytes from the data object
Throws:
FileNotFoundException - if the data file cannot be found
IOException - if there is an error reading the data file


Copyright © 2013. All Rights Reserved.