Example usage for org.jdom2 Element getContentSize

List of usage examples for org.jdom2 Element getContentSize

Introduction

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

Prototype

@Override
    public int getContentSize() 

Source Link

Usage

From source file:ca.nrc.cadc.caom2.xml.ObservationReader.java

License:Open Source License

/**
 * Build an PolarizationWCS from a JDOM representation of an polarization
 * element.//from   w  ww . j a  va2s .co m
 * 
 * @param name
 *            the name of the Element.
 * @param parent
 *            the parent Element.
 * @param namespace
 *            of the document.
 * @param required
 * @param rc
 * @return an PolarizationWCS, or null if the document doesn't contain an
 *         polarization element.
 * @throws ObservationParsingException
 */
protected PolarizationWCS getPolarizationWCS(String name, Element parent, Namespace namespace, boolean required,
        ReadContext rc) throws ObservationParsingException {
    Element element = getChildElement(name, parent, namespace, false);
    if (element == null || element.getContentSize() == 0) {
        return null;
    }

    CoordAxis1D axis = getCoordAxis1D("axis", element, namespace, true);
    return new PolarizationWCS(axis);
}

From source file:ca.nrc.cadc.caom2.xml.ObservationReader.java

License:Open Source License

/**
 * Build an Axis from a JDOM representation of an axis element.
 * // ww w . j  a v  a 2s . c  o  m
 * @param name
 *            the name of the Element.
 * @param parent
 *            the parent Element.
 * @param namespace
 *            of the document.
 * @param required
 *            is the element expected to be found.
 * @return an Axis, or null if the document doesn't contain an axis element.
 * @throws ObservationParsingException
 */
protected Axis getAxis(String name, Element parent, Namespace namespace, boolean required)
        throws ObservationParsingException {
    Element element = getChildElement(name, parent, namespace, required);
    if (element == null || element.getContentSize() == 0) {
        return null;
    }

    String ctype = getChildText("ctype", element, namespace, true);
    String cunit = getChildText("cunit", element, namespace, false);
    return new Axis(ctype, cunit);
}

From source file:ca.nrc.cadc.caom2.xml.ObservationReader.java

License:Open Source License

/**
 * Build an Coord2D from a JDOM representation of an element named name.
 * /*  ww  w .ja  v  a2s .  c o m*/
 * @param name
 *            the name of the Element.
 * @param parent
 *            the parent Element.
 * @param namespace
 *            of the document.
 * @param required
 *            is the element expected to be found.
 * @return a Coord2D, or null if the document doesn't contain element named
 *         name.
 * @throws ObservationParsingException
 */
protected Coord2D getCoord2D(String name, Element parent, Namespace namespace, boolean required)
        throws ObservationParsingException {
    Element element = getChildElement(name, parent, namespace, required);
    if (element == null || element.getContentSize() == 0) {
        return null;
    }

    RefCoord coord1 = getRefCoord("coord1", element, namespace, true);
    RefCoord coord2 = getRefCoord("coord2", element, namespace, true);
    return new Coord2D(coord1, coord2);
}

From source file:ca.nrc.cadc.caom2.xml.ObservationReader.java

License:Open Source License

/**
 * Build an ValueCoord2D from a JDOM representation of an element named
 * name.//from   w  w w  .j a  v a2  s . co  m
 * 
 * @param name
 *            the name of the Element.
 * @param parent
 *            the parent Element.
 * @param namespace
 *            of the document.
 * @param required
 *            is the element expected to be found.
 * @return a ValueCoord2D, or null if the document doesn't contain element
 *         named name.
 * @throws ObservationParsingException
 */
protected ValueCoord2D getValueCoord2D(String name, Element parent, Namespace namespace, boolean required)
        throws ObservationParsingException {
    Element element = getChildElement(name, parent, namespace, required);
    if (element == null || element.getContentSize() == 0) {
        return null;
    }

    double coord1 = getChildTextAsDouble("coord1", element, namespace, true);
    double coord2 = getChildTextAsDouble("coord2", element, namespace, true);
    return new ValueCoord2D(coord1, coord2);
}

From source file:ca.nrc.cadc.caom2.xml.ObservationReader.java

License:Open Source License

/**
 * Build an CoordAxis1D from a JDOM representation of element name.
 * /*ww  w  . ja  va 2 s  . c o  m*/
 * @param name
 *            the name of the Element.
 * @param parent
 *            the parent Element.
 * @param namespace
 *            of the document.
 * @param required
 *            is the element expected to be found.
 * @return an CoordAxis1D, or null if the document doesn't contain element
 *         called name.
 * @throws ObservationParsingException
 */
protected CoordAxis1D getCoordAxis1D(String name, Element parent, Namespace namespace, boolean required)
        throws ObservationParsingException {
    Element element = getChildElement(name, parent, namespace, required);
    if (element == null || element.getContentSize() == 0) {
        return null;
    }

    Axis axis = getAxis("axis", element, namespace, true);
    CoordAxis1D coordAxis1D = new CoordAxis1D(axis);
    coordAxis1D.error = getCoordError("error", element, namespace, false);
    coordAxis1D.range = getCoordRange1D("range", element, namespace, false);
    coordAxis1D.bounds = getCoordBounds1D("bounds", element, namespace, false);
    coordAxis1D.function = getCoordFunction1D("function", element, namespace, false);
    return coordAxis1D;
}

From source file:ca.nrc.cadc.caom2.xml.ObservationReader.java

License:Open Source License

/**
 * Build an CoordAxis2D from a JDOM representation of element name.
 * /*from w w  w  .  j  ava 2 s . c  o  m*/
 * @param name
 *            the name of the Element.
 * @param parent
 *            the parent Element.
 * @param namespace
 *            of the document.
 * @param required
 *            is the element expected to be found.
 * @return an CoordAxis2D, or null if the document doesn't contain element
 *         called name.
 * @throws ObservationParsingException
 */
protected CoordAxis2D getCoordAxis2D(String name, Element parent, Namespace namespace, boolean required)
        throws ObservationParsingException {
    Element element = getChildElement(name, parent, namespace, required);
    if (element == null || element.getContentSize() == 0) {
        return null;
    }

    Axis axis1 = getAxis("axis1", element, namespace, true);
    Axis axis2 = getAxis("axis2", element, namespace, true);

    CoordAxis2D axis = new CoordAxis2D(axis1, axis2);
    axis.error1 = getCoordError("error1", element, namespace, false);
    axis.error2 = getCoordError("error2", element, namespace, false);
    axis.range = getCoordRange2D("range", element, namespace, false);
    axis.bounds = getCoordBounds2D("bounds", element, namespace, false);
    axis.function = getCoordFunction2D("function", element, namespace, false);
    return axis;
}

From source file:ca.nrc.cadc.caom2.xml.ObservationReader.java

License:Open Source License

/**
 * Build an CoordBounds1D from a JDOM representation of an element named
 * name./*w  ww  . j  a v  a2s. co m*/
 * 
 * @param name
 *            the name of the Element.
 * @param parent
 *            the parent Element.
 * @param namespace
 *            of the document.
 * @param required
 *            is the element expected to be found.
 * @return an CoordBounds1D, or null if the document doesn't contain element
 *         named name.
 * @throws ObservationParsingException
 */
protected CoordBounds1D getCoordBounds1D(String name, Element parent, Namespace namespace, boolean required)
        throws ObservationParsingException {
    Element element = getChildElement(name, parent, namespace, required);
    if (element == null || element.getContentSize() == 0) {
        return null;
    }

    CoordBounds1D coordBounds1D = new CoordBounds1D();
    Element samples = getChildElement("samples", element, namespace, false);
    if (samples != null) {
        addChildrenToCoordRange1DList("range", coordBounds1D.getSamples(), samples, namespace, false);
    }
    return coordBounds1D;
}

From source file:ca.nrc.cadc.caom2.xml.ObservationReader.java

License:Open Source License

/**
 * Build an CoordBounds2D from a JDOM representation of an element named
 * name./*from ww  w  .ja v  a 2s  . com*/
 * 
 * @param name
 *            the name of the Element.
 * @param parent
 *            the parent Element.
 * @param namespace
 *            of the document.
 * @param required
 *            is the element expected to be found.
 * @return an CoordBounds2D, or null if the document doesn't contain element
 *         named name.
 * @throws ObservationParsingException
 */
protected CoordBounds2D getCoordBounds2D(String name, Element parent, Namespace namespace, boolean required)
        throws ObservationParsingException {
    Element element = getChildElement(name, parent, namespace, required);
    if (element == null || element.getContentSize() == 0) {
        return null;
    }

    // Look for a CoordCircle2D which has a center and a radius.
    CoordCircle2D circle = getCoordCircle2D("circle", element, namespace, false);
    if (circle != null) {
        return circle;
    }

    // Look for a CoordPolygon2D which has a list of Coord2D vertices.
    CoordPolygon2D polygon = getCoordPolygon2D("polygon", element, namespace, false);
    if (polygon != null) {
        return polygon;
    }

    // Unknown children.
    String error = "Unsupported element found in " + name + ": " + element.getText();
    throw new ObservationParsingException(error);
}

From source file:ca.nrc.cadc.caom2.xml.ObservationReader.java

License:Open Source License

/**
 * Build an CoordError from a JDOM representation of element name.
 * /* w ww  .  j  a  v a2  s.  com*/
 * @param name
 *            the name of the Element.
 * @param parent
 *            the parent Element.
 * @param namespace
 *            of the document.
 * @param required
 *            is the element expected to be found.
 * @return an CoordError, or null if the document doesn't contain element
 *         called name.
 * @throws ObservationParsingException
 */
protected CoordError getCoordError(String name, Element parent, Namespace namespace, boolean required)
        throws ObservationParsingException {
    Element element = getChildElement(name, parent, namespace, required);
    if (element == null || element.getContentSize() == 0) {
        return null;
    }

    Double syser = getChildTextAsDouble("syser", element, namespace, true);
    Double rnder = getChildTextAsDouble("rnder", element, namespace, true);
    return new CoordError(syser, rnder);
}

From source file:ca.nrc.cadc.caom2.xml.ObservationReader.java

License:Open Source License

/**
 * Build an CoordFunction1D from a JDOM representation of an element named
 * name.//  w  ww  . j  av a2  s . c o m
 * 
 * @param name
 *            the name of the Element.
 * @param parent
 *            the parent Element.
 * @param namespace
 *            of the document.
 * @param required
 *            is the element expected to be found.
 * @return an CoordFunction1D, or null if the document doesn't contain
 *         element named name.
 * @throws ObservationParsingException
 */
protected CoordFunction1D getCoordFunction1D(String name, Element parent, Namespace namespace, boolean required)
        throws ObservationParsingException {
    Element element = getChildElement(name, parent, namespace, false);
    if (element == null || element.getContentSize() == 0) {
        return null;
    }

    Long naxis = getChildTextAsLong("naxis", element, namespace, true);
    Double delta = getChildTextAsDouble("delta", element, namespace, true);
    RefCoord refCoord = getRefCoord("refCoord", element, namespace, true);
    return new CoordFunction1D(naxis, delta, refCoord);
}