Class XTCEDatabase


  • public final class XTCEDatabase
    extends XTCEDatabaseParser
    The XTCEDatabase class is the first core object to be used by a client that is working with an XTCE Database File.
    Author:
    David Overeem
    • Constructor Detail

      • XTCEDatabase

        public XTCEDatabase​(URL dbLocation,
                            boolean validateOnLoad,
                            boolean applyXIncludes,
                            boolean readOnly)
                     throws XTCEDatabaseException
        Constructor for use with an XTCE database file on the filesystem. Successfully constructing this object means that the XTCE database file was successfully loaded and methods can be called on the contents.
        Parameters:
        dbLocation - URL object containing the location of the XTCE document to load.
        validateOnLoad - boolean indicating if the XSD validation should be performed during the loading.
        applyXIncludes - boolean indicating if the XInclude processing for the loaded file should be applied or ignored.
        readOnly - boolean indicating if the document should be opened in a read-only context, which is faster because only the JAXB structure is created, avoiding the need to build the Document Object Model that is needed for round trip processing.
        Throws:
        XTCEDatabaseException - in the event that the file could not be successfully loaded in a valid state. This can be partly bypassed by not enabling the XSD validation, which is not recommended because it may de-stabilize the application using this data file.
      • XTCEDatabase

        public XTCEDatabase​(File dbFile,
                            boolean validateOnLoad,
                            boolean applyXIncludes,
                            boolean readOnly)
                     throws XTCEDatabaseException
        Constructor for use with an XTCE database file on the filesystem. Successfully constructing this object means that the XTCE database file was successfully loaded and methods can be called on the contents.
        Parameters:
        dbFile - File object containing the name and path to the XTCE database file to load and optionally validate.
        validateOnLoad - boolean indicating if the XSD validation should be performed during the loading.
        applyXIncludes - boolean indicating if the XInclude processing for the loaded file should be applied or ignored.
        readOnly - boolean indicating if the document should be opened in a read-only context, which is faster because only the JAXB structure is created, avoiding the need to build the Document Object Model that is needed for round trip processing.
        Throws:
        XTCEDatabaseException - in the event that the file could not be successfully loaded in a valid state. This can be partly bypassed by not enabling the XSD validation, which is not recommended because it may de-stabilize the application using this data file.
      • XTCEDatabase

        public XTCEDatabase​(InputStream istream,
                            File dbFile,
                            boolean validateOnLoad,
                            boolean applyXIncludes,
                            boolean readOnly)
                     throws XTCEDatabaseException
        Constructor for use with an XTCE database file from a stream. Successfully constructing this object means that the XTCE database file was successfully loaded and methods can be called on the contents.
        Parameters:
        istream - InputStream containing the stream to read the data from.
        dbFile - File containing the name and path to the XTCE database file to load and optionally validate.
        validateOnLoad - boolean indicating if the XSD validation should be performed during the loading.
        applyXIncludes - boolean indicating if the XInclude processing for the loaded file should be applied or ignored.
        readOnly - boolean indicating if the document should be opened in a read-only context, which is faster because only the JAXB structure is created, avoiding the need to build the Document Object Model that is needed for round trip processing.
        Throws:
        XTCEDatabaseException - in the event that the file could not be successfully loaded in a valid state. This can be partly bypassed by not enabling the XSD validation, which is not recommended because it may de-stabilize the application using this data file.
      • XTCEDatabase

        public XTCEDatabase​(String topLevelSpaceSystemName)
                     throws XTCEDatabaseException
        Constructor for creating a new XTCE database object based on a top level SpaceSystem element name.
        Parameters:
        topLevelSpaceSystemName - String containing the name of the top level SpaceSystem element to create a new and empty XTCE database.
        Throws:
        XTCEDatabaseException - in the event that the name being used cannot be a name for the top level SpaceSystem element. Examine the exception message for more details on the cause.
    • Method Detail

      • getMetrics

        public XTCESpaceSystemMetrics getMetrics()
        Retrieve the metrics for the XTCE document represented by this object. The metrics returned are inclusive and recursive to the top level Space System in the XTCE data model. Metrics for a singular Space System element can be obtained using the getMetrics() method on the XTCESpaceSystem class.
        Returns:
        XTCESpaceSystemMetrics object containing a variety of counts.
      • save

        public void save​(File dbFile)
                  throws XTCEDatabaseException
        Function to save the currently loaded database file.
        Parameters:
        dbFile - File object containing the file and path for which to save the file containing the XTCE document.
        Throws:
        XTCEDatabaseException - thrown in the event that the file cannot be saved. The caller should inspect the message inside the exception for more specific details on the cause of this error.
      • getSpaceSystem

        public XTCESpaceSystem getSpaceSystem​(String fullPath)
        Retrieve an arbitrary SpaceSystem wrapped element from the document.
        Parameters:
        fullPath - String containing the full path to the XTCE SpaceSystem element using the fully qualified UNIX style path rules of an XTCE reference.
        Returns:
        XTCESpaceSystem object containing the SpaceSystem and also some helper functions. If not found, the return can be null.
      • getRootSpaceSystem

        public XTCESpaceSystem getRootSpaceSystem()
        Retrieve an XTCESpaceSystem object that represents the root SpaceSystem element of this XTCE document.
        Returns:
        XTCESpaceSystem representing the root SpaceSystem, which for any valid document can never be null.
      • getSpaceSystemTree

        public List<XTCESpaceSystem> getSpaceSystemTree()
        Retrieve a list of all the SpaceSystem elements in this XTCE document, wrapped inside XTCESpaceSystem objects.
        Returns:
        List of XTCESpaceSystem objects that are created from the structure of the XTCE document.
      • addSpaceSystem

        public void addSpaceSystem​(String name,
                                   String path)
                            throws XTCEDatabaseException
        Function to add a new Space System element to the XTCE document structure.
        Parameters:
        name - String containing the name of the Space System to add.
        path - String containing the fully qualified XTCE UNIX style path to the new Space System in the hierarchy.
        Throws:
        XTCEDatabaseException - thrown in the event that this add method is called for a root SpaceSystem element or the desired name conflicts with another SpaceSystem element that already exists.
      • deleteSpaceSystem

        public void deleteSpaceSystem​(String ssPath)
                               throws XTCEDatabaseException
        Deletes a SpaceSystem element from the current XTCE document.
        Parameters:
        ssPath - String containing the fully qualified path to the XTCE SpaceSystem element that should be removed from the data model structure.
        Throws:
        XTCEDatabaseException - thrown in the event that this method is called to remove the root SpaceSystem or the SpaceSystem element to be removed cannot be located (as in, it does not exist).
      • getTelemetryParameters

        public List<XTCEParameter> getTelemetryParameters()
        Function to retrieve all of the Telemetry Parameters that are defined in the XTCE document. Similar functions exist on the XTCESpaceSystem objects. This one is intended to return the entire contents of the XTCE database file.
        Returns:
        List of XTCEParameter objects that exist in the entirety of the file. The list can possibly be empty if there are no telemetry parameters, which is likely only to happen on a newly created database file.
      • getTelemetryParameters

        public List<XTCEParameter> getTelemetryParameters​(String nameGlob)
        Function to retrieve all of the Telemetry Parameters that are defined in the XTCE document that match a glob style name pattern. Since the parameter name in XTCE is unique by Space System, it is possible for this method to return multiple results even for a name that is exact. TODO: This function can be optimized for searches that do not include glob matching. Not sure if this is needed though.
        Parameters:
        nameGlob - String containing a precise name or a glob of potential names.
        Returns:
        List of XTCEParameter objects found, which can be empty.
      • getTelemetryParameters

        public List<XTCEParameter> getTelemetryParameters​(String aliasGlob,
                                                          String aliasNameSpace)
        Function to retrieve all of the Telemetry Parameters that are defined in the XTCE document that match a glob style alias pattern in a specified namespace.
        Parameters:
        aliasGlob - String containing a precise alias or a glob of potential alias strings.
        aliasNameSpace - String containing the namespace of the alias in the XTCE data model.
        Returns:
        List of XTCEParameter objects found, which can be empty.
      • getTelecommandParameters

        public List<XTCEParameter> getTelecommandParameters()
        Function to retrieve all of the Telecommand Parameters that are defined in the XTCE document. Similar functions exist on the XTCESpaceSystem objects. This one is intended to return the entire contents of the XTCE database file.
        Returns:
        List of XTCEParameter objects that exist in the entirety of the file. The list can possibly be empty if there are no telecommand parameters, which is likely only to happen on a newly created database file.
      • getTelecommandParameters

        public List<XTCEParameter> getTelecommandParameters​(String nameGlob)
        Function to retrieve all of the Telecommand Parameters that are defined in the XTCE document that match a glob style name pattern. Since the parameter name in XTCE is unique by Space System, it is possible for this method to return multiple results even for a name that is exact. TODO: This function can be optimized for searches that do not include glob matching. Not sure if this is needed though.
        Parameters:
        nameGlob - String containing a precise name or a glob of potential names.
        Returns:
        List of XTCEParameter objects found, which can be empty.
      • getTelecommandParameters

        public List<XTCEParameter> getTelecommandParameters​(String aliasGlob,
                                                            String aliasNameSpace)
        Function to retrieve all of the Telecommand Parameters that are defined in the XTCE document that match a glob style alias pattern in a specified namespace.
        Parameters:
        aliasGlob - String containing a precise alias or a glob of potential alias strings.
        aliasNameSpace - String containing the namespace of the alias in the XTCE data model.
        Returns:
        List of XTCEParameter objects found, which can be empty.
      • getParameters

        public List<XTCEParameter> getParameters()
        Function to retrieve all of the Parameters that are defined in the XTCE document. Similar functions exist on the XTCESpaceSystem objects. This one is intended to return the entire contents of the XTCE database file.
        Returns:
        List of XTCEParameter objects that exist in the entirety of the file. The list can possibly be empty if there are no parameters, which is likely only to happen on a newly created database file.
      • getContainers

        public List<XTCETMContainer> getContainers()
        Function to retrieve all of the Telemetry Containers that are defined in the XTCE document. Similar functions exist on the XTCESpaceSystem objects. This one is intended to return the entire contents of the XTCE database file.
        Returns:
        List of XTCETMContainer objects that exist in the entirety of the file. The list can possibly be empty if there are no containers, which is likely only to happen on a newly created database file.
      • getContainer

        public XTCETMContainer getContainer​(String contFullPath)
                                     throws XTCEDatabaseException
        Retrieve a specific container in the XTCE database by the fully qualified path name to the container, using XTCE document path rules.
        Parameters:
        contFullPath - String containing the fully qualified path to the container desired.
        Returns:
        XTCETMContainer representing the SequenceContainer element in the XTCE data model.
        Throws:
        XTCEDatabaseException - thrown in the event that the container cannot be located using the provided path.
      • getContainers

        public List<XTCETMContainer> getContainers​(String nameGlob)
        Retrieve a List of SequenceContainers that match a user provided string glob, modeled as XTCETMContainer objects.
        Parameters:
        nameGlob - String containing a glob style matching pattern to match against the container names.
        Returns:
        List of XTCETMContainer objects representing the containers that match the provided glob or an empty list if there are no matches.
      • getTelecommands

        public List<XTCETelecommand> getTelecommands()
        Function to retrieve all of the Telecommands that are defined in the XTCE document. Similar functions exist on the XTCESpaceSystem objects. This one is intended to return the entire contents of the XTCE database file.
        Returns:
        List of XTCETelecommand objects that exist in the entirety of the file. The list can possibly be empty if there are no containers, which is likely only to happen on a newly created database file.
      • getTelecommands

        public List<XTCETelecommand> getTelecommands​(String nameGlob)
        Retrieve a List of Telecommands that match a user provided string glob, modeled as XTCETelecommand objects.
        Parameters:
        nameGlob - String containing a glob style matching pattern to match against the telecommand names.
        Returns:
        List of XTCETelecommand objects representing the telecommands that match the provided glob or an empty list if there are no matches.
      • getTelecommand

        public XTCETelecommand getTelecommand​(String contFullPath)
                                       throws XTCEDatabaseException
        Retrieve a specific telecommand in the XTCE database by the fully qualified path name to the telecommand, using XTCE document path rules.
        Parameters:
        contFullPath - String containing the fully qualified path to the telecommand desired.
        Returns:
        XTCETelecommand representing the MetaCommand element in the XTCE data model.
        Throws:
        XTCEDatabaseException - thrown in the event that the telecommand cannot be located using the provided path.
      • getStreams

        public List<XTCETMStream> getStreams()
        Function to retrieve all of the Telemetry Streams that are defined in the XTCE document. Similar functions exist on the XTCESpaceSystem objects. This one is intended to return the entire contents of the XTCE database file.
        Returns:
        List of XTCETMStream objects that exist in the entirety of the file. The list can possibly be empty if there are no containers, which is likely only to happen on a newly created database file.
      • getStream

        public XTCETMStream getStream​(String name)
                               throws XTCEDatabaseException
        Function to retrieve a the Telemetry Streams that is defined in the XTCE document. Similar functions exist on the XTCESpaceSystem objects. This one is intended to search the entire contents of the XTCE database file.
        Parameters:
        name - String containing a specific stream name to locate.
        Returns:
        XTCETMStream object if it exists in the document
        Throws:
        XTCEDatabaseException - in the event that the stream does not exist or does not process correctly. Interrogate the reason in the exception for more information.
      • processContainer

        public XTCEContainerContentModel processContainer​(XTCETMContainer container,
                                                          List<XTCEContainerEntryValue> userValues,
                                                          boolean showAllConditions)
                                                   throws XTCEDatabaseException
        Function to decompose an XTCETMContainer object into a simple array of entries that an application can iterate over without the need to resolve XTCE data model references, included additional containers, base containers, and conditional processing.
        Parameters:
        container - XTCETMContainer object containing the container/packet that the caller wishes to decompose.
        userValues - List of XTCEContainerEntryValue objects that represent desired setpoints for parameters in the container. This permits the caller to decompose a specific packet instance from a container by specifying values for parameters that satisfy include conditions for variable content. Restriction values for Base Container portions are automatically applied and do not need to be supplied by the caller.
        showAllConditions - boolean indicating if the returned content model should provide an array of entry results that include information only rows. These information only rows consist of rows to announce the start of a new Container or a new Aggregate. If false, only those rows will be returned for which a concrete start bit and length exist.
        Returns:
        XTCEContainerContentModel representing this XTCETMContainer.
        Throws:
        XTCEDatabaseException - thrown in the event that it is not possible to decompose the container completely due to bad references in the XTCE document.
      • processContainer

        public XTCEContainerContentModel processContainer​(XTCETMContainer container,
                                                          BitSet binaryData)
                                                   throws XTCEDatabaseException
        Function to decompose an XTCETMContainer object into a simple array of entries that an application can iterate over without the need to resolve XTCE data model references, included additional containers, base containers, and conditional processing.
        Parameters:
        container - XTCETMContainer object containing the container/packet that the caller wishes to decompose.
        binaryData - BitSet containing the container binary encoded data so that the output object contains entries with actual values from a real binary image.
        Returns:
        XTCEContainerContentModel representing this XTCETMContainer.
        Throws:
        XTCEDatabaseException - thrown in the event that it is not possible to decompose the container completely due to bad references in the XTCE document.
      • processContainer

        public XTCEContainerContentModel processContainer​(XTCETMContainer container,
                                                          byte[] bytes)
                                                   throws XTCEDatabaseException
        Function to decompose an XTCETMContainer object into a simple array of entries that an application can iterate over without the need to resolve XTCE data model references, included additional containers, base containers, and conditional processing. This function is intended to accept the byte array that is read from a ByteArrayOutputStream.toByteArray() that is easily obtained when reading a binary file using a Java FileInputStream.
        Parameters:
        container - XTCETMContainer object containing the container/packet that the caller wishes to decompose.
        bytes - byte[] containing the container binary encoded data so that the output object contains entries with actual values from a real binary image.
        Returns:
        XTCEContainerContentModel representing this XTCETMContainer.
        Throws:
        XTCEDatabaseException - thrown in the event that it is not possible to decompose the container completely due to bad references in the XTCE document.
      • processContainer

        public XTCEContainerContentModel processContainer​(XTCETMContainer container,
                                                          InputStream stream)
                                                   throws XTCEDatabaseException
        Function to decompose an XTCETMContainer object into a simple array of entries that an application can iterate over without the need to resolve XTCE data model references, included additional containers, base containers, and conditional processing. This function is intended to accept a Java InputStream containing the bytes to use for the binary portion of the container.
        Parameters:
        container - XTCETMContainer object containing the container/packet that the caller wishes to decompose.
        stream - InputStream containing the container binary encoded data so that the output object contains entries with actual values from a real binary image.
        Returns:
        XTCEContainerContentModel representing this XTCETMContainer.
        Throws:
        XTCEDatabaseException - thrown in the event that it is not possible to decompose the container completely due to bad references in the XTCE document, or if the stream throws an IOException.
      • processTelecommand

        public XTCETelecommandContentModel processTelecommand​(XTCETelecommand tcObject,
                                                              List<XTCEContainerEntryValue> userValues,
                                                              boolean showAllConditions)
                                                       throws XTCEDatabaseException
        Function to decompose an XTCETelecommand object into a simple array of entries that an application can iterate over without the need to resolve XTCE data model references, included additional containers, base containers, and conditional processing.
        Parameters:
        tcObject - XTCETelecommand object containing the telecommand that the caller wishes to decompose.
        userValues - List of XTCEContainerEntryValue objects that represent desired setpoints for arguments and/or parameters in the telecommand container. This permits the caller to decompose a specific telecommand instance from a more general telecommand by specifying values for parameters that satisfy include conditions for variable content. Restriction values for Base MetaComamand portions are automatically applied and do not need to be supplied by the caller.
        showAllConditions - boolean indicating if the returned content model should provide an array of entry results that include information only rows. These information only rows consist of rows to announce the start of a new Container or a new Aggregate. If false, only those rows will be returned for which a concrete start bit and length exist.
        Returns:
        XTCEContainerContentModel representing this XTCETelecommand.
        Throws:
        XTCEDatabaseException - thrown in the event that it is not possible to decompose the container completely due to bad references in the XTCE document.
      • processTelecommand

        public XTCETelecommandContentModel processTelecommand​(XTCETelecommand telecommand,
                                                              BitSet binaryData)
                                                       throws XTCEDatabaseException
        Function to decompose an XTCETelecommand object into a simple array of entries that an application can iterate over without the need to resolve XTCE data model references, included additional containers, base containers, and conditional processing.
        Parameters:
        telecommand - XTCETelecommand object containing the telecommand that the caller wishes to decompose.
        binaryData - BitSet containing the telecommand binary encoded data so that the output object contains entries with actual values from a real binary image.
        Returns:
        XTCETelecommandContentModel representing this XTCETelecommand.
        Throws:
        XTCEDatabaseException - thrown in the event that it is not possible to decompose the telecommand completely due to bad references in the XTCE document.
      • processTelecommand

        public XTCETelecommandContentModel processTelecommand​(XTCETelecommand telecommand,
                                                              byte[] bytes)
                                                       throws XTCEDatabaseException
        Function to decompose an XTCETelecommand object into a simple array of entries that an application can iterate over without the need to resolve XTCE data model references, included additional containers, base containers, and conditional processing. This function is intended to accept the byte array that is read from a ByteArrayOutputStream.toByteArray() that is easily obtained when reading a binary file using a Java FileInputStream.
        Parameters:
        telecommand - XTCETelecommand object containing the telecommand that the caller wishes to decompose.
        bytes - byte[] containing the container binary encoded data so that the output object contains entries with actual values from a real binary image.
        Returns:
        XTCETelecommandContentModel representing this XTCETelecommand.
        Throws:
        XTCEDatabaseException - thrown in the event that it is not possible to decompose the container completely due to bad references in the XTCE document.
      • processTelecommand

        public XTCETelecommandContentModel processTelecommand​(XTCETelecommand telecommand,
                                                              InputStream stream)
                                                       throws XTCEDatabaseException
        Function to decompose an XTCETelecommand object into a simple array of entries that an application can iterate over without the need to resolve XTCE data model references, included additional containers, base containers, and conditional processing. This function is intended to accept a Java InputStream containing the bytes to use for the binary portion of the container.
        Parameters:
        telecommand - XTCETelecommand object containing the telecommand that the caller wishes to decompose.
        stream - InputStream containing the container binary encoded data so that the output object contains entries with actual values from a real binary image.
        Returns:
        XTCETelecommandContentModel representing this XTCETelecommand.
        Throws:
        XTCEDatabaseException - thrown in the event that it is not possible to decompose the container completely due to bad references in the XTCE document, or if the stream throws an IOException.
      • findContainers

        public List<XTCETMContainer> findContainers​(XTCEParameter parameter)
        Retrieve the containers in the XTCE document that directly reference an entry in their manifest that includes the provided Parameter.
        Parameters:
        parameter - XTCEParameter object to find in the containers defined in this XTCE database document.
        Returns:
        List of XTCETMContainer objects found, or an empty list if the no container references the parameter.
      • getParameterTypeReference

        public NameDescriptionType getParameterTypeReference​(String typePath)
        Retrieve the type reference from the JAXB generated objects for a particular TM Parameter fully qualified type object path in the XTCE data model.
        Parameters:
        typePath - String containing the UNIX style fully qualified path to the TM Parameter type object.
        Returns:
        NameDescriptionType base class for the type object found, or a null object reference in the event that it is not found.
      • getArgumentTypeReference

        public NameDescriptionType getArgumentTypeReference​(String typePath)
        Retrieve the type reference from the JAXB generated objects for a particular TC Argument fully qualified type object path in the XTCE data model.
        Parameters:
        typePath - String containing the UNIX style fully qualified path to the TC Argument type object.
        Returns:
        NameDescriptionType base class for the type object found, or a null object reference in the event that it is not found.