/** * getChildElements purpose. * * <p>Used to help with XML manipulations. Returns *all* child elements of the specified name. * * @param root The root element to look for children in. * @param name The name of the child element to look for. * @return The child element found, null if not found. * @see #getChildElement(Element,String,boolean) */ public static Element[] getChildElements(Element root, String name) { try { return getChildElements(root, name, false); } catch (Exception e) { // will never be here. return null; } }
Element service(Element servicesElement, String id) throws Exception { Element[] serviceElements = ReaderUtils.getChildElements(servicesElement, "service"); for (int i = 0; i < serviceElements.length; i++) { String serviceId = ReaderUtils.getAttribute(serviceElements[i], "type", false); if (id.equals(serviceId)) { return serviceElements[i]; } } throw new Exception("No service element: " + id); }
public List<String> styles() throws Exception { Element styleRoot = ReaderUtils.getChildElement(coverage, "styles"); if (styleRoot != null) { List<String> styleNames = new ArrayList<String>(); Element[] styles = ReaderUtils.getChildElements(styleRoot, "style"); for (Element style : styles) { styleNames.add(style.getTextContent().trim()); } return styleNames; } else { return Collections.emptyList(); } }
public List<String> styles() throws Exception { Element styleRoot = ReaderUtils.getChildElement(featureType, "styles"); if (styleRoot != null) { List<String> styleNames = new ArrayList<String>(); Element[] styles = ReaderUtils.getChildElements(styleRoot, "style"); for (Element style : styles) { styleNames.add(style.getTextContent().trim()); } return styleNames; } else { return Collections.emptyList(); } }
public Map<String, Serializable> parameters() { Element parameters = ReaderUtils.getChildElement(coverage, "parameters"); if (parameters == null) { return Collections.EMPTY_MAP; } HashMap<String, Serializable> map = new HashMap<String, Serializable>(); Element[] parameter = ReaderUtils.getChildElements(parameters, "parameter"); for (int i = 0; i < parameter.length; i++) { String name = parameter[i].getAttribute("name"); String value = parameter[i].getAttribute("value"); map.put(name, value); } return map; }
public List<Map<String, String>> metadataLinks() { ArrayList links = new ArrayList(); Element metadataLinks = ReaderUtils.getChildElement(featureType, "metadataLinks"); if (metadataLinks != null) { Element[] metadataLink = ReaderUtils.getChildElements(metadataLinks, "metadataLink"); for (Element e : metadataLink) { HashMap m = new HashMap(); m.put("metadataType", e.getAttribute("metadataType")); m.put("type", e.getAttribute("type")); if (e.getFirstChild() != null) { m.put(null, e.getFirstChild().getNodeValue()); } links.add(m); } } return links; }
public Map<String, Object> envelope() throws Exception { Element envelopeElement = ReaderUtils.getChildElement(coverage, "envelope"); HashMap<String, Object> e = new HashMap<String, Object>(); String nativeCrsWkt = ReaderUtils.getAttribute(envelopeElement, "crs", false); nativeCrsWkt = nativeCrsWkt.replaceAll("'", "\""); e.put("crs", nativeCrsWkt); e.put("srsName", ReaderUtils.getAttribute(envelopeElement, "srsName", false)); Element[] posElements = ReaderUtils.getChildElements(envelopeElement, "pos"); String[] pos1 = posElements[0].getFirstChild().getTextContent().split(" "); String[] pos2 = posElements[1].getFirstChild().getTextContent().split(" "); e.put("x1", Double.parseDouble(pos1[0])); e.put("y1", Double.parseDouble(pos1[1])); e.put("x2", Double.parseDouble(pos2[0])); e.put("y2", Double.parseDouble(pos2[1])); return e; }
public List<Map> coverageDimensions() throws Exception { Element[] cdElements = ReaderUtils.getChildElements(coverage, "CoverageDimension"); List<Map> cds = new ArrayList<Map>(); for (int i = 0; i < cdElements.length; i++) { HashMap cd = new HashMap(); cd.put("name", ReaderUtils.getChildText(cdElements[i], "name")); cd.put("description", ReaderUtils.getChildText(cdElements[i], "description")); Element intervalElement = ReaderUtils.getChildElement(cdElements[i], "interval"); double min = Double.parseDouble(ReaderUtils.getChildText(intervalElement, "min")); double max = Double.parseDouble(ReaderUtils.getChildText(intervalElement, "max")); cd.put("min", min); cd.put("max", max); cds.add(cd); } return cds; }
Element[] axisNameElements = ReaderUtils.getChildElements(gridElement, "axisName"); String[] axisName = new String[axisNameElements.length]; for (int i = 0; i < axisName.length; i++) {
if (baseMapGroupsElement != null) { Element[] baseMapGroupElements = ReaderUtils.getChildElements(baseMapGroupsElement, "BaseMapGroup"); for (int i = 0; i < baseMapGroupElements.length; i++) { Element baseMapGroupElement = baseMapGroupElements[i]; if (baseMapEnvelopeElement != null) { Element[] posElements = ReaderUtils.getChildElements(baseMapEnvelopeElement, "pos"); double x1 = Double.parseDouble(
Element[] keywordElements = ReaderUtils.getChildElements(keywordsElement, "keyword"); ArrayList keywords = new ArrayList(); if (keywordElements != null) {