if (property.contains(":") && !this.namespaceTagHints.isEmpty()) { final int i = property.indexOf(":"); return new Attributes(this, "@" + property.substring(i + 1), property.substring(1, i), this.namespaceTagHints); } else { return new Attributes(this, property, this.namespaceTagHints);
public List list() { final Iterator iter = iterator(); final List result = new ArrayList(); while (iter.hasNext()) { result.add(iter.next()); } return result; }
/** * Throws a <code>GroovyRuntimeException</code>, because attributes can have no children. */ public Iterator childNodes() { throw new GroovyRuntimeException("Can't get the child nodes on a GPath expression selecting attributes: ...." + this.parent.name() + "." + name() + ".childNodes()"); }
public Writer writeTo(final Writer out) throws IOException { out.write(text()); return out; }
public Iterator iterator() { return new NodeIterator(nodeIterator()) { 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; } }; }
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; } };
public void build(final GroovyObject builder) { builder.getProperty("mkp"); builder.invokeMethod("yield", new Object[]{text()}); } }
public Iterator iterator() { return new NodeIterator(nodeIterator()) { protected Object getNextNode(final Iterator iter) { while (iter.hasNext()) { final Object next = iter.next(); if (next instanceof Attribute) { return next; } else { final String value = (String) ((Node) next).attributes().get(Attributes.this.attributeName); if (value != null) { return new Attribute(Attributes.this.attributeName, value, new NodeChild((Node) next, Attributes.this.parent.parent, "", Attributes.this.namespaceTagHints), "", Attributes.this.namespaceTagHints); } } } return null; } }; }
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; } };
public Writer writeTo(final Writer out) throws IOException { out.write(text()); return out; }
public String text() { final StringBuilder sb = new StringBuilder(); final Iterator iter = iterator(); while (iter.hasNext()) { sb.append(iter.next()); } return sb.toString(); }
/** * Throws a <code>GroovyRuntimeException</code>, because attributes can have no children. */ public Iterator childNodes() { throw new GroovyRuntimeException("Can't get the child nodes on a GPath expression selecting attributes: ...." + this.parent.name() + "." + name() + ".childNodes()"); }
public Iterator iterator() { return new NodeIterator(nodeIterator()) { protected Object getNextNode(final Iterator iter) { while (iter.hasNext()) { final Object next = iter.next(); if (next instanceof Attribute) { return next; } else { final String value = (String) ((Node) next).attributes().get(Attributes.this.attributeName); if (value != null) { return new Attribute(Attributes.this.attributeName, value, new NodeChild((Node) next, Attributes.this.parent.parent, "", Attributes.this.namespaceTagHints), "", Attributes.this.namespaceTagHints); } } } return null; } }; }
public Object getProperty(final String property) { if ("..".equals(property)) { return parent(); } else if ("*".equals(property)) { return children(); } else if ("**".equals(property)) { return depthFirst(); } else if (property.startsWith("@")) { if (property.indexOf(":") != -1) { final int i = property.indexOf(":"); return new Attributes(this, "@" + property.substring(i + 1), property.substring(1, i), this.namespaceTagHints); } else { return new Attributes(this, property, this.namespaceTagHints); } } else { if (property.indexOf(":") != -1) { final int i = property.indexOf(":"); return new NodeChildren(this, property.substring(i + 1), property.substring(0, i), this.namespaceTagHints); } else { return new NodeChildren(this, property, this.namespaceTagHints); } } }
public Writer writeTo(final Writer out) throws IOException { out.write(text()); return out; }
public String text() { final StringBuilder sb = new StringBuilder(); final Iterator iter = iterator(); while (iter.hasNext()) { sb.append(iter.next()); } return sb.toString(); }
public Iterator childNodes() { throw new GroovyRuntimeException("Can't get the child nodes on a GPath expression selecting attributes: ...." + this.parent.name() + "." + name() + ".childNodes()"); }
public Iterator iterator() { return new NodeIterator(nodeIterator()) { protected Object getNextNode(final Iterator iter) { while (iter.hasNext()) { final Object next = iter.next(); if (next instanceof Attribute) { return next; } else { final String value = (String) ((Node) next).attributes().get(Attributes.this.attributeName); if (value != null) { return new Attribute(Attributes.this.name, value, new NodeChild((Node) next, Attributes.this.parent.parent, "", Attributes.this.namespaceTagHints), "", Attributes.this.namespaceTagHints); } } } return null; } }; }
public Object getProperty(final String property) { if ("..".equals(property)) { return parent(); } else if ("*".equals(property)) { return children(); } else if ("**".equals(property)) { return depthFirst(); } else if (property.startsWith("@")) { if (property.indexOf(":") != -1) { final int i = property.indexOf(":"); return new Attributes(this, "@" + property.substring(i + 1), property.substring(1, i), this.namespaceTagHints); } else { return new Attributes(this, property, this.namespaceTagHints); } } else { if (property.indexOf(":") != -1) { final int i = property.indexOf(":"); return new NodeChildren(this, property.substring(i + 1), property.substring(0, i), this.namespaceTagHints); } else { return new NodeChildren(this, property, this.namespaceTagHints); } } }
public Writer writeTo(final Writer out) throws IOException { out.write(text()); return out; }