Example usage for org.jdom2 Element setText

List of usage examples for org.jdom2 Element setText

Introduction

In this page you can find the example usage for org.jdom2 Element setText.

Prototype

public Element setText(final String text) 

Source Link

Document

Sets the content of the element to be the text given.

Usage

From source file:de.relaunch64.popelganda.database.Settings.java

License:Open Source License

public void setLastUserScript(int index) {
    Element el = root.getChild(SETTING_LAST_SCRIPT);
    if (null == el) {
        el = new Element(SETTING_LAST_SCRIPT);
        root.addContent(el);/*from www .  jav  a  2 s.  c  o  m*/
    }
    el.setText(String.valueOf(index));
}

From source file:de.relaunch64.popelganda.database.Settings.java

License:Open Source License

public void setMainFont(Font f) {
    Element el = root.getChild(SETTING_MAINFONT);
    if (null == el) {
        el = new Element(SETTING_MAINFONT);
        root.addContent(el);// www.j a v  a2  s .  co  m
    }
    el.setText(f.getName());
    el.setAttribute("size", String.valueOf(f.getSize()));
}

From source file:de.relaunch64.popelganda.database.Settings.java

License:Open Source License

public void setLogSplitLayout(int val) {
    Element el = root.getChild(SETTING_LOGSPLITLAYOUT);
    if (null == el) {
        el = new Element(SETTING_LOGSPLITLAYOUT);
        root.addContent(el);/*from   ww  w. ja va  2s .com*/
    }
    el.setText(String.valueOf(val));
}

From source file:de.relaunch64.popelganda.database.Settings.java

License:Open Source License

public void setLineNumerAlignment(int align) {
    Element el = root.getChild(SETTING_LINE_NUMBER_ALIGNMENT);
    if (null == el) {
        el = new Element(SETTING_LINE_NUMBER_ALIGNMENT);
        root.addContent(el);/*from   w  w  w  .ja v a2 s .  c  o  m*/
    }
    el.setText(String.valueOf(align));
}

From source file:de.relaunch64.popelganda.database.Settings.java

License:Open Source License

public void setReopenFiles(EditorPanes ep) {
    Element el = root.getChild(SETTING_REOPEN_FILES);
    if (null == el) {
        el = new Element(SETTING_REOPEN_FILES);
        root.addContent(el);//  w  w w . j  a  v a 2  s.c om
    }
    // remove existing content
    el.removeContent();
    // iterate all editorpanes and store file pathes
    for (int i = 0; i < ep.getCount(); i++) {
        // get file path and compiler settings of each file
        File fp = ep.getFilePath(i);
        int c = ep.getAssembler(i).getID();
        int s = ep.getScript(i);
        // save if exists
        if (fp != null && fp.exists()) {
            // create new child element
            Element child = new Element(SETTING_REOPEN_FILES_CHILD);
            // add path and compiler
            child.setText(fp.getAbsolutePath());
            child.setAttribute(ATTR_ASM, String.valueOf(c));
            child.setAttribute(ATTR_SCRIPT, String.valueOf(s));
            // add to database
            el.addContent(child);
        }
    }
}

From source file:de.tor.tribes.util.report.ReportRule.java

License:Apache License

public Element toXml(String name) {
    Element rule = new Element(name);
    rule.addContent(new Element("type").setText(type.name()));
    rule.addContent(new Element("targetSet").setText(targetSet));
    Element settings = new Element("settings");

    switch (type) {
    case AGE:/*from  w w  w . jav a 2s.c  o m*/
        Long maxAge = (Long) filterComponent;
        settings.setText(maxAge.toString());
        break;
    case ATTACKER_ALLY:
        List<Ally> attAllyList = (List<Ally>) filterComponent;
        for (Ally a : attAllyList) {
            settings.addContent(new Element("ally").setText(Integer.toString(a.getId())));
        }
        break;
    case ATTACKER_TRIBE:
        List<Tribe> attTribeList = (List<Tribe>) filterComponent;
        for (Tribe t : attTribeList) {
            settings.addContent(new Element("tribe").setText(Integer.toString(t.getId())));
        }
        break;
    case COLOR:
        Integer color = (Integer) filterComponent;
        settings.setText(color.toString());
        break;
    case DATE:
        Range<Long> dates = (Range<Long>) filterComponent;
        settings.setText(dates.getMinimum() + "-" + dates.getMaximum());
        break;
    case DEFENDER_ALLY:
        List<Ally> defAllyList = (List<Ally>) filterComponent;
        for (Ally a : defAllyList) {
            settings.addContent(new Element("ally").setText(Integer.toString(a.getId())));
        }
        break;
    case DEFENDER_TRIBE:
        List<Tribe> defTribeList = (List<Tribe>) filterComponent;
        for (Tribe t : defTribeList) {
            settings.addContent(new Element("tribe").setText(Integer.toString(t.getId())));
        }
        break;
    case CATA:
    case CONQUERED:
    case FAKE:
    case FARM:
    case OFF:
    case WALL:
        break;
    default:
        throw new IllegalArgumentException("wrong type");
    }

    rule.addContent(settings);
    return rule;
}

From source file:de.unigoettingen.sub.search.opac.ConfigOpacCatalogue.java

License:Open Source License

/**
 * Beautifier fr ein JDom-Object durchfhren ================================================================
 *//*w ww.  ja  v a 2s .  c  o  m*/

private void executeBeautifierForElement(Element el) {
    String matchedValue = "";
    for (ConfigOpacCatalogueBeautifier beautifier : this.beautifySetList) {
        Element subfieldToChange = null;
        Element mainFieldToChange = null;
        /* eine Kopie der zu prfenden Elemente anlegen (damit man darin lschen kann */

        ArrayList<ConfigOpacCatalogueBeautifierElement> prooflist = new ArrayList<ConfigOpacCatalogueBeautifierElement>(
                beautifier.getTagElementsToProof());
        /* von jedem Record jedes Field durchlaufen */
        List<Element> elements = el.getChildren("field");
        boolean foundValue = false;
        for (Element field : elements) {
            String tag = field.getAttributeValue("tag");

            if (beautifier.getTagElementToChange().getTag().equals(tag)) {
                mainFieldToChange = field;
            }

            /* von jedem Field alle Subfelder durchlaufen */
            List<Element> subelements = field.getChildren("subfield");
            for (Element subfield : subelements) {
                String subtag = subfield.getAttributeValue("code");
                String value = subfield.getText();

                if (beautifier.getTagElementToChange().getTag().equals(tag)
                        && beautifier.getTagElementToChange().getSubtag().equals(subtag)) {
                    subfieldToChange = subfield;
                }
                /*
                 * wenn die Werte des Subfeldes in der Liste der zu prfenden Beutifier-Felder stehen, dieses aus der Liste der Beautifier
                 * entfernen
                 */
                if (!prooflist.isEmpty()) {
                    for (ConfigOpacCatalogueBeautifierElement cocbe : beautifier.getTagElementsToProof()) {
                        if (cocbe.getValue().equals("*")) {
                            if (cocbe.getTag().equals(tag) && cocbe.getSubtag().equals(subtag)) {
                                if (!foundValue) {
                                    matchedValue = value;
                                    foundValue = true;
                                }
                                prooflist.remove(cocbe);
                            }
                        } else if (cocbe.getTag().equals(tag) && cocbe.getSubtag().equals(subtag)
                                && value.matches(cocbe.getValue())) {
                            if (!foundValue) {
                                matchedValue = value;
                            }
                            prooflist.remove(cocbe);
                        }
                    }
                }
            }
        }
        /*
         * --------------------- wenn in der Kopie der zu prfenden Elemente keine Elemente mehr enthalten sind, kann der zu ndernde Wert
         * wirklich gendert werden -------------------
         */

        // check main field
        if (prooflist.size() == 0 && mainFieldToChange == null) {
            mainFieldToChange = new Element("field");
            mainFieldToChange.setAttribute("tag", beautifier.getTagElementToChange().getTag());
            elements.add(mainFieldToChange);
        }

        // check subfield
        if (prooflist.size() == 0 && subfieldToChange == null) {
            //                Element field = new Element("field");
            //                field.setAttribute("tag", beautifier.getTagElementToChange().getTag());
            subfieldToChange = new Element("subfield");
            subfieldToChange.setAttribute("code", beautifier.getTagElementToChange().getSubtag());
            mainFieldToChange.addContent(subfieldToChange);
            //                elements.add(field);
        }

        if (prooflist.size() == 0) {
            if (beautifier.getTagElementToChange().getValue().equals("*")) {
                subfieldToChange.setText(matchedValue);
            } else {
                subfieldToChange.setText(beautifier.getTagElementToChange().getValue());
            }
        }

    }

}

From source file:devicemodel.conversions.XmlConversions.java

public static Element nodeToXml(DeviceNode node) {
    Element elem = new Element(node.getName());
    if (node.getAttributes().size() > 0) {
        for (String key : node.getAttributes().keySet()) {
            elem.getAttributes().add(new Attribute(key, node.getAttribute(key)));
        }/* w  ww.  j  a  v a  2s.  c  om*/
    }
    if (node.getValue() != null) {
        elem.setText(node.getValue());
    }

    if (node.getChildren().size() > 0) {
        List<String> children = node.getChildrenNamesSorted();
        for (String child : children) {
            elem.getChildren().add(nodeToXml(node.getChild(child)));
        }
    }

    return elem;
}

From source file:domainapp.app.services.export.ExportToWordMenu.java

License:Apache License

private static void addPara(final Element body, final String id, final String clazz, final String text) {
    final Element p = new Element("p");
    body.addContent(p);/*from w  ww. j  a  v a2 s. c o m*/
    p.setAttribute("id", id);
    p.setAttribute("class", clazz);
    p.setText(text);
}

From source file:domainapp.app.services.export.ExportToWordMenu.java

License:Apache License

private static void addPara(final Element li, final String text) {
    if (text == null) {
        return;/*from  www  .j  av  a 2s. c om*/
    }
    final Element p = new Element("p");
    li.addContent(p);
    p.setText(text);
}