Package org.yamcs.xtce.xml
Class AbstractStaxReader
java.lang.Object
org.yamcs.xtce.xml.AbstractStaxReader
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
XtceStaxReader
Abstract class for XML readers
-
Field Summary
Modifier and TypeFieldDescriptionprotected final String
protected XMLEvent
protected final XMLEventReader
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected StartElement
Checks preconditions before the dedicated code for section reading will runvoid
close()
protected boolean
hasAttribute
(String attName, StartElement element) protected boolean
hasAttributes
(StartElement element) Examines element for presence of attributesprotected boolean
isEndElementWithName
(String localName) Test if the xmlEvent is of type END_ELEMENT and has particular local name.protected boolean
isStartElementWithName
(String localName) Check if xml element is a start element with particular nameprotected String
readAttribute
(String attName, StartElement element, String defaultValue) protected boolean
readBooleanAttribute
(String attName, StartElement element, boolean defaultValue) protected double
readDoubleAttribute
(String attName, StartElement element) protected double
readDoubleAttribute
(String attName, StartElement element, double defaultValue) protected int
readIntAttribute
(String attName, StartElement element) protected int
readIntAttribute
(String attName, StartElement element, int defaultValue) protected long
readLongAttribute
(String attName, StartElement element) protected long
readLongAttribute
(String attName, StartElement element, long defaultValue) protected String
readMandatoryAttribute
(String attName, StartElement element) Get attribute values as stringprotected String
readStringBetweenTags
(String tagName)
-
Field Details
-
xmlEventReader
-
fileName
-
xmlEvent
-
-
Constructor Details
-
AbstractStaxReader
- Throws:
IOException
XMLStreamException
-
-
Method Details
-
hasAttributes
Examines element for presence of attributes- Parameters:
element
- Element to be examined, should not be null- Returns:
- True, if the element contains attributes, otherwise false
-
isStartElementWithName
Check if xml element is a start element with particular name- Parameters:
localName
- Name of the element- Returns:
- True if element is start element with the given name, otherwise false
-
readStringBetweenTags
- Throws:
XMLStreamException
-
checkStartElementPreconditions
Checks preconditions before the dedicated code for section reading will run- Returns:
- Throws:
IllegalStateException
- If the conditions are not met
-
hasAttribute
- Throws:
XMLStreamException
-
readMandatoryAttribute
protected String readMandatoryAttribute(String attName, StartElement element) throws XMLStreamException Get attribute values as string- Parameters:
attName
- Name of the attributeelement
- Start element which the attribute is read from- Returns:
- Attribute's value as string
- Throws:
XMLStreamException
- - if the attribute does not exist
-
readAttribute
-
readIntAttribute
protected int readIntAttribute(String attName, StartElement element, int defaultValue) throws XMLStreamException - Throws:
XMLStreamException
-
readIntAttribute
- Throws:
XMLStreamException
-
readLongAttribute
- Throws:
XMLStreamException
-
readLongAttribute
protected long readLongAttribute(String attName, StartElement element, long defaultValue) throws XMLStreamException - Throws:
XMLStreamException
-
readDoubleAttribute
protected double readDoubleAttribute(String attName, StartElement element) throws XMLStreamException - Throws:
XMLStreamException
-
readDoubleAttribute
protected double readDoubleAttribute(String attName, StartElement element, double defaultValue) throws XMLStreamException - Throws:
XMLStreamException
-
readBooleanAttribute
protected boolean readBooleanAttribute(String attName, StartElement element, boolean defaultValue) throws XMLStreamException - Throws:
XMLStreamException
-
isEndElementWithName
Test if the xmlEvent is of type END_ELEMENT and has particular local name. This test is used to identify the end of section.- Parameters:
localName
- Local name of the element (we neglect namespace for now)- Returns:
- True if current xmlEvent is of type END_ELEMENT and has particular local name, otherwise false
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
XMLStreamException
IOException
-