本文整理了Java中org.jboss.shrinkwrap.descriptor.spi.node.Node.setComment()
方法的一些代码示例,展示了Node.setComment()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.setComment()
方法的具体详情如下:
包路径:org.jboss.shrinkwrap.descriptor.spi.node.Node
类名称:Node
方法名:setComment
[英]Marks this Node as a comment
[中]将此节点标记为注释
代码示例来源:origin: org.projectodd.shrinkwrap.descriptors/shrinkwrap-descriptors-spi
private void readRecursive(final Node target, final org.w3c.dom.Node source) {
readAttributes(target, source);
final NodeList sourceChildren = source.getChildNodes();
if (sourceChildren != null) {
for (int i = 0; i < sourceChildren.getLength(); i++) {
final org.w3c.dom.Node child = sourceChildren.item(i);
if (child.getNodeType() != org.w3c.dom.Node.TEXT_NODE) {
// Create our representation of the Node
final Node newTarget = target.createChild(child.getNodeName());
if (onlyTextChildren(child)) {
// See if we're dealing with a comment and mark specifically
if (child.getNodeType() == org.w3c.dom.Node.COMMENT_NODE) {
newTarget.setComment(true);
}
// Set text
newTarget.text(child.getTextContent());
readAttributes(newTarget, child);
} else {
readRecursive(newTarget, child);
}
} else {
target.text(child.getTextContent());
}
}
}
}
代码示例来源:origin: org.jboss.shrinkwrap.descriptors/shrinkwrap-descriptors-spi
private void readRecursive(final Node target, final org.w3c.dom.Node source) {
readAttributes(target, source);
final NodeList sourceChildren = source.getChildNodes();
if (sourceChildren != null) {
for (int i = 0; i < sourceChildren.getLength(); i++) {
final org.w3c.dom.Node child = sourceChildren.item(i);
if (child.getNodeType() != org.w3c.dom.Node.TEXT_NODE) {
// Create our representation of the Node
final Node newTarget = target.createChild(child.getNodeName());
if (onlyTextChildren(child)) {
// See if we're dealing with a comment and mark specifically
if (child.getNodeType() == org.w3c.dom.Node.COMMENT_NODE) {
newTarget.setComment(true);
}
// Set text
newTarget.text(child.getTextContent());
readAttributes(newTarget, child);
} else {
readRecursive(newTarget, child);
}
} else {
target.text(child.getTextContent());
}
}
}
}
代码示例来源:origin: stackoverflow.com
import japa.parser.JavaParser;
import japa.parser.ParseException;
import japa.parser.ast.CompilationUnit;
import japa.parser.ast.Node;
import java.io.File;
import java.io.IOException;
public class RemoveAllComments {
static void removeComments(Node node) {
for (Node child : node.getChildrenNodes()) {
child.setComment(null);
removeComments(child);
}
}
public static void main(String[] args) throws ParseException, IOException {
File sourceFile = new File("Test.java");
CompilationUnit cu = JavaParser.parse(sourceFile);
removeComments(cu);
System.out.println(cu.toString());
}
}
内容来源于网络,如有侵权,请联系作者删除!