Search in sources :

Example 1 with XMLWriter

use of org.freeplane.n3.nanoxml.XMLWriter in project freeplane by freeplane.

the class WindowConfigurationStorage method marshall.

private String marshall() {
    final XMLElement xml = new XMLElement();
    xml.setAttribute("x", Integer.toString(x));
    xml.setAttribute("y", Integer.toString(y));
    xml.setAttribute("width", Integer.toString(width));
    xml.setAttribute("height", Integer.toString(height));
    xml.setName(name);
    marshallSpecificElements(xml);
    final StringWriter string = new StringWriter();
    final XMLWriter writer = new XMLWriter(string);
    try {
        writer.write(xml);
        return string.toString();
    } catch (final IOException e) {
        LogUtils.severe(e);
        return null;
    }
}
Also used : StringWriter(java.io.StringWriter) IOException(java.io.IOException) XMLElement(org.freeplane.n3.nanoxml.XMLElement) XMLWriter(org.freeplane.n3.nanoxml.XMLWriter)

Example 2 with XMLWriter

use of org.freeplane.n3.nanoxml.XMLWriter in project freeplane by freeplane.

the class FormatController method saveFormats.

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);
    xmlWriter.write(saver, true);
    writer.close();
}
Also used : FileWriter(java.io.FileWriter) XMLElement(org.freeplane.n3.nanoxml.XMLElement) XMLWriter(org.freeplane.n3.nanoxml.XMLWriter) FileWriter(java.io.FileWriter) XMLWriter(org.freeplane.n3.nanoxml.XMLWriter) Writer(java.io.Writer)

Example 3 with XMLWriter

use of org.freeplane.n3.nanoxml.XMLWriter in project freeplane by freeplane.

the class MapWriter method writeMapAsXml.

public void writeMapAsXml(final MapModel map, final Writer fileout, final Mode mode, final boolean saveInvisible, final boolean forceFormat) throws IOException {
    final TreeXmlWriter xmlWriter = new TreeXmlWriter(writeManager, fileout);
    xmlWriter.setHint(Hint.MODE, mode);
    if (forceFormat) {
        xmlWriter.setHint(WriterHint.FORCE_FORMATTING);
    }
    final XMLElement xmlMap = new XMLElement("map");
    setSaveInvisible(saveInvisible);
    xmlWriter.addElement(map, xmlMap);
    xmlWriter.flush();
    fileout.close();
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement) TreeXmlWriter(org.freeplane.core.io.xml.TreeXmlWriter)

Example 4 with XMLWriter

use of org.freeplane.n3.nanoxml.XMLWriter in project freeplane by freeplane.

the class ScannerController method saveScanners.

private void saveScanners(final List<Scanner> scanners) throws IOException {
    final XMLElement saver = new XMLElement();
    saver.setName(ROOT_ELEMENT);
    final String sep = System.getProperty("line.separator");
    final String description = commentLines(// 
    "Description:", // 
    "", // 
    "<scanner> Scanners are locale dependent. If there is no scanner for", // 
    "the selected locale the scanner marked with default=\"true\" is choosen.", // 
    " 'locales': A comma-separated list of locale names.", // 
    "   The locale is selected via Preferences -> Environment -> Language", // 
    "   It's a pattern like 'en' (generic English) or 'en_US'", // 
    "   (English/USA). Use the more general two-letter form if appropriate.", // 
    " 'default': Set to \"true\" for only one locale. The standard is 'en'.", // 
    "", // 
    "<checkfirstchar> allows to enable a fast check for the first input", // 
    "character. If the first input character is not contained in the string", // 
    "given in attribute 'chars' no further attempts are made to parse the", // 
    "input as a number or date.", // 
    "Do not use this option if you have have scanner formats that can", // 
    "recognize arbitrary text at the beginning of the pattern. To disable", // 
    "this check omit <checkfirstchar> or add the attribute disabled=\"true\".", // 
    " 'chars': A string of characters that may start data.", // 
    "", // 
    "<type> selects the kind of data the scanner should recognize.", // 
    " 'style' selects the formatter implementation:", // 
    "  - \"isodate\": flexible ISO date reader for strings like 2011-04-29 22:31:21", // 
    "    Only creates datetimes if time part is given, so no differentiation", // 
    "    between date and date/time is necessary.", // 
    "  - \"date\": a special format for dates; needs attribute 'format'. See", // 
    "    http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html", // 
    "  - \"numberliteral\": parses Java float or integral number literals only, with", // 
    "    a dot as decimal separator and no thousands separator. See", // 
    "    http://en.wikibooks.org/wiki/Java_Programming/Literals/Numeric_Literals/Floating_Point_Literals", // 
    "  - \"decimal\": a special format for numbers; needs attribute 'format'. See", // 
    "    http://download.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html", // 
    " 'format': The format code of a \"date\" or \"decimal\" scanner.", " 'comment': Inline comment, not used by the application.");
    final String header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + sep + description;
    for (Scanner scanner : scanners) {
        saver.addChild(scanner.toXml());
    }
    final Writer writer = new FileWriter(pathToFile);
    final XMLWriter xmlWriter = new XMLWriter(writer);
    xmlWriter.addRawContent(header);
    xmlWriter.write(saver, true);
    writer.close();
}
Also used : FileWriter(java.io.FileWriter) XMLElement(org.freeplane.n3.nanoxml.XMLElement) XMLWriter(org.freeplane.n3.nanoxml.XMLWriter) FileWriter(java.io.FileWriter) XMLWriter(org.freeplane.n3.nanoxml.XMLWriter) Writer(java.io.Writer)

Example 5 with XMLWriter

use of org.freeplane.n3.nanoxml.XMLWriter in project freeplane by freeplane.

the class FilterController method saveConditions.

void saveConditions(final DefaultComboBoxModel filterConditionModel, final String pathToFilterFile) throws IOException {
    final XMLElement saver = new XMLElement();
    saver.setName("filter_conditions");
    final Writer writer = new FileWriter(pathToFilterFile);
    for (int i = 0; i < filterConditionModel.getSize(); i++) {
        final ASelectableCondition cond = (ASelectableCondition) filterConditionModel.getElementAt(i);
        if (cond != null && !(cond instanceof NoFilteringCondition)) {
            cond.toXml(saver);
        }
    }
    final XMLWriter xmlWriter = new XMLWriter(writer);
    xmlWriter.write(saver, true);
    writer.close();
}
Also used : FileWriter(java.io.FileWriter) NoFilteringCondition(org.freeplane.features.filter.condition.NoFilteringCondition) XMLElement(org.freeplane.n3.nanoxml.XMLElement) XMLWriter(org.freeplane.n3.nanoxml.XMLWriter) Writer(java.io.Writer) FileWriter(java.io.FileWriter) XMLWriter(org.freeplane.n3.nanoxml.XMLWriter) ASelectableCondition(org.freeplane.features.filter.condition.ASelectableCondition)

Aggregations

XMLElement (org.freeplane.n3.nanoxml.XMLElement)5 XMLWriter (org.freeplane.n3.nanoxml.XMLWriter)4 FileWriter (java.io.FileWriter)3 Writer (java.io.Writer)3 IOException (java.io.IOException)2 StringWriter (java.io.StringWriter)2 TreeXmlWriter (org.freeplane.core.io.xml.TreeXmlWriter)1 ASelectableCondition (org.freeplane.features.filter.condition.ASelectableCondition)1 NoFilteringCondition (org.freeplane.features.filter.condition.NoFilteringCondition)1 CdataContentXmlWriter (org.freeplane.n3.nanoxml.CdataContentXmlWriter)1