Java 类org.dom4j.VisitorSupport 实例源码

项目:sagetv-phoenix-core    文件:VFSOrganizer.java   
private void organizeNode(Document doc, final String parentName, final String childElName, final String idAttr,
                          final Map<String, Element> addTo) {
    Element e = doc.getRootElement().element(parentName);
    if (e != null) {
        e.accept(new VisitorSupport() {
            @Override
            public void visit(Element node) {
                if (childElName.equals(node.getName())) {
                    String id = node.attributeValue(idAttr);
                    if (id == null) {
                        log.warn("No " + idAttr + " attribute for Node " + node + " in " + name);
                        return;
                    }

                    if (addTo.put(id, node) != null) {
                        log.info("Replaced VFS Entry: " + childElName + "[" + id + "] from " + name);
                    }
                }
            }
        });
    }
}
项目:atlas    文件:ManifestFileUtils.java   
/**
 * 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);
}