/** * Returns <code>true</code> if attribute containing some word. */ public boolean isAttributeContaining(final String name, final String word) { Attribute attr = getAttributeInstance(name); if (attr == null) { return false; } return attr.isContaining(word); }
/** * Returns attribute value. Returns <code>null</code> when * attribute doesn't exist or when attribute exist but doesn't * specify a value. */ public String getAttribute(final String name) { Attribute attribute = getAttributeInstance(name); if (attribute == null) { return null; } return attribute.getValue(); }
@Override public void xml(final CharSequence version, final CharSequence encoding, final CharSequence standalone) { if (!enabled) { return; } XmlDeclaration xmlDeclaration = new XmlDeclaration(rootNode, version, encoding, standalone); parentNode.addChild(xmlDeclaration); }
protected void walk(final Node rootNode, final NodeFilter nodeFilter, final List<Node> result) { int childCount = rootNode.getChildNodesCount(); for (int i = 0; i < childCount; i++) { Node node = rootNode.getChild(i); if (nodeFilter.accept(node)) { result.add(node); } walk(node, nodeFilter, result); } }
@Override public void script(final Tag tag, final CharSequence body) { if (!enabled) { return; } Element node = createElementNode(tag); parentNode.addChild(node); if (body.length() != 0) { Node text = new Text(rootNode, body.toString()); node.addChild(text); } }
@Override public boolean match(final Node node) { return (node.getSiblingElementIndex() == 0) && (node.getParentNode().getChildElementsCount() == 1); } }
@Override protected NodeVisitor createRenderer(Appendable appendable) { LagartoHtmlRendererNodeVisitor renderer = (LagartoHtmlRendererNodeVisitor) super.createRenderer(appendable); renderer.setTagCase(RAW); renderer.setAttributeCase(RAW); return renderer; } }
/** * Fixes foster elements. */ public void fixFosterElements(final Document document) { findFosterNodes(document); fixElements(); fixText(); }
/** * Removes child node. It works only with direct children, i.e. * if provided child node is not a child nothing happens. */ public void removeChild(final Node childNode) { if (childNode.getParentNode() != this) { return; } childNode.detachFromParent(); }
@Override public boolean match(final Node node) { return (node.getSiblingNameIndex() == 0) && (node.getNextSiblingName() == null); } }
@Override public void element(final Element element) { try { _element(element); } catch (IOException ioex) { throw new LagartoDOMException(ioex); } }
@Override protected void elementBody(Element element) throws IOException { boolean hasXML = element.hasAttribute("xml-attrib"); // detects XML content if (hasXML) { configXML(); } super.elementBody(element); if (hasXML) { configHtml(); } }
@Override public void document(Document document) { configHtml(); super.document(document); }
protected void configHtml() { setTagCase(LOWERCASE); setAttributeCase(LOWERCASE); } protected void configXML() {
@Override protected NodeVisitor createRenderer(Appendable appendable) { LagartoHtmlRendererNodeVisitor renderer = (LagartoHtmlRendererNodeVisitor) super.createRenderer(appendable); renderer.setTagCase(DEFAULT); renderer.setAttributeCase(RAW); return renderer; } }
@Override protected NodeVisitor createRenderer(Appendable appendable) { LagartoHtmlRendererNodeVisitor renderer = (LagartoHtmlRendererNodeVisitor) super.createRenderer(appendable); renderer.setTagCase(RAW); renderer.setAttributeCase(DEFAULT); return renderer; } }
@Override protected NodeVisitor createRenderer(Appendable appendable) { LagartoHtmlRendererNodeVisitor renderer = (LagartoHtmlRendererNodeVisitor) super.createRenderer(appendable); renderer.setTagCase(DEFAULT); renderer.setAttributeCase(DEFAULT); return renderer; } }
@Override protected NodeVisitor createRenderer(Appendable appendable) { LagartoHtmlRendererNodeVisitor renderer = (LagartoHtmlRendererNodeVisitor) super.createRenderer(appendable); renderer.setTagCase(LOWERCASE); renderer.setAttributeCase(UPPERCASE); return renderer; } }
@Override protected NodeVisitor createRenderer(Appendable appendable) { LagartoHtmlRendererNodeVisitor renderer = (LagartoHtmlRendererNodeVisitor) super.createRenderer(appendable); renderer.setTagCase(UPPERCASE); renderer.setAttributeCase(LOWERCASE); return renderer; } }