mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GT-3198 - fix FunctionBitPatternExplorerPlugin xml handling - codereview
Tweak output format, catch null value.
This commit is contained in:
parent
2c9b771d13
commit
e5184277ef
3 changed files with 22 additions and 2 deletions
|
@ -166,7 +166,9 @@ public class ContextRegisterInfo {
|
|||
|
||||
Element e = new Element(XML_ELEMENT_NAME);
|
||||
e.setAttribute("contextRegister", contextRegister);
|
||||
if (value != null) {
|
||||
e.setAttribute("value", value);
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
|
|
@ -287,7 +287,7 @@ public class FileBitPatternInfo {
|
|||
Element rootEle = toXml();
|
||||
Document doc = new Document(rootEle);
|
||||
|
||||
XmlUtilities.writeDocToFile(doc, destFile);
|
||||
XmlUtilities.writePrettyDocToFile(doc, destFile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,6 +27,7 @@ import javax.xml.parsers.SAXParserFactory;
|
|||
|
||||
import org.jdom.*;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom.output.Format;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.xml.sax.*;
|
||||
|
||||
|
@ -219,6 +220,23 @@ public class XmlUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a JDOM XML {@link Document} to a {@link File}, with a prettier
|
||||
* format than {@link #writeDocToFile(Document, File)}.
|
||||
* <p>
|
||||
*
|
||||
* @param doc JDOM XML {@link Document} to write.
|
||||
* @param dest {@link File} to write to.
|
||||
* @throws IOException if error when writing file.
|
||||
*/
|
||||
public static void writePrettyDocToFile(Document doc, File dest) throws IOException {
|
||||
XMLOutputter outputter = new XMLOutputter();
|
||||
outputter.setFormat(Format.getPrettyFormat());
|
||||
try (FileWriter fw = new FileWriter(dest)) {
|
||||
outputter.output(doc, fw);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a File and convert to jdom xml doc.
|
||||
* <p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue