public CHILD appendChild(CHILD el, boolean copy) { el = adoptOrImport(getW3CElement().getOwnerDocument(), el, copy); getW3CElement().appendChild(el.getW3CElement()); return el; }
public CHILD createChild(String name) { return createChild(name, null); }
protected ArrayBuilder(DOMElement element) { super(element); }
public void replaceEqualChild(DOMElement source, String identifier) { DOMElement original = findChildWithIdentifier(identifier); DOMElement replacement = source.findChildWithIdentifier(identifier); original.getParent().replaceChild(original, replacement, true); }
public String toSimpleXMLString() { StringBuilder sb = new StringBuilder(); sb.append("<").append(getElementName()); NamedNodeMap map = getW3CElement().getAttributes(); for (int i = 0; i < map.getLength(); i++) { Node attr = map.item(i); sb.append(" ").append(attr.getNodeName()).append("=\"") .append(attr.getTextContent()).append("\""); } if (getContent().length() > 0) { sb.append(">").append(getContent()).append("</").append(getElementName()).append(">"); } else { sb.append("/>"); } return sb.toString(); }
@Override public String toString() { return "(" + getClass().getSimpleName() + ") " + (getW3CElement() == null ? "UNBOUND" : getElementName()); }
public CHILD getRequiredChild(String name) throws ParserException { CHILD[] children = getChildren(name); if (children.length != 1) { throw new ParserException("Required single child element of '" + getElementName() + "' not found: " + name); } return children[0]; }
public abstract class ArrayBuilder<T extends DOMElement> extends Builder<T> { protected ArrayBuilder(DOMElement element) { super(element); } public abstract T[] newChildrenArray(int length); public T[] getChildElements() { return buildArray(element.getChildren()); } public T[] getChildElements(String elementName) { return buildArray(element.getChildren(elementName)); } protected T[] buildArray(DOMElement[] list) { T[] children = newChildrenArray(list.length); for (int i = 0; i < children.length; i++) { children[i] = build(list[i].getW3CElement()); } return children; } }
public XHTMLElement getFirstChild(XHTML.ELEMENT el) { return super.getFirstChild(el.name()); }
public XHTMLElement[] findChildren(XHTML.ELEMENT el) { return super.findChildren(el.name()); }
public XHTMLElement[] getChildren(XHTML.ELEMENT el) { return super.getChildren(el.name()); }
public CHILD replaceChild(CHILD original, CHILD replacement, boolean copy) { replacement = adoptOrImport(getW3CElement().getOwnerDocument(), replacement, copy); getW3CElement().replaceChild(replacement.getW3CElement(), original.getW3CElement()); return replacement; }
public XHTMLElement createChild(XHTML.ELEMENT el) { return super.createChild(el.name(), XHTML.NAMESPACE_URI); }