use of groovy.namespace.QName in project groovy by apache.
the class Attributes method iterator.
@Override
public Iterator iterator() {
return new NodeIterator(nodeIterator()) {
@Override
protected Object getNextNode(final Iterator iter) {
while (iter.hasNext()) {
final Object next = iter.next();
if (next instanceof Attribute) {
return next;
} else {
String attributeKey = Attributes.this.attributeName;
if (Attributes.this.namespacePrefix != null && !"*".equals(Attributes.this.namespacePrefix) && Attributes.this.namespacePrefix.length() > 0) {
attributeKey = new QName(Attributes.this.lookupNamespace(Attributes.this.namespacePrefix), Attributes.this.attributeName).toString();
}
final String value = (String) ((Node) next).attributes().get(attributeKey);
if (value != null) {
return new Attribute(Attributes.this.name, value, new NodeChild((Node) next, Attributes.this.parent.parent, "", Attributes.this.namespaceTagHints), (Attributes.this.namespacePrefix == null || "*".equals(Attributes.this.namespacePrefix)) ? "" : Attributes.this.namespacePrefix, Attributes.this.namespaceTagHints);
}
}
}
return null;
}
};
}
use of groovy.namespace.QName in project groovy by apache.
the class NamespaceAwareHashMap method adjustForNamespaceIfNeeded.
private Object adjustForNamespaceIfNeeded(Object key) {
String keyString = key.toString();
if (keyString.contains("{") || namespaceTagHints == null || namespaceTagHints.isEmpty() || !keyString.contains(":")) {
return key;
}
final int i = keyString.indexOf(':');
return new QName(namespaceTagHints.get(keyString.substring(0, i)).toString(), keyString.substring(i + 1)).toString();
}
Aggregations