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:org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.java

License:Apache License

/**
 * Add creator property element if needed.
 *///  w ww.  j  a  v a2s  .co  m
private void addCreator() {
    if (!propsPart.getCreatorProperty().hasValue())
        return;

    Element elem = xmlDoc.getRootElement().element(new QName(KEYWORD_CREATOR, namespaceDC));
    if (elem == null) {
        // missing, we add it
        elem = xmlDoc.getRootElement().addElement(new QName(KEYWORD_CREATOR, namespaceDC));
    } else {
        elem.clearContent();// clear the old value
    }
    elem.addText(propsPart.getCreatorProperty().getValue());
}

From source file:org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.java

License:Apache License

/**
 * Add description property element if needed.
 *///from  w ww. j  a va2 s.c  o  m
private void addDescription() {
    if (!propsPart.getDescriptionProperty().hasValue())
        return;

    Element elem = xmlDoc.getRootElement().element(new QName(KEYWORD_DESCRIPTION, namespaceDC));
    if (elem == null) {
        // missing, we add it
        elem = xmlDoc.getRootElement().addElement(new QName(KEYWORD_DESCRIPTION, namespaceDC));
    } else {
        elem.clearContent();// clear the old value
    }
    elem.addText(propsPart.getDescriptionProperty().getValue());
}

From source file:org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.java

License:Apache License

/**
 * Add identifier property element if needed.
 *//*from ww w  .  ja v a 2  s  . c o  m*/
private void addIdentifier() {
    if (!propsPart.getIdentifierProperty().hasValue())
        return;

    Element elem = xmlDoc.getRootElement().element(new QName(KEYWORD_IDENTIFIER, namespaceDC));
    if (elem == null) {
        // missing, we add it
        elem = xmlDoc.getRootElement().addElement(new QName(KEYWORD_IDENTIFIER, namespaceDC));
    } else {
        elem.clearContent();// clear the old value
    }
    elem.addText(propsPart.getIdentifierProperty().getValue());
}

From source file:org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.java

License:Apache License

/**
 * Add keywords property element if needed.
 *//*from   w w  w.ja v  a2 s.c o m*/
private void addKeywords() {
    if (!propsPart.getKeywordsProperty().hasValue())
        return;

    Element elem = xmlDoc.getRootElement().element(new QName(KEYWORD_KEYWORDS, namespaceCoreProperties));
    if (elem == null) {
        // missing, we add it
        elem = xmlDoc.getRootElement().addElement(new QName(KEYWORD_KEYWORDS, namespaceCoreProperties));
    } else {
        elem.clearContent();// clear the old value
    }
    elem.addText(propsPart.getKeywordsProperty().getValue());
}

From source file:org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.java

License:Apache License

/**
 * Add language property element if needed.
 *///from w w w.  j a v  a 2s. co m
private void addLanguage() {
    if (!propsPart.getLanguageProperty().hasValue())
        return;

    Element elem = xmlDoc.getRootElement().element(new QName(KEYWORD_LANGUAGE, namespaceDC));
    if (elem == null) {
        // missing, we add it
        elem = xmlDoc.getRootElement().addElement(new QName(KEYWORD_LANGUAGE, namespaceDC));
    } else {
        elem.clearContent();// clear the old value
    }
    elem.addText(propsPart.getLanguageProperty().getValue());
}

From source file:org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.java

License:Apache License

/**
 * Add 'last modified by' property if needed.
 *//*from  w  ww  . j  av a 2s  . c om*/
private void addLastModifiedBy() {
    if (!propsPart.getLastModifiedByProperty().hasValue())
        return;

    Element elem = xmlDoc.getRootElement()
            .element(new QName(KEYWORD_LAST_MODIFIED_BY, namespaceCoreProperties));
    if (elem == null) {
        // missing, we add it
        elem = xmlDoc.getRootElement().addElement(new QName(KEYWORD_LAST_MODIFIED_BY, namespaceCoreProperties));
    } else {
        elem.clearContent();// clear the old value
    }
    elem.addText(propsPart.getLastModifiedByProperty().getValue());
}

From source file:org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.java

License:Apache License

/**
 * Add 'last printed' property if needed.
 *
 *///from  w ww .ja  v  a  2  s . co  m
private void addLastPrinted() {
    if (!propsPart.getLastPrintedProperty().hasValue())
        return;

    Element elem = xmlDoc.getRootElement().element(new QName(KEYWORD_LAST_PRINTED, namespaceCoreProperties));
    if (elem == null) {
        // missing, we add it
        elem = xmlDoc.getRootElement().addElement(new QName(KEYWORD_LAST_PRINTED, namespaceCoreProperties));
    } else {
        elem.clearContent();// clear the old value
    }
    elem.addText(propsPart.getLastPrintedPropertyString());
}

From source file:org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.java

License:Apache License

/**
 * Add modified property element if needed.
 *///from  w  w w .  j a  v a 2 s  .c  o m
private void addModified() {
    if (!propsPart.getModifiedProperty().hasValue())
        return;

    Element elem = xmlDoc.getRootElement().element(new QName(KEYWORD_MODIFIED, namespaceDcTerms));
    if (elem == null) {
        // missing, we add it
        elem = xmlDoc.getRootElement().addElement(new QName(KEYWORD_MODIFIED, namespaceDcTerms));
    } else {
        elem.clearContent();// clear the old value
    }
    elem.addAttribute(new QName("type", namespaceXSI), "dcterms:W3CDTF");
    elem.addText(propsPart.getModifiedPropertyString());
}

From source file:org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.java

License:Apache License

/**
 * Add revision property if needed./*from  w w w .j  a  v  a  2  s .c o  m*/
 */
private void addRevision() {
    if (!propsPart.getRevisionProperty().hasValue())
        return;

    Element elem = xmlDoc.getRootElement().element(new QName(KEYWORD_REVISION, namespaceCoreProperties));
    if (elem == null) {
        // missing, we add it
        elem = xmlDoc.getRootElement().addElement(new QName(KEYWORD_REVISION, namespaceCoreProperties));
    } else {
        elem.clearContent();// clear the old value
    }
    elem.addText(propsPart.getRevisionProperty().getValue());
}

From source file:org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.java

License:Apache License

/**
 * Add subject property if needed./*from w  w w  . j av a  2  s .co  m*/
 */
private void addSubject() {
    if (!propsPart.getSubjectProperty().hasValue())
        return;

    Element elem = xmlDoc.getRootElement().element(new QName(KEYWORD_SUBJECT, namespaceDC));
    if (elem == null) {
        // missing, we add it
        elem = xmlDoc.getRootElement().addElement(new QName(KEYWORD_SUBJECT, namespaceDC));
    } else {
        elem.clearContent();// clear the old value
    }
    elem.addText(propsPart.getSubjectProperty().getValue());
}