public abstract class XTCEDatabaseParser extends Object
| Constructor and Description |
|---|
XTCEDatabaseParser() |
| Modifier and Type | Method and Description |
|---|---|
NodeList |
evaluateXPathQuery(String query)
Evaluate an arbitrary XPath Query Expression and return a generic
NodeList object back or an exception with an error message.
|
boolean |
getChanged()
Retrieve the changed flag indicating if some part of the XTCE document
has changed since it has last been saved.
|
Document |
getDocument()
Method to return the document object from the Document Object Model
(DOM) of this XTCE document.
|
Element |
getDocumentElement()
Method to return the root document element from the Document Object
Model (DOM) of this XTCE document.
|
List<String> |
getDocumentWarnings()
Retrieve the list of warnings and errors that were collected during
parsing of the XTCE document by the SAX parser.
|
long |
getErrorCount()
Retrieve the count of error messages from the parsing.
|
File |
getFilename()
Retrieve the current filename, in fully qualified path form, for the
XTCE database file that is loaded.
|
String |
getNamespaceFromDocument()
Retrieve the XTCE namespace that is applicable to the document that is
loaded.
|
String |
getSchemaFromDocument()
Retrieve the XTCE schema document that is applicable for this loaded
file.
|
boolean |
isReadOnly()
Retrieve the read only flag that was provided when the XTCE document
was loaded and parsed.
|
protected org.omg.space.xtce.SpaceSystemType |
loadDatabase(File dbFile,
boolean validateOnLoad,
boolean applyXIncludes,
boolean readOnly)
Protected method to read/parse an XTCE XML document and populate the
internal data members for this object.
|
protected org.omg.space.xtce.SpaceSystemType |
loadDatabase(InputStream dbStream,
String path,
boolean validateOnLoad,
boolean applyXIncludes,
boolean readOnly)
Protected method to read/parse an XTCE XML document and populate the
internal data members for this object.
|
protected org.omg.space.xtce.SpaceSystemType |
loadDatabase(URL dbLocation,
boolean validateOnLoad,
boolean applyXIncludes,
boolean readOnly)
Protected method to read/parse an XTCE XML document and populate the
internal data members for this object.
|
protected org.omg.space.xtce.SpaceSystemType |
newDatabase(String spaceSystemName)
Method to create a new XTCE Document in memory, which is always created
in an editable state instead of read-only.
|
void |
normalizeDocument()
Method to normalize the whitespace in the XML Document Object Model to
make saved documents look clean.
|
protected boolean |
removeDefaultAttribute(Element element,
String name,
String value)
Remove an attribute node from an element in the Document Object Model
when the attribute contains the default value.
|
protected void |
renameElement(Element element,
String newName)
Rename an Element node in the Document Object Model assuming that it is
the XTCE namespace but consider that the XTCE URI might be the default
namespace, in which case there is no prefix, or it could have the
xtce: prefix.
|
protected void |
saveDatabase(File dbFile)
Method to write the current XTCE Document in memory to a File object.
|
void |
setChanged(boolean changedFlag)
Set the change flag to indicate whether or not this XTCE document has
been changed since the last time it was saved.
|
protected void |
setFilename(File dbFile)
Protected method to set a new filename when the database is saved.
|
protected void |
updateHistorySet(List<String> messages)
Update the History elements in the XTCE document before saving, only if
the document uses the Header element.
|
static List<String> |
validateDocument(File dbFile,
boolean applyXIncludes)
Method to perform XML Schema Description (XSD) verification on an
arbitrary XTCE document.
|
public final File getFilename()
protected final void setFilename(File dbFile)
dbFile - File object containing the file that was saved.public final boolean getChanged()
public final void setChanged(boolean changedFlag)
changedFlag - boolean to use to set the changed flag.public final String getSchemaFromDocument()
public final String getNamespaceFromDocument()
public final List<String> getDocumentWarnings()
public final long getErrorCount()
public final boolean isReadOnly()
public static List<String> validateDocument(File dbFile, boolean applyXIncludes)
dbFile - File object containing the fully qualified filesystem path
to the XTCE document to be verified.applyXIncludes - boolean indicating if the XInclude processing for
the loaded file should be applied or ignored.protected org.omg.space.xtce.SpaceSystemType newDatabase(String spaceSystemName) throws XTCEDatabaseException
spaceSystemName - Name attribute of the root SpaceSystem element
to begin the document.XTCEDatabaseException - in the event that the DocumentBuilder
cannot make a new document or JAXB cannot bind to the new document from
the DOM. This is unlikely.protected org.omg.space.xtce.SpaceSystemType loadDatabase(File dbFile, boolean validateOnLoad, boolean applyXIncludes, boolean readOnly) throws XTCEDatabaseException
dbFile - File object containing the XTCE XML document to load.validateOnLoad - boolean to indicate if the XML document should be
validated through the XML Schema Description (XSD) document that is
configured for the XTCEDatabase object. In the future this will be more
flexible.applyXIncludes - boolean indicating if the XInclude processing for
the loaded file should be applied or ignored.readOnly - boolean indicating if the Document Object Model should
be constructed. This is needed for round trip editing, but it is slower
than just the pure JAXB implementation.XTCEDatabaseException - thrown in the event that the document
cannot be read or is not sufficiently valid to complete construction of
the internal data model.protected org.omg.space.xtce.SpaceSystemType loadDatabase(URL dbLocation, boolean validateOnLoad, boolean applyXIncludes, boolean readOnly) throws XTCEDatabaseException
dbLocation - URL containing a location to load the document from.validateOnLoad - boolean to indicate if the XML document should be
validated through the XML Schema Description (XSD) document that is
configured for the XTCEDatabase object. In the future this will be more
flexible.applyXIncludes - boolean indicating if the XInclude processing for
the loaded file should be applied or ignored.readOnly - boolean indicating if the Document Object Model should
be constructed. This is needed for round trip editing, but it is slower
than just the pure JAXB implementation.XTCEDatabaseException - thrown in the event that the document
cannot be read or is not sufficiently valid to complete construction of
the internal data model.protected org.omg.space.xtce.SpaceSystemType loadDatabase(InputStream dbStream, String path, boolean validateOnLoad, boolean applyXIncludes, boolean readOnly) throws XTCEDatabaseException
dbStream - InputStream object containing the XTCE XML document to
load.path - String containing the current working directory for the
stream, which is needed for XInclude, or null if not possible to get.validateOnLoad - boolean to indicate if the XML document should be
validated through the XML Schema Description (XSD) document that is
configured for the XTCEDatabase object. In the future this will be more
flexible.applyXIncludes - boolean indicating if the XInclude processing for
the loaded file should be applied or ignored.readOnly - boolean indicating if the Document Object Model should
be constructed. This is needed for round trip editing, but it is slower
than just the pure JAXB implementation.XTCEDatabaseException - thrown in the event that the document
cannot be read or is not sufficiently valid to complete construction of
the internal data model.protected void saveDatabase(File dbFile) throws XTCEDatabaseException
dbFile - File containing the location to write the database XML.XTCEDatabaseException - in the event that the document is opened
read-only, in which case the DOM is not loaded or initialized.public void normalizeDocument()
throws XTCEDatabaseException
XTCEDatabaseException - in the event that the document is not well
formed or it is loaded read-only, in which case the Document Object
Model is not in use.public final Element getDocumentElement() throws XTCEDatabaseException
XTCEDatabaseException - in the event that the document is opened
read-only, in which case the DOM is not loaded or initialized.public final Document getDocument() throws XTCEDatabaseException
XTCEDatabaseException - in the event that the document is opened
read-only, in which case the DOM is not loaded or initialized.public NodeList evaluateXPathQuery(String query) throws XTCEDatabaseException
query - String containing the XPath expression.XTCEDatabaseException - in the event that the query contains an
error or cannot otherwise be evaluated against the DOM tree.protected void renameElement(Element element, String newName) throws XTCEDatabaseException
element - Element to renamenewName - String containing the new element nameXTCEDatabaseException - in the event that the document object
does not exist because the document is in read-only mode.protected boolean removeDefaultAttribute(Element element, String name, String value)
element - Element object from the DOM to search for the attribute.name - String containing the name of the attribute to check.value - String containing the default value of the attribute.protected void updateHistorySet(List<String> messages) throws XTCEDatabaseException
messages - List of strings to add to the HistorySet element with
each message being 1 new History element.XTCEDatabaseException - Unlikely to be thrown, but can occur if
the document is malformed according to the schema.Copyright © 2015–2019. All rights reserved.