org.dom4j.Comment Java Examples

The following examples show how to use org.dom4j.Comment. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ManifestFileUtils.java    From atlas with Apache License 2.0 5 votes vote down vote up
/**
 * Remove comments from XML
 *
 * @param document
 * @throws IOException
 * @throws DocumentException
 */
private static void removeComments(Document document) throws IOException, DocumentException {
    Visitor visitor = new VisitorSupport() {

        @Override
        public void visit(Comment comment) {
            comment.setText(" ");
        }
    };
    document.accept(visitor);
}
 
Example #2
Source File: VersionedXmlDoc.java    From onedev with MIT License 4 votes vote down vote up
public void add(Comment comment) {
	getWrapped().add(comment);
}
 
Example #3
Source File: VersionedXmlDoc.java    From onedev with MIT License 4 votes vote down vote up
public boolean remove(Comment comment) {
	return getWrapped().remove(comment);
}
 
Example #4
Source File: ElementWrapper.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void add(Comment comment) {
	element.add( comment );
}
 
Example #5
Source File: ElementWrapper.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public boolean remove(Comment comment) {
	return element.remove( comment );
}
 
Example #6
Source File: Dom4jProxy.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void add(Comment comment) {
	target().add( comment );
}
 
Example #7
Source File: Dom4jProxy.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public boolean remove(Comment comment) {
	return target().remove( comment );
}
 
Example #8
Source File: LowercaseTableNames.java    From unitime with Apache License 2.0 4 votes vote down vote up
protected void writeElement(Element element) throws IOException {
    int size = element.nodeCount();
    String qualifiedName = element.getQualifiedName();

    writePrintln();
    indent();

    writer.write("<");
    writer.write(qualifiedName);

    boolean textOnly = true;

    for (int i = 0; i < size; i++) {
        Node node = element.node(i);
        if (node instanceof Element) {
            textOnly = false;
        } else if (node instanceof Comment) {
            textOnly = false;
        }
    }

    writeAttributes(element);

    lastOutputNodeType = Node.ELEMENT_NODE;

    if (size <= 0) {
        writeEmptyElementClose(qualifiedName);
    } else {
        writer.write(">");

        if (textOnly) {
            // we have at least one text node so lets assume
            // that its non-empty
            writeElementContent(element);
        } else {
        	if (element.attributeCount() > 3)
        		writePrintln();
            // we know it's not null or empty from above
            ++indentLevel;

            writeElementContent(element);

            --indentLevel;

            writePrintln();
            indent();
        }

        writer.write("</");
        writer.write(qualifiedName);
        writer.write(">");
    }
   	if (element.attributeCount() > 2 && indentLevel > 0)
   		writePrintln();

    lastOutputNodeType = Node.ELEMENT_NODE;
}