List of usage examples for org.dom4j Node getText
String getText();
Returns the text of this node.
From source file:com.collabnet.ccf.core.AbstractReader.java
License:Open Source License
protected String getRepositoryMappingDirectionId(Document syncInfo) { Node node = syncInfo.selectSingleNode(REPOSITORY_MAPPING_DIRECTION_ID); if (node == null) return null; return node.getText(); }
From source file:com.collabnet.ccf.core.AbstractReader.java
License:Open Source License
protected String getRepositoryMappingId(Document syncInfo) { Node node = syncInfo.selectSingleNode(REPOSITORY_MAPPING_ID); if (node == null) return null; return node.getText(); }
From source file:com.collabnet.ccf.core.ga.GenericArtifactHelper.java
License:Open Source License
/** * Extracts the value of the supplied attribute * /*w w w .j a v a2 s . c om*/ * @param element * element with attribute in question * @param attributeName * name of the attribute in question * @return value of the attribute in question * @throws GenericArtifactParsingException * exception s thrown is attribute is missing */ private static String getAttributeValue(Element element, String attributeName) throws GenericArtifactParsingException { // TODO Cash constructed XPath objects? // XPath xpath = new DefaultXPath("@" + CCF_NAMESPACE_PREFIX + ":" + // attributeName); XPath xpath = new DefaultXPath("@" + attributeName); xpath.setNamespaceURIs(ccfNamespaceMap); Node attributeNode = xpath.selectSingleNode(element); if (attributeNode == null) throw new GenericArtifactParsingException( "Missing attribute: " + attributeName + " in element " + element.getName()); else return attributeNode.getText(); }
From source file:com.collabnet.ccf.core.ga.GenericArtifactHelper.java
License:Open Source License
/** * Extracts the value of the supplied attribute without throwing an * exception if missing// w w w .j a va 2s . c om * * @param element * element with attribute in question * @param attributeName * name of the attribute in question * @return value of the attribute in question, null if attribute is missing * */ private static String getAttributeValueWithoutException(Element element, String attributeName) { // TODO Cash constructed XPath objects? // XPath xpath = new DefaultXPath("@" + CCF_NAMESPACE_PREFIX + ":" + // attributeName); XPath xpath = new DefaultXPath("@" + attributeName); xpath.setNamespaceURIs(ccfNamespaceMap); Node attributeNode = xpath.selectSingleNode(element); if (attributeNode == null) return null; else return attributeNode.getText(); }
From source file:com.collabnet.ccf.core.utils.XPathUtils.java
License:Open Source License
/** * Extracts the value of the supplied attribute * /*from w w w . j a va2 s.c om*/ * @param element * element with attribute in question * @param attributeName * name of the attribute in question * @param failIfNotFound * determines if exception should be thrown if attribute is not * found * @return value of the attribute in question, null if not found and * failIfNotFound is set to false * @throws GenericArtifactParsingException * exception thrown is attribute is missing and failIfNotFound * is set to true */ public static String getAttributeValue(Element element, String attributeName, boolean failIfNotFound) throws GenericArtifactParsingException { XPath xpath = new DefaultXPath("@" + attributeName); xpath.setNamespaceURIs(ccfNamespaceMap); Node attributeNode = xpath.selectSingleNode(element); if (attributeNode == null) { if (failIfNotFound) { throw new GenericArtifactParsingException( "Missing attribute: " + attributeName + " in element " + element.getName()); } else { return null; } } else { return attributeNode.getText(); } }
From source file:com.controlj.addon.weather.noaa.ConditionsSourceFactory.java
License:Open Source License
private String extractString(Document document, String element) { Node node = document.selectSingleNode("/current_observation/" + element); return node == null ? null : node.getText(); }
From source file:com.controlj.addon.weather.noaa.ConditionsSourceFactory.java
License:Open Source License
private Float extractFloat(Document document, String element) { Node node = document.selectSingleNode("/current_observation/" + element); return node == null ? null : toFloat(node.getText()); }
From source file:com.controlj.addon.weather.noaa.ConditionsSourceFactory.java
License:Open Source License
private Date extractObservationTime(Document document) { Node node = document.selectSingleNode("/current_observation/observation_time_rfc822"); try {//from w w w .ja va 2 s. c om return rfc8222Format.parse(node.getText()); } catch (ParseException e) { return null; } }
From source file:com.controlj.addon.weather.noaa.ForecastSourceFactory.java
License:Open Source License
private List<Date> getForecastDates(Document forecast) { boolean problem = false; ArrayList<Date> result = new ArrayList<Date>(); Node node = forecast.selectSingleNode("/dwml/data/parameters/temperature[@type='maximum']/@time-layout"); if (node != null) { String timeLayout = node.getText(); if (timeLayout != null) { List list = forecast.selectNodes("/dwml/data/time-layout/layout-key[text()='" + timeLayout + "']//following-sibling::start-valid-time"); for (Object o : list) { try { result.add(timeLayoutFormat.parse(((Node) o).getText())); } catch (ParseException e) { result.add(null);/*from w w w . j a va 2 s . c o m*/ Logging.println("Couldn't parse date in the forecast", e); problem = true; } } if (result.size() == 0) { Logging.println("Didn't find any days in forecast"); problem = true; } } } else { Logging.println("Can't find max temperature in forecast"); problem = true; } if (problem) { Logging.logDocument("forecast", "Problem parsing forecast dates", forecast); } return result; }
From source file:com.controlj.addon.weather.noaa.StationSourceFactory.java
License:Open Source License
private String getLatLong() throws InvalidConfigurationDataException { Node node = latLongDoc.selectSingleNode("/dwml/latLonList"); if (node == null) { throw new InvalidConfigurationDataException("Can't find latitude/longitude from zip code"); }/* w w w . j a v a 2s .c o m*/ return node.getText(); }