formats.addAll(stringFormats);
return formats;
}
private void saveFormats(final List<PatternFormat> formats) throws IOException {
final XMLElement saver = new XMLElement();
saver.setName(ROOT_ELEMENT);
final String sep = System.getProperty("line.separator");
final String header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ sep //
+ "<!-- 'type' selects the kind of data the formatter is intended to format. -->"
+ sep //
+ "<!-- 'style' selects the formatter implementation: -->"
+ sep //
+ "<!-- - 'date': http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html -->"
+ sep //
+ "<!-- - 'decimal': http://download.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html -->"
+ sep //
+ "<!-- - 'formatter': http://download.oracle.com/javase/6/docs/api/java/util/Formatter.html -->"
+ sep //
+ "<!-- - 'name': a informal name, a comment that's not visible in the app -->" + sep //
+ "<!-- - 'locale': the name of the locale, only set for locale dependent format codes -->" + sep;
for (PatternFormat patternFormat : formats) {
if (!patternFormat.getType().equals(PatternFormat.TYPE_IDENTITY)
&& !patternFormat.getType().equals(PatternFormat.TYPE_STANDARD)) {
saver.addChild(patternFormat.toXml());
}
}
final Writer writer = new FileWriter(pathToFile);
final XMLWriter xmlWriter = new XMLWriter(writer);
xmlWriter.addRawContent(header);