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
FieldsModifier and TypeFieldDescriptionprotected final Stringprotected XMLEventprotected final XMLEventReader -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StartElementChecks preconditions before the dedicated code for section reading will runvoidclose()protected booleanhasAttribute(String attName, StartElement element) protected booleanhasAttributes(StartElement element) Examines element for presence of attributesprotected booleanisEndElementWithName(String localName) Test if the xmlEvent is of type END_ELEMENT and has particular local name.protected booleanisStartElementWithName(String localName) Check if xml element is a start element with particular nameprotected StringreadAttribute(String attName, StartElement element, String defaultValue) protected booleanreadBooleanAttribute(String attName, StartElement element, boolean defaultValue) protected doublereadDoubleAttribute(String attName, StartElement element) protected doublereadDoubleAttribute(String attName, StartElement element, double defaultValue) protected intreadIntAttribute(String attName, StartElement element) protected intreadIntAttribute(String attName, StartElement element, int defaultValue) protected longreadLongAttribute(String attName, StartElement element) protected longreadLongAttribute(String attName, StartElement element, long defaultValue) protected StringreadMandatoryAttribute(String attName, StartElement element) Get attribute values as stringprotected StringreadStringBetweenTags(String tagName)
-
Field Details
-
xmlEventReader
-
fileName
-
xmlEvent
-
-
Constructor Details
-
AbstractStaxReader
- Throws:
IOExceptionXMLStreamException
-
-
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:
closein interfaceAutoCloseable- Throws:
XMLStreamExceptionIOException
-