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.
  • Field Details

    • parentDir

      protected URL parentDir
    • fileObject

      protected File fileObject
    • offset

      protected long offset
    • name

      protected String name
    • localIdentifier

      protected String localIdentifier
    • channel

      protected SeekableByteChannel channel
    • dataObjectLocation

      protected DataObjectLocation dataObjectLocation
  • Constructor Details

  • Method Details

    • getDataFile

      public URL getDataFile() throws MalformedURLException
      Gets a url that refers to the data file for this object.
      Returns:
      a URL for 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

      public InputStream getInputStream() throws 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
    • getChannel

      public SeekableByteChannel getChannel() throws IOException
      Gets a SeekableByteChannel for 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 SeekableByteChannel for 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

      public String getName()
    • setName

      public void setName(String name)
    • getDataObjectLocation

      public DataObjectLocation getDataObjectLocation()
    • setDataObjectLocation

      public void setDataObjectLocation(DataObjectLocation dataObjectLocation)
    • getLocalIdentifier

      public String getLocalIdentifier()
    • setLocalIdentifier

      public void setLocalIdentifier(String localIdentifier)