Class ObjectAccess

  • All Implemented Interfaces:
    ObjectProvider

    public class ObjectAccess
    extends java.lang.Object
    implements ObjectProvider
    The ObjectAccess class is a point of entry into parsed PDS (including PDS 4/XML-schema-labeled) objects.
    Author:
    dcberrio
    • 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 an ObjectAccess 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 an ObjectAccess 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 an ObjectAccess 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 interface ObjectProvider
        Type Parameters:
        T - the product object class
        Parameters:
        labelFile - the file containing the XML label
        productClass - 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 interface ObjectProvider
        Type Parameters:
        T - the product object class
        Parameters:
        label - the url containing the XML label
        productClass - 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 interface ObjectProvider
        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 interface ObjectProvider
        Parameters:
        relativeXmlFilePath - the XML file path and name of the product to set, relative to the ObjectAccess archive root
        product - 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 interface ObjectProvider
        Parameters:
        relativeXmlFilePath - the XML file path and name of the product to set, relative to the ObjectAccess archive root
        product - 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.
      • 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 interface ObjectProvider
        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 interface ObjectProvider
        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 interface ObjectProvider
        Parameters:
        fileArea - the browse file area
        Returns:
        an list of arrays, which may be empty
      • getHeaderObjects

        public java.util.List<java.lang.Object> getHeaderObjects​(FileAreaMetadata fileArea)
      • getHeaderObjects

        public java.util.List<java.lang.Object> getHeaderObjects​(FileAreaUpdate fileArea)
      • 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 interface ObjectProvider
        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 interface ObjectProvider
        Parameters:
        table - TableDelimited object
        Returns:
        list of FieldDelimited 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 interface ObjectProvider
        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 interface ObjectProvider
        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 interface ObjectProvider
        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 interface ObjectProvider
        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 interface ObjectProvider
        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 interface ObjectProvider
        Returns:
        the root file path of the object archive(s) for this ObjectProvider
      • 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 interface ObjectProvider