List of usage examples for org.jdom2 Element addContent
@Override public Element addContent(final Collection<? extends Content> newContent)
From source file:ca.nrc.cadc.caom2.xml.ObservationWriter.java
License:Open Source License
/** * Builds a JDOM representation of a RefCoord and adds it to the parent * element.// w w w.jav a 2 s . com * * @param name * The name of the element. * @param refCoord * The RefCoord to add to the parent. * @param parent * The parent element for this child element. */ protected void addRefCoordElement(String name, RefCoord refCoord, Element parent) { if (refCoord == null) { return; } Element element = getCaom2Element(name); addNumberElement("pix", refCoord.pix, element); addNumberElement("val", refCoord.val, element); parent.addContent(element); }
From source file:ca.nrc.cadc.caom2.xml.ObservationWriter.java
License:Open Source License
/** * Builds a JDOM representation of a Slice and adds it to the parent * element./*from w w w .j a v a 2 s .c o m*/ * * @param name * The name of the element. * @param slice * The Slice to add to the parent. * @param parent * The parent element for this child element. */ protected void addSliceElement(String name, Slice slice, Element parent) { if (slice == null) { return; } Element element = getCaom2Element(name); addAxisElement("axis", slice.getAxis(), element); addNumberElement("bin", slice.getBin(), element); parent.addContent(element); }
From source file:ca.nrc.cadc.caom2.xml.ObservationWriter.java
License:Open Source License
/** * Builds a JDOM representation Element with the given name and sets the * text to the given value, then adds the element to the parent. * //w ww . j a v a2 s. c o m * @param name * The name of the element. * @param value * The value for the element. * @param parent * The parent element for this child element. */ protected void addElement(String name, String value, Element parent) { if (value == null) { return; } Element element = new Element(name, caom2Namespace); element.setText(value); parent.addContent(element); }
From source file:ca.nrc.cadc.caom2.xml.ObservationWriter.java
License:Open Source License
/** * Builds a JDOM representation Element with the given name and sets the * text to the given value, then adds the element to the parent. * //from ww w . j ava 2s . co m * @param name * The name of the element. * @param number * The value for the element. * @param parent * The parent element for this child element. */ protected void addNumberElement(String name, Number number, Element parent) { if (number == null) { return; } Element element = new Element(name, caom2Namespace); element.setText(number.toString()); parent.addContent(element); }
From source file:ca.nrc.cadc.caom2.xml.ObservationWriter.java
License:Open Source License
/** * Builds a JDOM representation Element with the given name and sets the * text to true if the value is true, else sets the text to false, then adds * the element to the parent./*from www .java2 s . c o m*/ * * @param name * The name of the element. * @param value * The boolean value for the element. * @param parent * The parent element for this child element. */ protected void addBooleanElement(String name, Boolean value, Element parent) { if (value == null) { return; } Element element = new Element(name, caom2Namespace); element.setText(value ? "true" : "false"); parent.addContent(element); }
From source file:ca.nrc.cadc.caom2.xml.ObservationWriter.java
License:Open Source License
/** * Builds a JDOM representation Element with the given name and sets the * text to the given value, then adds the element to the parent. * // www . j a v a 2 s .c o m * @param name * The name of the element. * @param uri * The URI value for the element. * @param parent * The parent element for this child element. */ protected void addURIElement(String name, URI uri, Element parent) { if (uri == null) { return; } Element element = new Element(name, caom2Namespace); element.setText(uri.toString()); parent.addContent(element); }
From source file:ca.nrc.cadc.caom2.xml.ObservationWriter.java
License:Open Source License
/** * Builds a JDOM representation Element with the given name and adds space * delimited List values as the text, then adds the element to the parent. * /*from w w w .ja v a 2 s . co m*/ * @param name * The name of the element. * @param values * The List of Strings for the element. * @param parent * The parent element for this child element. */ protected void addStringListElement(String name, Collection<String> values, Element parent) { if (values == null || (values.isEmpty() && !writeEmptyCollections)) { return; } Element element = new Element(name, caom2Namespace); StringBuilder sb = new StringBuilder(); for (String value : values) { sb.append(value).append(" "); } element.setText(sb.toString().trim()); parent.addContent(element); }
From source file:ca.nrc.cadc.caom2.xml.ObservationWriter.java
License:Open Source License
protected void addKeywordsElement(Collection<String> values, Element parent) { if (values == null || (values.isEmpty() && !writeEmptyCollections)) { return;/*from w w w. j a v a2 s . c o m*/ } Element element = new Element("keywords", caom2Namespace); StringBuilder sb = new StringBuilder(); for (String value : values) { Element kw = new Element("keyword", caom2Namespace); kw.addContent(value); element.addContent(kw); } parent.addContent(element); }
From source file:ca.nrc.cadc.caom2.xml.ObservationWriter.java
License:Open Source License
/** * Builds a JDOM representation Element with the given name and adds space * delimited List values as the text, then adds the element to the parent. * //from w w w . j a v a 2s. c o m * @param name * The name of the element. * @param values * The List of CoordRange1D for the element. * @param parent * The parent element for this child element. */ protected void addCoordRange1DListElement(String name, List<CoordRange1D> values, Element parent) { if (values == null) { return; } Element element = new Element(name, caom2Namespace); for (CoordRange1D range : values) { addCoordRange1DElement("range", range, element); } parent.addContent(element); }
From source file:ca.nrc.cadc.caom2.xml.ObservationWriter.java
License:Open Source License
/** * Builds a JDOM representation of the Date in IVOA format and adds it to * the Observation element.//from ww w . j a v a 2 s. c o m * * @param name * The name of the element. * @param date * The Date for the element. * @param parent * The parent element for this child element. * @param dateFormat * IVOA DateFormat. */ protected void addDateElement(String name, Date date, Element parent, DateFormat dateFormat) { if (date == null) { return; } Element element = new Element(name, caom2Namespace); element.setText(dateFormat.format(date)); parent.addContent(element); }