public boolean hasAttribute(Element e, String attribute) { return e.getAttribute(attribute) != null; }
/** * @since 1.4.5 */ public JDom2Reader(Document document, NameCoder nameCoder) { super(document.getRootElement(), nameCoder); }
/** * @since 1.4.5 */ public JDom2Writer(final Element container, final NameCoder nameCoder) { this(container, new DefaultJDOMFactory(), nameCoder); }
private Document createEmptyCruiseConfigDocument() { Element root = new Element("cruise"); Namespace xsiNamespace = Namespace.getNamespace("xsi", XML_NS); root.addNamespaceDeclaration(xsiNamespace); registry.registerNamespacesInto(root); root.setAttribute("noNamespaceSchemaLocation", "cruise-config.xsd", xsiNamespace); String xsds = registry.xsds(); if (!xsds.isEmpty()) { root.setAttribute("schemaLocation", xsds, xsiNamespace); } root.setAttribute("schemaVersion", Integer.toString(GoConstants.CONFIG_SCHEMA_VERSION)); return new Document(root); }
private void addBreakers(Element element) { Element messages = new Element("messages"); Element message = new Element("message"); String breakerNames = StringUtils.join(breakers, ", "); message.setAttribute("text", breakerNames); message.setAttribute("kind", "Breakers"); messages.addContent(message); element.addContent(messages); }
private void parseDOMTree(Document document) throws UnsupportedEncodingException { Element infoElement = document.getRootElement(); Element entryElement = infoElement.getChild("entry"); String encodedUrl = entryElement.getChildTextTrim("url"); Element repositoryElement = entryElement.getChild("repository"); String root = repositoryElement.getChildTextTrim("root"); String encodedPath = StringUtils.replace(encodedUrl, root, ""); this.path = URLDecoder.decode(encodedPath, ENCODING); this.root = root; this.encodedUrl = encodedUrl; }
private static boolean compareAttributeAwareConfigTag(Element e, AttributeAwareConfigTag attributeAwareConfigTag) { return attributeAwareConfigTag.value().equals(e.getName()) && attributeAwareConfigTag.attributeValue().equals(e.getAttributeValue(attributeAwareConfigTag.attribute())) && e.getNamespace().getURI().equals(attributeAwareConfigTag.namespaceURI()); }
public void populate(Element parent) { if (requireCdata) { parent.addContent(new CDATA(valueString())); } else { parent.setText(valueString()); } }
private Element child(Element e, ConfigTag tag) { return e.getChild(tag.value(), Namespace.getNamespace(tag.namespacePrefix(), tag.namespaceURI())); }
public String getAttribute(Element e, String attribute) { Attribute attr = e.getAttribute(attribute); if(attr == null) { throw bomb("Error finding attribute '" + attribute + "' in config: " + configFile + elementOutput(e)); } return attr.getValue(); }
public void populate(Element parent) { Element child = elementFor(value.getClass(), configCache); parent.addContent(child); write(value, child, configCache, registry); }
protected Object createNode(final String name) { final Element element = documentFactory.element(encodeNode(name)); final Element parent = top(); if (parent != null) { parent.addContent(element); } return element; }
public void registerNamespacesInto(Element element) { for (PluginNamespace namespace : xsdsFor.values()) { element.addNamespaceDeclaration(Namespace.getNamespace(namespace.prefix, namespace.uri)); } }
private static Namespace namespaceFor(ConfigTag annotation) { return Namespace.getNamespace(annotation.namespacePrefix(), annotation.namespaceURI()); }
private CommandSnippetComment getComment(Document document) { for (Object content : document.getContent()) { if (content instanceof Comment) { return new CommandSnippetTextComment(((Comment) content).getText()); } } return new EmptySnippetComment(); }
/** * @since 1.4.5 */ public JDom2Reader(Document document) { super(document.getRootElement()); }
private boolean hasAttribute(String attribute) { return e.getAttribute(attribute) != null; }
/** * @since 1.4.5 */ public JDom2Writer(final Element container) { this(container, new DefaultJDOMFactory()); }
public Document documentFrom(CruiseConfig config) { Document document = createEmptyCruiseConfigDocument(); write(config, document.getRootElement(), configCache, registry); return document; }
/** * @since 1.4.5 */ public JDom2Writer() { this(new DefaultJDOMFactory()); }