Package gov.nasa.pds.objectAccess
Class ObjectAccess
- java.lang.Object
-
- gov.nasa.pds.objectAccess.ObjectAccess
-
- All Implemented Interfaces:
ObjectProvider
public class ObjectAccess extends java.lang.Object implements ObjectProvider
TheObjectAccess
class is a point of entry into parsed PDS (including PDS 4/XML-schema-labeled) objects.- Author:
- dcberrio
-
-
Constructor Summary
Constructors Constructor Description ObjectAccess()
Creates a new instance with the current local directory as the archive root path.ObjectAccess(java.io.File archiveRoot)
Constructs anObjectAccess
object and sets the archive root path.ObjectAccess(java.lang.String archiveRoot)
Constructs anObjectAccess
object and sets the archive root path.ObjectAccess(java.net.URL archiveRoot)
Constructs anObjectAccess
object and sets the archive root path.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getArchiveRoot()
Gets the root file path of the object archive(s) for this ObjectProvider.java.util.List<Array2DImage>
getArray2DImages(FileAreaObservational observationalFileArea)
Returns a list of Array2DImage objects given an observation file area object.java.util.List<Array3DImage>
getArray3DImages(FileAreaObservational observationalFileArea)
Returns a list of Array3DImage objects given an observation file area object.java.util.List<Array3DSpectrum>
getArray3DSpectrums(FileAreaObservational observationalFileArea)
Returns a list of Array3DSpectrum objects given an observation file area object.java.util.List<Array>
getArrays(FileArea fileArea)
Gets a list of Array objects from a file area.java.util.List<Array>
getArrays(FileAreaBrowse fileArea)
Gets a list of Array objects from a browse file area.java.util.List<Array>
getArrays(FileAreaObservational fileArea)
Gets a list of Array objects from an observational file area.java.util.List<java.lang.Object>
getDataObjects(Product product)
java.util.List<FieldBinary>
getFieldBinaries(TableBinary table)
Returns a list of FieldBinary objects given a table binary object.java.util.List<java.lang.Object>
getFieldBinaryAndGroupFieldBinaries(TableBinary table)
Returns a list of FieldBinary and GroupFieldBinary objects given a table binary object.java.util.List<java.lang.Object>
getFieldCharacterAndGroupFieldCharacters(TableCharacter table)
Returns a list of FieldCharacter and GroupFieldCharacter objects given a table character object.java.util.List<FieldCharacter>
getFieldCharacters(TableCharacter table)
Returns a list of FieldCharacter objects given a table character object.java.util.List<java.lang.Object>
getFieldDelimitedAndGroupFieldDelimiteds(TableDelimited table)
Returns a list of FieldDelimited and GroupFieldDelimited objects given a table delimited object.java.util.List<FieldDelimited>
getFieldDelimiteds(TableDelimited table)
Returns a list of FieldDelimited objects given a table delimited object.java.util.List<GroupFieldDelimited>
getGroupFieldDelimiteds(TableDelimited table)
Returns a list of GroupFieldDelimited objects given a table delimited object.java.util.List<java.lang.Object>
getHeaderObjects(FileArea fileArea)
java.util.List<java.lang.Object>
getHeaderObjects(FileAreaAncillary anciilaryFileArea)
java.util.List<java.lang.Object>
getHeaderObjects(FileAreaBrowse browseFileArea)
java.util.List<java.lang.Object>
getHeaderObjects(FileAreaMetadata fileArea)
java.util.List<java.lang.Object>
getHeaderObjects(FileAreaObservational observationalFileArea)
Returns a list of Header objectsjava.util.List<java.lang.Object>
getHeaderObjects(FileAreaObservationalSupplemental fileArea)
java.util.List<java.lang.Object>
getHeaderObjects(FileAreaUpdate fileArea)
long
getObjectLength(java.lang.Object obj)
ProductObservational
getObservationalProduct(java.lang.String relativeXmlFilePath)
Gets an instance of ProductObservational.long
getOffset(java.lang.Object obj)
<T> T
getProduct(java.io.File labelFile, java.lang.Class<T> productClass)
Reads a product label of a specified class, and returns an instance of that class as a result.<T> T
getProduct(java.net.URL label, java.lang.Class<T> productClass)
Reads a product label of a specified class, and returns an instance of that class as a result.java.net.URL
getRoot()
Gets the root file path of the object archive(s) for this ObjectProvider.java.util.List<TableBinary>
getTableBinaries(FileAreaObservational observationalFileArea)
Returns a list of TableBinary objects given an observation file area object.java.util.List<TableCharacter>
getTableCharacters(FileAreaObservational observationalFileArea)
Returns a list of TableCharacter objects given an observation file area object.java.util.List<TableDelimited>
getTableDelimiteds(FileAreaObservational observationalFileArea)
Returns a list of TableDelimited objects given an observation file area object.java.util.List<java.lang.Object>
getTableObjects(FileArea fileArea)
java.util.List<java.lang.Object>
getTableObjects(FileAreaAncillary anciilaryFileArea)
java.util.List<java.lang.Object>
getTableObjects(FileAreaBrowse browseFileArea)
java.util.List<java.lang.Object>
getTableObjects(FileAreaObservational observationalFileArea)
Returns a list of table objects.java.util.List<java.lang.Object>
getTableObjects(FileAreaObservationalSupplemental observationalFileAreaSupplemental)
java.util.List<java.lang.Object>
getTablesAndImages(FileArea fileArea)
java.util.List<java.lang.Object>
getTablesAndImages(FileAreaBrowse browseFileArea)
java.util.List<java.lang.Object>
getTablesAndImages(FileAreaObservational observationalFileArea)
XMLLabelContext
getXMLLabelContext()
static boolean
isHeaderObject(java.lang.Object obj)
static boolean
isTableObject(java.lang.Object obj)
boolean
isTextObject(java.lang.Object obj)
void
setObservationalProduct(java.lang.String relativeXmlFilePath, ProductObservational product)
Writes a label given the product XML file.void
setObservationalProduct(java.lang.String relativeXmlFilePath, ProductObservational product, XMLLabelContext labelContext)
Writes a label given the product XML file.
-
-
-
Constructor Detail
-
ObjectAccess
public ObjectAccess() throws java.net.MalformedURLException, java.net.URISyntaxException
Creates a new instance with the current local directory as the archive root path.- Throws:
java.net.URISyntaxException
java.net.MalformedURLException
-
ObjectAccess
public ObjectAccess(java.lang.String archiveRoot) throws java.net.MalformedURLException, java.net.URISyntaxException
Constructs anObjectAccess
object and sets the archive root path.- Parameters:
archiveRoot
- the archive root path- Throws:
java.net.URISyntaxException
java.net.MalformedURLException
-
ObjectAccess
public ObjectAccess(java.io.File archiveRoot) throws java.net.MalformedURLException, java.net.URISyntaxException
Constructs anObjectAccess
object and sets the archive root path.- Parameters:
archiveRoot
- the archive root path- Throws:
java.net.URISyntaxException
java.net.MalformedURLException
-
ObjectAccess
public ObjectAccess(java.net.URL archiveRoot) throws java.net.URISyntaxException, java.net.MalformedURLException
Constructs anObjectAccess
object and sets the archive root path.- Parameters:
archiveRoot
- the archive root path- Throws:
java.net.URISyntaxException
java.net.MalformedURLException
-
-
Method Detail
-
getProduct
public <T> T getProduct(java.io.File labelFile, java.lang.Class<T> productClass) throws ParseException
Description copied from interface:ObjectProvider
Reads a product label of a specified class, and returns an instance of that class as a result.- Specified by:
getProduct
in interfaceObjectProvider
- Type Parameters:
T
- the product object class- Parameters:
labelFile
- the file containing the XML labelproductClass
- the product object class- Returns:
- an instance of the product object
- Throws:
ParseException
- if there is an error parsing the label
-
getProduct
public <T> T getProduct(java.net.URL label, java.lang.Class<T> productClass) throws ParseException
Description copied from interface:ObjectProvider
Reads a product label of a specified class, and returns an instance of that class as a result.- Specified by:
getProduct
in interfaceObjectProvider
- Type Parameters:
T
- the product object class- Parameters:
label
- the url containing the XML labelproductClass
- the product object class- Returns:
- an instance of the product object
- Throws:
ParseException
- if there is an error parsing the label
-
getObservationalProduct
public ProductObservational getObservationalProduct(java.lang.String relativeXmlFilePath)
Description copied from interface:ObjectProvider
Gets an instance of ProductObservational.- Specified by:
getObservationalProduct
in interfaceObjectProvider
- Parameters:
relativeXmlFilePath
- the XML file path and name of the product to obtain, relative to the ObjectAccess archive root- Returns:
- an instance of ProductObservational
-
setObservationalProduct
public void setObservationalProduct(java.lang.String relativeXmlFilePath, ProductObservational product) throws java.lang.Exception
Description copied from interface:ObjectProvider
Writes a label given the product XML file.- Specified by:
setObservationalProduct
in interfaceObjectProvider
- Parameters:
relativeXmlFilePath
- the XML file path and name of the product to set, relative to the ObjectAccess archive rootproduct
- The Product_Observational object to serialize into an XML file.- Throws:
java.lang.Exception
-
setObservationalProduct
public void setObservationalProduct(java.lang.String relativeXmlFilePath, ProductObservational product, XMLLabelContext labelContext) throws java.lang.Exception
Writes a label given the product XML file. This method assumes that the label will be written to the local file system. Therefore, the protocol of the ObjectAccess archive root must be a 'file'.- Specified by:
setObservationalProduct
in interfaceObjectProvider
- Parameters:
relativeXmlFilePath
- the XML file path and name of the product to set, relative to the ObjectAccess archive rootproduct
- The Product_Observational object to serialize into an XML file.labelContext
- A context to use when creating the XML file. Can be set to null.- Throws:
java.lang.Exception
- If there was an error creating the XML file.
-
getDataObjects
public java.util.List<java.lang.Object> getDataObjects(Product product) throws ParseException
- Specified by:
getDataObjects
in interfaceObjectProvider
- Throws:
ParseException
-
getArrays
public java.util.List<Array> getArrays(FileArea fileArea)
Description copied from interface:ObjectProvider
Gets a list of Array objects from a file area.- Specified by:
getArrays
in interfaceObjectProvider
- Parameters:
fileArea
- the file area.- Returns:
- an list of arrays, which may be empty.
-
getArrays
public java.util.List<Array> getArrays(FileAreaObservational fileArea)
Description copied from interface:ObjectProvider
Gets a list of Array objects from an observational file area.- Specified by:
getArrays
in interfaceObjectProvider
- Parameters:
fileArea
- the observational file area.- Returns:
- an list of arrays, which may be empty.
-
getArrays
public java.util.List<Array> getArrays(FileAreaBrowse fileArea)
Description copied from interface:ObjectProvider
Gets a list of Array objects from a browse file area.- Specified by:
getArrays
in interfaceObjectProvider
- Parameters:
fileArea
- the browse file area- Returns:
- an list of arrays, which may be empty
-
getArray2DImages
public java.util.List<Array2DImage> getArray2DImages(FileAreaObservational observationalFileArea)
Description copied from interface:ObjectProvider
Returns a list of Array2DImage objects given an observation file area object.- Specified by:
getArray2DImages
in interfaceObjectProvider
- Returns:
- a list of image objects
-
getArray3DImages
public java.util.List<Array3DImage> getArray3DImages(FileAreaObservational observationalFileArea)
Description copied from interface:ObjectProvider
Returns a list of Array3DImage objects given an observation file area object.- Specified by:
getArray3DImages
in interfaceObjectProvider
- Returns:
- a list of image objects
-
getArray3DSpectrums
public java.util.List<Array3DSpectrum> getArray3DSpectrums(FileAreaObservational observationalFileArea)
Description copied from interface:ObjectProvider
Returns a list of Array3DSpectrum objects given an observation file area object.- Specified by:
getArray3DSpectrums
in interfaceObjectProvider
- Returns:
- a list of image objects
-
getHeaderObjects
public java.util.List<java.lang.Object> getHeaderObjects(FileArea fileArea)
- Specified by:
getHeaderObjects
in interfaceObjectProvider
-
getHeaderObjects
public java.util.List<java.lang.Object> getHeaderObjects(FileAreaAncillary anciilaryFileArea)
- Specified by:
getHeaderObjects
in interfaceObjectProvider
-
getHeaderObjects
public java.util.List<java.lang.Object> getHeaderObjects(FileAreaObservational observationalFileArea)
Description copied from interface:ObjectProvider
Returns a list of Header objects- Specified by:
getHeaderObjects
in interfaceObjectProvider
- Returns:
- a list of Header objects
-
getHeaderObjects
public java.util.List<java.lang.Object> getHeaderObjects(FileAreaBrowse browseFileArea)
- Specified by:
getHeaderObjects
in interfaceObjectProvider
-
getHeaderObjects
public java.util.List<java.lang.Object> getHeaderObjects(FileAreaObservationalSupplemental fileArea)
-
getHeaderObjects
public java.util.List<java.lang.Object> getHeaderObjects(FileAreaMetadata fileArea)
-
getHeaderObjects
public java.util.List<java.lang.Object> getHeaderObjects(FileAreaUpdate fileArea)
-
getTableObjects
public java.util.List<java.lang.Object> getTableObjects(FileArea fileArea)
- Specified by:
getTableObjects
in interfaceObjectProvider
-
getTableObjects
public java.util.List<java.lang.Object> getTableObjects(FileAreaObservational observationalFileArea)
Description copied from interface:ObjectProvider
Returns a list of table objects.- Specified by:
getTableObjects
in interfaceObjectProvider
- Returns:
- a list of table objects
-
getTableObjects
public java.util.List<java.lang.Object> getTableObjects(FileAreaBrowse browseFileArea)
- Specified by:
getTableObjects
in interfaceObjectProvider
-
getTableObjects
public java.util.List<java.lang.Object> getTableObjects(FileAreaAncillary anciilaryFileArea)
- Specified by:
getTableObjects
in interfaceObjectProvider
-
getTableObjects
public java.util.List<java.lang.Object> getTableObjects(FileAreaObservationalSupplemental observationalFileAreaSupplemental)
- Specified by:
getTableObjects
in interfaceObjectProvider
-
getTablesAndImages
public java.util.List<java.lang.Object> getTablesAndImages(FileArea fileArea)
- Specified by:
getTablesAndImages
in interfaceObjectProvider
-
getTablesAndImages
public java.util.List<java.lang.Object> getTablesAndImages(FileAreaObservational observationalFileArea)
- Specified by:
getTablesAndImages
in interfaceObjectProvider
-
getTablesAndImages
public java.util.List<java.lang.Object> getTablesAndImages(FileAreaBrowse browseFileArea)
- Specified by:
getTablesAndImages
in interfaceObjectProvider
-
getTableCharacters
public java.util.List<TableCharacter> getTableCharacters(FileAreaObservational observationalFileArea)
Description copied from interface:ObjectProvider
Returns a list of TableCharacter objects given an observation file area object.- Specified by:
getTableCharacters
in interfaceObjectProvider
- Returns:
- list of TableCharacter objects
-
getTableBinaries
public java.util.List<TableBinary> getTableBinaries(FileAreaObservational observationalFileArea)
Description copied from interface:ObjectProvider
Returns a list of TableBinary objects given an observation file area object.- Specified by:
getTableBinaries
in interfaceObjectProvider
- Returns:
- list of TableBinary objects
-
getTableDelimiteds
public java.util.List<TableDelimited> getTableDelimiteds(FileAreaObservational observationalFileArea)
Description copied from interface:ObjectProvider
Returns a list of TableDelimited objects given an observation file area object.- Specified by:
getTableDelimiteds
in interfaceObjectProvider
- Returns:
- list of TableDelimited objects
-
getFieldCharacters
public java.util.List<FieldCharacter> getFieldCharacters(TableCharacter table)
Description copied from interface:ObjectProvider
Returns a list of FieldCharacter objects given a table character object.- Specified by:
getFieldCharacters
in interfaceObjectProvider
- Parameters:
table
- TableCharacter object- Returns:
- list of FieldCharacter objects
-
getFieldDelimiteds
public java.util.List<FieldDelimited> getFieldDelimiteds(TableDelimited table)
Description copied from interface:ObjectProvider
Returns a list of FieldDelimited objects given a table delimited object.- Specified by:
getFieldDelimiteds
in interfaceObjectProvider
- Parameters:
table
- TableDelimited object- Returns:
- list of FieldDelimited objects
-
getGroupFieldDelimiteds
public java.util.List<GroupFieldDelimited> getGroupFieldDelimiteds(TableDelimited table)
Description copied from interface:ObjectProvider
Returns a list of GroupFieldDelimited objects given a table delimited object.- Specified by:
getGroupFieldDelimiteds
in interfaceObjectProvider
- Parameters:
table
- TableDelimited object- Returns:
- list of GroupFieldDelimited objects
-
getFieldDelimitedAndGroupFieldDelimiteds
public java.util.List<java.lang.Object> getFieldDelimitedAndGroupFieldDelimiteds(TableDelimited table)
Description copied from interface:ObjectProvider
Returns a list of FieldDelimited and GroupFieldDelimited objects given a table delimited object.- Specified by:
getFieldDelimitedAndGroupFieldDelimiteds
in interfaceObjectProvider
- Parameters:
table
- TableDelimited object- Returns:
- list of FieldDelimited and GroupFieldDelimited objects
-
getFieldCharacterAndGroupFieldCharacters
public java.util.List<java.lang.Object> getFieldCharacterAndGroupFieldCharacters(TableCharacter table)
Description copied from interface:ObjectProvider
Returns a list of FieldCharacter and GroupFieldCharacter objects given a table character object.- Specified by:
getFieldCharacterAndGroupFieldCharacters
in interfaceObjectProvider
- Parameters:
table
- TableCharacter object- Returns:
- list of FieldCharacter and GroupFieldCharacter objects
-
getFieldBinaryAndGroupFieldBinaries
public java.util.List<java.lang.Object> getFieldBinaryAndGroupFieldBinaries(TableBinary table)
Description copied from interface:ObjectProvider
Returns a list of FieldBinary and GroupFieldBinary objects given a table binary object.- Specified by:
getFieldBinaryAndGroupFieldBinaries
in interfaceObjectProvider
- Parameters:
table
- TableBinary object- Returns:
- list of FieldBinary and GroupFieldBinary objects
-
getFieldBinaries
public java.util.List<FieldBinary> getFieldBinaries(TableBinary table)
Description copied from interface:ObjectProvider
Returns a list of FieldBinary objects given a table binary object.- Specified by:
getFieldBinaries
in interfaceObjectProvider
- Parameters:
table
- TableBinary object- Returns:
- list of FieldBinary objects
-
getArchiveRoot
public java.lang.String getArchiveRoot()
Description copied from interface:ObjectProvider
Gets the root file path of the object archive(s) for this ObjectProvider.- Specified by:
getArchiveRoot
in interfaceObjectProvider
- Returns:
- the root file path of the object archive(s) for this ObjectProvider
-
getRoot
public java.net.URL getRoot()
Description copied from interface:ObjectProvider
Gets the root file path of the object archive(s) for this ObjectProvider.- Specified by:
getRoot
in interfaceObjectProvider
- Returns:
- the root file path of the object archive(s) for this ObjectProvider
-
getXMLLabelContext
public XMLLabelContext getXMLLabelContext()
-
isTableObject
public static boolean isTableObject(java.lang.Object obj)
-
isHeaderObject
public static boolean isHeaderObject(java.lang.Object obj)
-
isTextObject
public boolean isTextObject(java.lang.Object obj)
-
getOffset
public long getOffset(java.lang.Object obj)
- Specified by:
getOffset
in interfaceObjectProvider
-
getObjectLength
public long getObjectLength(java.lang.Object obj)
- Specified by:
getObjectLength
in interfaceObjectProvider
-
-