Example usage for org.jdom2 Element addContent

List of usage examples for org.jdom2 Element addContent

Introduction

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

Prototype

@Override
public Element addContent(final Collection<? extends Content> newContent) 

Source Link

Document

Appends all children in the given collection to the end of the content list.

Usage

From source file:de.bund.bfr.fskml.FskMetaDataObject.java

License:Open Source License

public FskMetaDataObject(ResourceType resourceType) {

    Element typeNode = factory.element("type", dcNamespace);
    typeNode.setText(resourceType.name());

    Element element = factory.element("element");
    element.addContent(typeNode);

    metaDataObject = new DefaultMetaDataObject(element);
}

From source file:de.bund.bfr.knime.pmm.common.ParametricModel.java

License:Open Source License

@Override
public Element toXmlElement() {
    Element modelElement = new Element(ELEMENT_PARAMETRICMODEL);
    modelElement.setAttribute(ATT_MDBUUID, m_dbuuid == null ? "" : m_dbuuid);
    modelElement.setAttribute(ATT_EMDBUUID, em_dbuuid == null ? "" : em_dbuuid);
    modelElement.setAttribute(ATT_MODELNAME, modelName);
    modelElement.setAttribute(ATT_MODELCLASS, XmlHelper.getNonNull(modelClass));
    modelElement.setAttribute("FittedModelName", fittedModelName == null ? "" : fittedModelName);
    modelElement.setAttribute(ATT_LEVEL, String.valueOf(level));
    modelElement.setAttribute(ATT_MODELID, String.valueOf(modelId));
    modelElement.setAttribute(ATT_ESTMODELID, String.valueOf(estModelId));
    modelElement.setAttribute(ATT_GLOBALMODELID, String.valueOf(globalModelId));
    modelElement.setAttribute(ATT_CONDID, String.valueOf(condId));
    modelElement.setAttribute(ATT_RSS, String.valueOf(rss));
    modelElement.setAttribute(ATT_RMS, String.valueOf(rms));
    modelElement.setAttribute(ATT_AIC, String.valueOf(aic));
    modelElement.setAttribute(ATT_BIC, String.valueOf(bic));
    modelElement.setAttribute(ATT_CHECKED, isChecked == null ? "" : String.valueOf(isChecked));
    modelElement.setAttribute(ATT_COMMENT, comment == null ? "" : comment);
    modelElement.setAttribute(ATT_QSCORE, qualityScore == null ? "" : String.valueOf(qualityScore));

    modelElement.setAttribute(ATT_RSQUARED, String.valueOf(rsquared));

    Element element = new Element(ATT_FORMULA);
    element.addContent(formula);
    modelElement.addContent(element);/*  w w  w.  j  av  a 2  s  .c o  m*/

    element = new Element(ATT_PARAM);
    element.addContent(parameter.toXmlString());
    modelElement.addContent(element);

    element = new Element(ATT_INDEP);
    element.addContent(independent.toXmlString());
    modelElement.addContent(element);

    if (depXml != null) {
        element = new Element(ATT_DEP);
        PmmXmlDoc pd = new PmmXmlDoc();
        pd.add(depXml);
        element.addContent(pd.toXmlString());
        modelElement.addContent(element);
    }

    element = new Element(ATT_MLIT);
    element.addContent(modelLit.toXmlString());
    modelElement.addContent(element);
    element = new Element(ATT_EMLIT);
    element.addContent(estLit.toXmlString());
    modelElement.addContent(element);

    return modelElement;
}

From source file:de.bund.bfr.knime.pmm.common.ParamXml.java

License:Open Source License

@Override
public Element toXmlElement() {
    Element ret = new Element(ELEMENT_PARAM);

    ret.setAttribute(ATT_NAME, XmlHelper.getNonNull(name));
    ret.setAttribute(ATT_ORIGNAME, XmlHelper.getNonNull(origName));
    ret.setAttribute(ATT_IS_START, XmlHelper.getNonNull(isStartParam));
    ret.setAttribute(ATT_VALUE, XmlHelper.getNonNull(value));
    ret.setAttribute(ATT_ERROR, XmlHelper.getNonNull(error));
    ret.setAttribute(ATT_MIN, XmlHelper.getNonNull(min));
    ret.setAttribute(ATT_MAX, XmlHelper.getNonNull(max));
    ret.setAttribute(ATT_P, XmlHelper.getNonNull(P));
    ret.setAttribute(ATT_T, XmlHelper.getNonNull(t));
    ret.setAttribute(ATT_MINGUESS, XmlHelper.getNonNull(minGuess));
    ret.setAttribute(ATT_MAXGUESS, XmlHelper.getNonNull(maxGuess));
    ret.setAttribute(ATT_CATEGORY, XmlHelper.getNonNull(category));
    ret.setAttribute(ATT_UNIT, XmlHelper.getNonNull(unit));
    ret.setAttribute(ATT_DESCRIPTION, XmlHelper.getNonNull(description));

    if (correlations != null) {
        for (String origname : correlations.keySet()) {
            Element element = new Element(ATT_CORRELATION);
            Double d = correlations.get(origname);

            element.setAttribute(ATT_ORIGNAME, origname);
            element.setAttribute(ATT_VALUE, XmlHelper.getNonNull(d));
            ret.addContent(element);
        }/*w  w  w.  j  a  v a  2 s  .  c  o  m*/
    }

    return ret;
}

From source file:de.bund.bfr.knime.pmm.common.PmmTimeSeries.java

License:Open Source License

@Override
public Element toXmlElement() {
    Element ret = new Element(ELEMENT_TIMESERIES);
    try {//from w  w w  .  j  a v  a  2  s .c o  m
        if (getCondId() != null) {
            ret.setAttribute(TimeSeriesSchema.ATT_CONDID, getCondId() + "");
        }
        if (getCombaseId() != null) {
            if (!getCombaseId().isEmpty()) {
                ret.setAttribute(TimeSeriesSchema.ATT_COMBASEID, getCombaseId());
            }
        }
        if (hasMatrix()) {
            ret.setAttribute(TimeSeriesSchema.ATT_MATRIX, getMatrix().toXmlString());
        }
        if (hasAgent()) {
            ret.setAttribute(TimeSeriesSchema.ATT_AGENT, getAgent().toXmlString());
        }
        if (hasMisc()) {
            ret.setAttribute(TimeSeriesSchema.ATT_MISC, getMisc().toXmlString());
        }
        Element element = new Element(ELEMENT_TSXML);
        PmmXmlDoc timeSeriesXmlDoc = this.getPmmXml(TimeSeriesSchema.ATT_TIMESERIES);
        element.addContent(timeSeriesXmlDoc.toXmlString());
        ret.addContent(element);
        element = new Element(ELEMENT_MDINFO);
        PmmXmlDoc mdInfoXmlDoc = this.getPmmXml(TimeSeriesSchema.ATT_MDINFO);
        element.addContent(mdInfoXmlDoc.toXmlString());
        ret.addContent(element);
        element = new Element(ELEMENT_LITMD);
        PmmXmlDoc litMdDoc = this.getPmmXml(TimeSeriesSchema.ATT_LITMD);
        element.addContent(litMdDoc.toXmlString());
        ret.addContent(element);
        ret.setAttribute(TimeSeriesSchema.ATT_DBUUID,
                XmlHelper.getNonNull(getString(TimeSeriesSchema.ATT_DBUUID)));
    } catch (PmmException ex) {
        ex.printStackTrace();
    }
    return ret;
}

From source file:de.bund.bfr.knime.pmm.common.PmmXmlDoc.java

License:Open Source License

public Document toXmlDocument() {
    Document doc = new Document();
    Element rootElement = new Element(ELEMENT_PMMDOC);
    doc.setRootElement(rootElement);//from   w ww.  j a  va  2 s.c  om

    for (PmmXmlElementConvertable element : elementSet) {
        rootElement.addContent(element.toXmlElement());
    }
    return doc;
}

From source file:de.bund.bfr.knime.pmm.extendedtable.Model1Metadata.java

License:Open Source License

public Document toXmlDocument() {
    Document doc = new Document();
    Element rootElement = new Element(ELEMENT_PMMDOC);
    doc.setRootElement(rootElement);/*w  w  w  . j av a2  s .c  o m*/

    if (agentXml != null) {
        rootElement.addContent(agentXml.toXmlElement());
    }
    if (matrixXml != null) {
        rootElement.addContent(matrixXml.toXmlElement());
    }
    for (MLiteratureItem literatureItem : modelLiteratureItems) {
        rootElement.addContent(literatureItem.toXmlElement());
    }
    for (EMLiteratureItem literatureItem : estimatedModelLiteratureItems) {
        rootElement.addContent(literatureItem.toXmlElement());
    }

    return doc;
}

From source file:de.bund.bfr.knime.pmm.extendedtable.TimeSeriesMetadata.java

License:Open Source License

public Document toXmlDocument() {
    Document doc = new Document();
    Element rootElement = new Element(ELEMENT_PMMDOC);
    doc.setRootElement(rootElement);/*from ww w.  j  a  v  a 2s  .  co m*/

    if (agentXml != null) {
        rootElement.addContent(agentXml.toXmlElement());
    }
    if (matrixXml != null) {
        rootElement.addContent(matrixXml.toXmlElement());
    }
    for (MDLiteratureItem literatureItem : literatureItems) {
        rootElement.addContent(literatureItem.toXmlElement());
    }

    return doc;
}

From source file:de.bund.bfr.pmfml.file.PMFMetadataNode.java

License:Open Source License

public PMFMetadataNode(final ModelType modelType, final Set<String> masterFiles) {
    this.modelType = modelType;
    this.masterFiles = masterFiles;

    node = new Element("metaParent");
    final Element modelTypeElement = new Element(MODEL_TYPE_TAG);
    modelTypeElement.addContent(modelType.name());
    node.addContent(modelTypeElement);/*from  w  w w  .j  a v  a2 s  .  c  o m*/
    for (final String masterFile : masterFiles) {
        final Element masterFileElement = new Element(MASTER_FILE_TAG);
        masterFileElement.addContent(masterFile);
        node.addContent(masterFileElement);
    }
}

From source file:de.danielluedecke.zettelkasten.database.Bookmarks.java

License:Open Source License

/**
 * Adds a new bookmark to the bookmark-file. First, we have to check whether
 * the bookmark already exists. If not, add it. Then we have to check for the
 * category. If it already exists, retrieve the category's index-number. Else
 * add a new category.//from w  w w.  java2s . c o m
 * <br><br>
 * Use "getCompleteBookmark" for retrieving a bookmark's entry-number, category
 * and comment.
 * 
 * @param index the index-number of the bookmark, i.e. the entry's number
 * @param cat the category, under which the bookmark should appear.
 * @param comment an optional comment for the bookmark
 */
public void addBookmark(int index, String cat, String comment) {
    // first check whether this index-number was already bookmarked...
    // if not, a -1 is return, else the index-number
    // if the bookmark already exists, do nothing
    if (-1 == getBookmarkPosition(index)) {
        try {
            // retrieve the position of the category
            int catpos = getCategoryPosition(cat);
            // check whether the category exists
            if (-1 == catpos) {
                // if the category doesn't already exist, add it
                catpos = addCategory(cat);
            }
            // create new bookmark-element
            Element bm = new Element(Daten.ELEMENT_ENTRY);
            // set the id, i.e. the number of the entry which is bookmarked
            bm.setAttribute("id", String.valueOf(index));
            // set the category-index for this bookmark
            bm.setAttribute("cat", String.valueOf(catpos));
            // and add the comment
            if (null == comment) {
                comment = "";
            }
            bm.setText(comment);
            // retrieve the bookmark-"root"-element
            Element bookbase = bookmarks.getRootElement().getChild("bookmark");
            // and add the bookmark-element
            bookbase.addContent(bm);
            // change modified-state
            setModified(true);
        } catch (IllegalAddException ex) {
            Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
        } catch (IllegalNameException ex) {
            Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
        } catch (IllegalDataException ex) {
            Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
        }
    }
}

From source file:de.danielluedecke.zettelkasten.database.Bookmarks.java

License:Open Source License

/**
 * Adds a new category string to the bookmarks category list.
 * //from   w ww .  j ava  2s. c o  m
 * @param cat a string with the new category-name
 * @return the index of the currently added category (which equals the new size of the amount 
 * of categories - 1)
 */
public int addCategory(String cat) {
    // get the sub-element "category" of the bookmarks xml datafile
    Element category = bookmarks.getRootElement().getChild("category");
    // create a new category element
    Element newCat = new Element(Daten.ELEMENT_ENTRY);
    // add the new category element to the bookmarks datafile
    category.addContent(newCat);
    // and finally add the parameter (new category string) to the recently created
    // category element
    newCat.setText(cat);
    setModified(true);
    // return the new size of the categories, i.e. the category position of 
    // the recently added category entry
    return bookmarks.getRootElement().getChild("category").getContentSize() - 1;
}