gov.nasa.pds.label
Class Label

java.lang.Object
  extended by gov.nasa.pds.label.Label

public class Label
extends Object

Implements a mechanism for accessing labels and the objects they represent.

For PDS4 labels, the user should load a label file and access the objects as follows:

 Label label = Label.open(new File("labelfile.xml");

 // Get the tables in the data file.
 List<TableObject> tables = label.getObjects(TableObject.class);

 // Read the table record-by-record.
 TableObject table = tables.get(0);
 TableRecord record = table.readNext();
 while (record != null) {
     ... process this record ...
 }

 label.close();
 

See the package gov.nasa.pds.object to see all the object types that can be represented in a PDS label.


Method Summary
 void close()
          Closes the label.
 LabelStandard getLabelStandard()
          Gets the label standard that the label conforms to.
 List<DataObject> getObjects()
          Gets the data objects represented by the label.
<T extends DataObject>
List<T>
getObjects(Class<T> clazz)
          Gets the data objects that are of a given class.
 Class<? extends Product> getProductClass()
          Gets the object class of the product.
 ProductType getProductType()
          Gets the type of the product, as an enumerated type.
 String getStandardVersion()
          Returns the version number of the label standard used by the product.
static Label open(File labelFile)
          Opens a label from a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

close

public void close()
Closes the label. All further calls on the label may generate errors.


open

public static Label open(File labelFile)
                  throws ParseException
Opens a label from a file.

Parameters:
labelFile - the label file
Returns:
the label
Throws:
ParseException - if there is an error reading the label from the file

getLabelStandard

public LabelStandard getLabelStandard()
Gets the label standard that the label conforms to.

Returns:
the label standard

getStandardVersion

public String getStandardVersion()
Returns the version number of the label standard used by the product.

Returns:
the label standard version number, as a string

getProductClass

public Class<? extends Product> getProductClass()
Gets the object class of the product.

Returns:
the product object class

getProductType

public ProductType getProductType()
Gets the type of the product, as an enumerated type.

Returns:
the product type

getObjects

public List<DataObject> getObjects()
                            throws Exception
Gets the data objects represented by the label.

Returns:
a list of data objects
Throws:
Exception - if there is an error accessing the objects in the product

getObjects

public <T extends DataObject> List<T> getObjects(Class<T> clazz)
                                      throws Exception
Gets the data objects that are of a given class.

Type Parameters:
T - the class of the objects desired
Parameters:
clazz - the class object of the object class
Returns:
a list of data objects
Throws:
Exception - if there is an error accessing the objects in the product


Copyright © 2013. All Rights Reserved.