use of org.dom4j.Comment in project atlas by alibaba.
the class ManifestFileUtils method removeComments.
/**
* 移除xml中的注释
*
* @param document
* @throws IOException
* @throws DocumentException
*/
private static void removeComments(Document document) throws IOException, DocumentException {
Visitor visitor = new VisitorSupport() {
public void visit(Comment comment) {
comment.setText(" ");
}
};
document.accept(visitor);
}
use of org.dom4j.Comment in project cpsolver by UniTime.
the class GetInfo method getInfo.
public static void getInfo(File folder, List<Info> infos, String prefix) {
File infoFile = new File(folder, "info.xml");
if (infoFile.exists()) {
System.out.println("Reading " + infoFile + " ...");
try {
Document document = (new SAXReader()).read(infoFile);
HashMap<String, String> info = getInfo(document.getRootElement());
if (info != null && !info.isEmpty()) {
infos.add(new Info(prefix, info));
return;
}
} catch (Exception e) {
System.err.println("Error reading file " + infoFile + ", message: " + e.getMessage());
}
}
File outputFile = new File(folder, "output.csv");
if (outputFile.exists()) {
System.out.println("Reading " + outputFile + " ...");
try {
HashMap<String, String> info = getInfo(outputFile);
if (info != null && !info.isEmpty()) {
infos.add(new Info(prefix, info));
return;
}
} catch (Exception e) {
System.err.println("Error reading file " + infoFile + ", message: " + e.getMessage());
}
}
File solutionFile = new File(folder, "solution.xml");
if (!solutionFile.exists())
return;
try {
System.out.println("Reading " + solutionFile + " ...");
Document document = (new SAXReader()).read(solutionFile);
for (Iterator<?> i = document.nodeIterator(); i.hasNext(); ) {
Node node = (Node) i.next();
if (node instanceof Comment) {
Comment comment = (Comment) node;
if (comment.getText().indexOf("Solution Info:") >= 0) {
HashMap<String, String> info = getInfo(comment.getText());
if (info != null)
infos.add(new Info(prefix, info));
}
}
}
} catch (Exception e) {
System.err.println("Error reading file " + solutionFile + ", message: " + e.getMessage());
}
}