Example usage for org.dom4j Element addText

List of usage examples for org.dom4j Element addText

Introduction

In this page you can find the example usage for org.dom4j Element addText.

Prototype

Element addText(String text);

Source Link

Document

Adds a new Text node with the given text to this element.

Usage

From source file:cz.mzk.editor.server.newObject.PeriodicalItemBuilder.java

License:Open Source License

/**
 * {@inheritDoc}/*from  w ww.j a v a2s . co m*/
 */
@Override
protected void decorateMODSStream() {
    Element modsCollection = FoxmlUtils.createModsCollectionEl();
    Namespace modsNs = Namespaces.mods;
    Element mods = modsCollection.addElement(new QName("mods", modsNs));
    mods.addAttribute("version", "3.3");
    mods.addAttribute("ID", getAditionalInfo());
    Element idUrn = mods.addElement(new QName("identifier", modsNs));
    idUrn.addAttribute("type", "urn");
    idUrn.addText(getUuid());

    Element titleInfo = mods.addElement(new QName("titleInfo", modsNs));

    addRootTitle(titleInfo);
    addRootSubtitle(titleInfo);

    if (isNotNullOrEmpty(getName())) {
        Element partName = titleInfo.addElement(new QName("partName", modsNs));
        partName.addText(getName());
    }

    if (isNotNullOrEmpty(getPartNumber())) {
        Element partNumber = titleInfo.addElement(new QName("partNumber", modsNs));
        partNumber.addText(getPartNumber());
    }

    if (isNotNullOrEmpty(getTypeOfResource())) {
        Element typeOfResourceEl = mods.addElement(new QName("typeOfResource", modsNs));
        typeOfResourceEl.addText(getTypeOfResource());
    }

    Element genre = mods.addElement(new QName("genre", modsNs));
    if (isNotNullOrEmpty(getType()))
        genre.addAttribute("type", getType());
    String levelName = getAditionalInfo().substring(0, getAditionalInfo().indexOf("_", 6));
    genre.addText(Constants.PERIODICAL_ITEM_LEVEL_NAMES.MAP.get(levelName));

    Element originInfo = mods.addElement(new QName("originInfo", modsNs));
    Element dateIssued = originInfo.addElement(new QName("dateIssued", modsNs));
    if (isNotNullOrEmpty(getDateOrIntPartName())) {
        dateIssued.addText(getDateOrIntPartName());
    } else {
        dateIssued.addAttribute("qualifier", "approximate");
    }

    addRootPublisher(originInfo);
    addRootPlace(originInfo);
    addRootLanguage(mods);
    addRootTopic(mods);
    Element locationEl = mods.addElement(new QName("location", modsNs));
    addLocation(locationEl);
    addRootPhysicalLocation(locationEl, false);

    Element physicalDescription = addRootPhysicalDescriptionForm(mods);
    if (isNotNullOrEmpty(getNoteOrIntSubtitle())) {
        Element noteEl = physicalDescription.addElement(new QName("note", modsNs));
        noteEl.addText(getNoteOrIntSubtitle());
    }

    Element part = mods.addElement(new QName("part", modsNs));
    part.addAttribute("type", "issue");

    addIdentifierUuid(mods, getUuid());

    appendDatastream(DATASTREAM_CONTROLGROUP.X, DATASTREAM_ID.BIBLIO_MODS, modsCollection, null, null);

}

From source file:cz.mzk.editor.server.newObject.PeriodicalVolumeBuilder.java

License:Open Source License

/**
 * {@inheritDoc}/*ww w . j a  v  a2 s.c o  m*/
 */
@Override
protected void decorateMODSStream() {

    Element modsCollection = FoxmlUtils.createModsCollectionEl();
    Namespace modsNs = Namespaces.mods;
    Element mods = modsCollection.addElement(new QName("mods", modsNs));
    mods.addAttribute("version", "3.3");
    mods.addAttribute("ID", "MODS_VOLUME_0001");
    Element idUrn = mods.addElement(new QName("identifier", modsNs));
    idUrn.addAttribute("type", "urn");
    idUrn.addText(getUuid());

    Element titleInfo = mods.addElement(new QName("titleInfo", modsNs));

    if (isNotNullOrEmpty(getPartNumber())) {
        Element partNumber = titleInfo.addElement(new QName("partNumber", modsNs));
        partNumber.addText(getPartNumber());
    }

    Element originInfo = mods.addElement(new QName("originInfo", modsNs));
    Element dateIssued = originInfo.addElement(new QName("dateIssued", modsNs));
    if (isNotNullOrEmpty(getDateOrIntPartName())) {
        dateIssued.addText(getDateOrIntPartName());
    } else {
        dateIssued.addAttribute("qualifier", "approximate");
    }

    addRootPublisher(originInfo);
    addRootPlace(originInfo);
    originInfo.addElement(new QName("issuance", modsNs)).addText("continuing");

    addRootPhysicalDescriptionForm(mods);
    Element locationEl = mods.addElement(new QName("location", modsNs));
    addLocation(locationEl);
    addRootPhysicalLocation(locationEl, false);
    addRootRecordInfo(mods.addElement(new QName("recordInfo", modsNs)));

    Element partEl = mods.addElement(new QName("part", modsNs));
    partEl.addAttribute("type", "volume");
    Element detailEl = partEl.addElement(new QName("detail", modsNs));
    detailEl.addAttribute("type", "volume");
    if (isNotNullOrEmpty(getPartNumber()))
        detailEl.addElement(new QName("number", modsNs)).addText(getPartNumber());//"volume number: " + getPartNumber());
    if (getBundle().getMarc() != null && isNotNullOrEmpty(getBundle().getMarc().getDateIssued()))
        partEl.addElement(new QName("date", modsNs))
                .addText(getDateOrIntPartName() != null ? getDateOrIntPartName()
                        : getBundle().getMarc().getDateIssued());

    Element genre = mods.addElement(new QName("genre", modsNs));
    genre.addText("volume");

    if (isNotNullOrEmpty(getNoteOrIntSubtitle())) {
        Element physicalDescription = mods.addElement(new QName("physicalDescription", modsNs));
        Element noteEl = physicalDescription.addElement(new QName("note", modsNs));
        noteEl.addText(getNoteOrIntSubtitle());
    }

    addRootLanguage(mods);
    addIdentifierUuid(mods, getUuid());

    appendDatastream(DATASTREAM_CONTROLGROUP.X, DATASTREAM_ID.BIBLIO_MODS, modsCollection, null, null);

}

From source file:de.ailis.wlandsuite.game.parts.LibraryAction.java

License:Open Source License

/**
 * Returns the library data as XML.//from   w  w w  .  j  a v  a 2s  .c  o  m
 *
 * @param id
 *            The action id
 * @return The library data as XML
 */

@Override
public Element toXml(final int id) {
    Element element;

    element = XmlUtils.createElement("library");

    element.addAttribute("id", StringUtils.toHex(id));
    if (this.name != null && this.name.length() > 0) {
        element.addAttribute("name", this.name);
    }
    if (this.message != 0) {
        element.addAttribute("message", Integer.toString(this.message));
    }
    if (this.newActionClass != 255) {
        element.addAttribute("newActionClass", StringUtils.toHex(this.newActionClass));
    }
    if (this.newAction != 255) {
        element.addAttribute("newAction", StringUtils.toHex(this.newAction));
    }

    for (final int skill : this.skills) {
        Element subElement;

        subElement = XmlUtils.createElement("skill");
        subElement.addText(Integer.toString(skill));

        element.add(subElement);
    }
    return element;
}

From source file:de.ailis.wlandsuite.game.parts.Party.java

License:Open Source License

/**
 * Returns the XML representation of the party.
 *
 * @param id/*from   ww  w .  ja v a 2s. com*/
 *            The party id
 * @return The XML element
 */

public Element toXml(final int id) {
    Element element;

    if (size() > 7) {
        throw new GameException("Party cannot have more than 7 members but this party has " + size());
    }

    element = XmlUtils.createElement("party");
    element.addAttribute("id", Integer.toString(id));
    element.addAttribute("x", Integer.toString(this.x));
    element.addAttribute("y", Integer.toString(this.y));
    element.addAttribute("map", Integer.toString(this.map));
    element.addAttribute("prevX", Integer.toString(this.prevX));
    element.addAttribute("prevY", Integer.toString(this.prevY));
    element.addAttribute("prevMap", Integer.toString(this.prevMap));
    for (final int member : this) {
        Element subElement;

        subElement = XmlUtils.createElement("member");
        subElement.addText(Integer.toString(member));
        element.add(subElement);
    }
    return element;
}

From source file:de.ailis.wlandsuite.game.parts.StoreAction.java

License:Open Source License

/**
 * Returns the store data as XML./*from   w w w .ja  v  a  2 s . co m*/
 *
 * @param id
 *            The action id
 * @return The store data as XML
 */

@Override
public Element toXml(final int id) {
    Element element;

    element = XmlUtils.createElement("store");

    element.addAttribute("id", StringUtils.toHex(id));
    if (this.name != null && this.name.length() > 0) {
        element.addAttribute("name", this.name);
    }
    if (this.message != 0) {
        element.addAttribute("message", Integer.toString(this.message));
    }
    if (this.buyFactor != 0) {
        element.addAttribute("buyFactor", Integer.toString(this.buyFactor));
    }
    if (this.sellFactor != 0) {
        element.addAttribute("sellFactor", Integer.toString(this.sellFactor));
    }
    if (this.itemList != 0) {
        element.addAttribute("itemList", Integer.toString(this.itemList));
    }
    if (this.newActionClass != 255) {
        element.addAttribute("newActionClass", StringUtils.toHex(this.newActionClass));
    }
    if (this.newActionClass != 255) {
        element.addAttribute("newAction", StringUtils.toHex(this.newAction));
    }

    for (final int itemType : this.itemTypes) {
        Element subElement;

        subElement = XmlUtils.createElement("itemType");
        subElement.addText(Integer.toString(itemType));

        element.add(subElement);
    }
    return element;
}

From source file:de.innovationgate.wga.common.beans.LuceneIndexFileRule.java

License:Apache License

/**
 * Saves rules to lucene configuration in wga.xml
 * @param lucene The lucene configuration element
 * @param rules List of {@link LuceneIndexFileRule} objects to be saved
 *//*from w w  w  .  j av  a  2s. com*/
public static void saveRules(Element lucene, List rules) {
    Element filerules = WGUtils.getOrCreateElement(lucene, "filerules");
    //remove old rules
    filerules.clearContent();
    Iterator itemrulesIt = rules.iterator();
    while (itemrulesIt.hasNext()) {
        LuceneIndexFileRule rule = (LuceneIndexFileRule) itemrulesIt.next();
        Element ruleElement = filerules.addElement("filerule");
        ruleElement.addAttribute("filesizelimit", new Integer(rule.getFileSizeLimit()).toString());
        if (rule.isIncludedInAllContent()) {
            ruleElement.addAttribute("includedinallcontent", "true");
        } else {
            ruleElement.addAttribute("includedinallcontent", "false");
        }
        ruleElement.addAttribute("boost", Float.toString(rule.getBoost()));
        ruleElement.addText(rule.getFilePattern());
    }
}

From source file:de.innovationgate.wga.common.beans.LuceneIndexFileRule.java

License:Apache License

/**
 * adds the default rule to the lucene.itemrules element
 * @param lucene luceneElement/*from  w  w w.ja  v  a  2  s  .c o m*/
 */
public static void addDefaultRule(Element lucene) {
    Element rules = lucene.element("filerules");
    LuceneIndexFileRule rule = getDefaultRule();
    Element ruleElement = rules.addElement("filerule");
    ruleElement.addAttribute("filesizelimit", new Integer(rule.getFileSizeLimit()).toString());
    if (rule.isIncludedInAllContent()) {
        ruleElement.addAttribute("includedinallcontent", "true");
    } else {
        ruleElement.addAttribute("includedinallcontent", "false");
    }
    ruleElement.addAttribute("boost", Float.toString(rule.getBoost()));
    ruleElement.addText(rule.getFilePattern());
}

From source file:de.innovationgate.wga.common.beans.LuceneIndexItemRule.java

License:Apache License

/**
 * Saves rules to lucene configuration in wga.xml
 * @param lucene The lucene configuration element
 * @param rules List of {@link LuceneIndexItemRule} objects to be saved
 *//*from  w w w. j  a  v  a 2 s.c  o  m*/
public static void saveRules(Element lucene, List rules) {
    Element itemrules = lucene.element("itemrules");
    //remove old rules
    itemrules.clearContent();
    Iterator itemrulesIt = rules.iterator();
    while (itemrulesIt.hasNext()) {
        LuceneIndexItemRule rule = (LuceneIndexItemRule) itemrulesIt.next();
        Element itemrule = itemrules.addElement("itemrule");
        itemrule.addAttribute("indextype", rule.getIndexType());
        itemrule.addAttribute("contenttype", rule.getContentType());
        if (rule.isSortable()) {
            itemrule.addAttribute("sortable", "true");
        } else {
            itemrule.addAttribute("sortable", "false");
        }
        itemrule.addAttribute("boost", Float.toString(rule.getBoost()));
        itemrule.addText(rule.getItemExpression());
    }
}

From source file:de.innovationgate.wga.common.beans.LuceneIndexItemRule.java

License:Apache License

/**
 * adds the default rule to the lucene.itemrules element
 * @param lucene luceneElement//from www  .  ja  va  2s  . com
 */
public static void addDefaultRule(Element lucene) {
    Element itemrules = lucene.element("itemrules");
    LuceneIndexItemRule rule = getDefaultRule();
    Element itemrule = itemrules.addElement("itemrule");
    itemrule.addAttribute("indextype", rule.getIndexType());
    itemrule.addAttribute("contenttype", rule.getContentType());
    if (rule.isSortable()) {
        itemrule.addAttribute("sortable", "true");
    } else {
        itemrule.addAttribute("sortable", "false");
    }
    itemrule.addAttribute("boost", Float.toString(rule.getBoost()));
    itemrule.addText(rule.getItemExpression());

}

From source file:de.innovationgate.wgpublisher.webtml.Base.java

License:Open Source License

/**
 * @param rootElement/*w ww .  j av  a2  s .com*/
 */
protected void createDebugNode(Element parent) {

    BaseTagStatus status = getStatus();

    status.starttime = System.currentTimeMillis();

    String className = getClass().getName();
    className = className.substring(className.lastIndexOf(".") + 1).toLowerCase();

    status.debugNode = parent.addElement("tmltag");
    status.debugNode.addAttribute("name", className);
    if (this instanceof Root) {
        status.debugNode.addAttribute("resource", ((Root) this).getResource());
        status.debugNode.addAttribute("path", status.debugNode.getUniquePath());
    }
    status.debugNode.addAttribute("sourceline", getSourceline());
    status.debugNode.addAttribute("started", DEBUG_TIMESTAMP_FORMAT.format(new Date()));
    status.debugNode.addAttribute("level", String.valueOf(getLevel()));

    if (status.debugNode.getDocument().getRootElement().attributeValue("traceroptions", "false")
            .equals("false")) {
        return;
    }

    Element options = status.debugNode.addElement("options");
    Iterator<String> opts = status.tagOptions.keySet().iterator();
    String key;
    Element optionElem;
    TMLOption tmloption;
    while (opts.hasNext()) {
        key = (String) opts.next();
        if (!key.startsWith("$")) {
            tmloption = status.tagOptions.get(key);
            optionElem = options.addElement("option");
            optionElem.addAttribute("name", tmloption.getName());
            optionElem.addAttribute("type",
                    (tmloption.getValue() != null ? tmloption.getValue().getClass().getName() : "(none)"));
            optionElem.addText(String.valueOf(tmloption.getValue()));
        }
    }
}