public String dataStore() throws Exception { return ReaderUtils.getAttribute(featureType, "datastore", true); }
public boolean searchable() { Element searchable = ReaderUtils.getChildElement(featureType, "searchable"); if (searchable != null) { try { return "true".equals(ReaderUtils.getAttribute(searchable, "enabled", false)); } catch (Exception e) { } } return false; }
public String cacheAgeMax() { Element cacheInfo = ReaderUtils.getChildElement(featureType, "cacheinfo"); if (cacheInfo != null) { try { return ReaderUtils.getAttribute(cacheInfo, "maxage", false); } catch (Exception e) { } } return null; }
/** * getBooleanAttribute purpose. * * <p>Used to help with XML manipulations. Returns the first child integer attribute of the * specified name. An exception occurs when the node is required and not found. * * @param elem The root element to look for children in. * @param attName The name of the attribute to look for. * @param mandatory true when an exception should be thrown if the attribute element does not * exist. * @param defaultValue what to return for a non-mandatory that is not found. * @return The value if the attribute was found, the false otherwise. * @throws Exception When a child attribute is required and not found. */ public static boolean getBooleanAttribute( Element elem, String attName, boolean mandatory, boolean defaultValue) throws Exception { String value = getAttribute(elem, attName, mandatory); if ((value == null) || (value == "")) { return defaultValue; } return Boolean.valueOf(value).booleanValue(); }
public boolean cachingEnabled() { Element cacheInfo = ReaderUtils.getChildElement(featureType, "cacheinfo"); if (cacheInfo != null) { try { return "true".equals(ReaderUtils.getAttribute(cacheInfo, "enabled", false)); } catch (Exception e) { } } return false; }
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 String defaultStyle() throws Exception { Element styles = ReaderUtils.getChildElement(coverage, "styles"); return ReaderUtils.getAttribute(styles, "default", true); }
public String defaultInterpolation() throws Exception { Element supportedFormats = ReaderUtils.getChildElement(coverage, "supportedInterpolations"); return ReaderUtils.getAttribute(supportedFormats, "default", true); }
public String defaultStyle() throws Exception { Element styles = ReaderUtils.getChildElement(featureType, "styles"); return ReaderUtils.getAttribute(styles, "default", false); }
public String nativeFormat() throws Exception { Element supportedFormats = ReaderUtils.getChildElement(coverage, "supportedFormats"); return ReaderUtils.getAttribute(supportedFormats, "nativeFormat", true); }
/** * Convenience method for reading connection parameters from a datastore element. * * @param dataStoreElement The "datastore" element. * @return The map of connection paramters. * @throws Exception If problem parsing any parameters. */ protected Map dataStoreParams(Element dataStoreElement) throws Exception { Element paramsElement = ReaderUtils.getChildElement(dataStoreElement, "connectionParams", true); NodeList paramList = paramsElement.getElementsByTagName("parameter"); Map params = new HashMap(); for (int i = 0; i < paramList.getLength(); i++) { Element paramElement = (Element) paramList.item(i); String key = ReaderUtils.getAttribute(paramElement, "name", true); String value = ReaderUtils.getAttribute(paramElement, "value", false); params.put(key, value); } return params; }
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 Map<String, Object> legendURL() throws Exception { Element legendURL = ReaderUtils.getChildElement(featureType, "LegendURL"); if (legendURL != null) { HashMap map = new HashMap(); map.put("width", Integer.parseInt(ReaderUtils.getAttribute(legendURL, "width", true))); map.put( "height", Integer.parseInt(ReaderUtils.getAttribute(legendURL, "height", true))); map.put("format", ReaderUtils.getChildText(legendURL, "Format", true)); map.put( "onlineResource", ReaderUtils.getAttribute( ReaderUtils.getChildElement(legendURL, "OnlineResource", true), "xlink:href", true)); return map; } return null; }
String attValue = getAttribute(elem, attName, mandatory);
String value = getAttribute(elem, attName, mandatory);
<T> void value(String parameter, Element element, Map map, Class<T> clazz, boolean man, T def) throws Exception { Element valueElement = ReaderUtils.getChildElement(element, parameter); if (valueElement == null) { if (man) { throw new RuntimeException("No such element: " + parameter); } else { map.put(parameter, def); return; } } Object value = null; if (Boolean.class.equals(clazz)) { value = Boolean.valueOf( ReaderUtils.getBooleanAttribute(valueElement, "value", true, false)); } else if (Integer.class.equals(clazz)) { value = Integer.valueOf(ReaderUtils.getIntAttribute(valueElement, "value", true, -1)); } else if (Double.class.equals(clazz)) { value = new Double(ReaderUtils.getDoubleAttribute(valueElement, "value", true)); } else { value = ReaderUtils.getAttribute(valueElement, "value", true); } map.put(parameter, value); }
String id = ReaderUtils.getAttribute(dataStoreElement, "id", true); dataStore.put("id", id); dataStore.put( "namespace", ReaderUtils.getAttribute(dataStoreElement, "namespace", false)); dataStore.put( "enabled",
format.put("id", ReaderUtils.getAttribute(formatElement, "id", true)); format.put("namespace", ReaderUtils.getAttribute(formatElement, "namespace", false)); format.put( "enabled",
Integer.parseInt(ReaderUtils.getAttribute(gridElement, "dimension", true)));
if (mlElement != null) { HashMap metadataLink = new HashMap(); metadataLink.put("about", ReaderUtils.getAttribute(mlElement, "about", false)); metadataLink.put("type", ReaderUtils.getAttribute(mlElement, "type", false)); metadataLink.put( "metadataType", ReaderUtils.getAttribute(mlElement, "metadataType", false)); service.put("metadataLink", metadataLink);