Class AttributeSynchronizer
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- net.ssehub.easy.instantiation.core.model.artifactModel.xml.AttributeSynchronizer
-
- All Implemented Interfaces:
org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler
class AttributeSynchronizer extends org.xml.sax.helpers.DefaultHandlerImplements an XML attribute synchronizer. As DOM parsing does (usually) not preserve attribute sequences, we synchronize XML attributes if needed through an additional SAX parsing run. This is a SAX content handler maintaining an internal iterator. For each matching element, we synchronize the attributes in the respective VIL attribute fragment.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private static intINDEX_NODEprivate XmlNodeiterprivate java.util.Map<XmlNode,java.lang.Integer>positions
-
Constructor Summary
Constructors Constructor Description AttributeSynchronizer(XmlElement root)Creates an attribute synchronizer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private XmlNodeadvanceIter(XmlNode current)Advances the iterator position.private XmlNodecheckPositions(XmlNode node)Checks whether the initial position ofnodeis stored inpositions.private XmlNodeconsumeNonXmlElements(XmlNode node)Consumes all following non-XmlElements.voidstartElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
-
-
-
-
Field Detail
-
INDEX_NODE
private static final int INDEX_NODE
- See Also:
- Constant Field Values
-
iter
private XmlNode iter
-
positions
private java.util.Map<XmlNode,java.lang.Integer> positions
-
-
Constructor Detail
-
AttributeSynchronizer
AttributeSynchronizer(XmlElement root)
Creates an attribute synchronizer.- Parameters:
root- the root node to start from
-
-
Method Detail
-
startElement
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
startElementin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
checkPositions
private XmlNode checkPositions(XmlNode node)
Checks whether the initial position ofnodeis stored inpositions.- Parameters:
node- the node to check (may be null, ignored then)- Returns:
node
-
advanceIter
private XmlNode advanceIter(XmlNode current)
- Parameters:
current- the current node- Returns:
- the next iterator position
-
consumeNonXmlElements
private XmlNode consumeNonXmlElements(XmlNode node)
Consumes all following non-XmlElements.- Parameters:
node- the node to start consuming for (may be null)- Returns:
- the next non-
XmlElement, may benode, may be null - See Also:
advanceIter(XmlNode)
-
-