Java Utililty Methods XML QName

List of utility methods to do XML QName

Description

The list of methods to do XML QName are organized into topic(s).

Method

booleanmatch(XMLStreamReader reader, QName name)
match
return reader.getName().equals(name);
booleanmatches(Node node, String requiredLocalName, QName requiredNamespace)
matches
if (node == null) {
    return false;
boolean matchingNamespace = matchingNamespace(node, requiredNamespace);
return matchingNamespace && matchingLocalName(node, requiredLocalName);
booleanmatches(QName qname, Node node)
matches
return (node != null && qname.equals(newQName(node)));
booleanmatchingNamespace(Node node, QName requiredNamespace)
matching Namespace
if (requiredNamespace == null) {
    return true;
} else {
    return requiredNamespace.getNamespaceURI().equals(node.getNamespaceURI());
booleanmatchNode(Node node, QName name)
match Node
return matchNode(node, name, false);
booleanmoveReaderToTag(XMLStreamReader reader, QName... tags)
Moves reader to first occurrence of the structure equivalent of Xpath tags[0]/tags[1]../tags[n].
QName stopTag = reader.getName();
int currentLevel = 0;
QName searchTag = tags[currentLevel];
QName parentTag = null;
QName skipTag = null;
for (int event = 0; 
        reader.hasNext() && !(event == XMLStreamReader.END_ELEMENT
                && stopTag.equals(reader.getName())); event = reader.next()) {
...
PredicatenamedNode(QName qname)
named Node
return namedNode(qname.getNamespaceURI(), qname.getLocalPart());
QNamenodeToQName(Node node)
node To Q Name
return new QName(node.getNamespaceURI(), node.getLocalName());
MapparseXml(final Node node, final Map properties)
parse Xml
for (int i = 0; i < node.getAttributes().getLength(); i++) {
    final Node item = node.getAttributes().item(i);
    final QName itemType = (item.getNamespaceURI() == null) ? new QName(item.getNodeName())
            : new QName(item.getNamespaceURI(), item.getLocalName());
    properties.put(itemType, item.getNodeValue());
for (int i = 0; i < node.getChildNodes().getLength(); i++) {
    final Node item = node.getChildNodes().item(i);
...
voidprintPath(List path)
For debugging purposes only.
StringBuffer buffer = new StringBuffer();
for (QName item : path) {
    if (buffer.toString().equals(""))
        buffer.append(item);
    else
        buffer.append("/" + item);