List of usage examples for org.dom4j Node valueOf
String valueOf(String xpathExpression);
valueOf
evaluates an XPath expression and returns the textual representation of the results the XPath string-value of this node.
From source file:org.jdbcluster.filter.ClusterSelectImpl.java
License:Apache License
/** * @param clusterType identifies the ClusterType * @param SelectID selects the SelectID/*from w w w .j a va2 s . co m*/ * @return all fetched attributes or an empty String */ @SuppressWarnings("unchecked") public String getFetch(ClusterType clusterType, String SelectID) { String clusterId = clusterType.getName(); String xPath = "//jdbcluster/clustertype/cluster[@id='" + clusterId + "']" + "/select[@id='" + SelectID + "']" + "/fetch"; List<Node> nodes = document.selectNodes(xPath); // List content instanceof Node! String alias = getAlias(clusterType, SelectID); if (alias == null || alias.length() == 0) { alias = ""; } else { alias = alias + "."; } StringBuilder builder = new StringBuilder(); for (Node node : nodes) { builder.append(' ').append(node.valueOf("@joinType")).append(" join fetch ").append(alias) .append(node.valueOf("@property")); } return builder.toString(); }
From source file:org.jdbcluster.filter.ClusterSelectImpl.java
License:Apache License
/** * gets static part of a hql query read from a String attribute * @param clusterType identifies the ClusterType * @param SelectID the SelectID//from w w w.j ava 2s . c o m * @param className specifies the classname * @return String */ public String getStaticStatementAttribute(ClusterType clusterType, String SelectID, String className) { String clusterId = clusterType.getName(); String xPath = "//jdbcluster/clustertype/cluster[@id='" + clusterId + "']" + "/select[@id='" + SelectID + "']" + "/FilterClass[@class='" + className + "']" + "/static"; Node node = document.selectSingleNode(xPath); if (node == null) return null; return node.valueOf("@statementAttribute"); }
From source file:org.jdbcluster.privilege.PrivilegeConfigImpl.java
License:Apache License
public String getUserPrivilegeCheckerPath() { String xPath = "//jdbcluster/privileges/UserPrivilegeChecker"; Node node = document.selectSingleNode(xPath); if (node == null) { return null; } else {// www . ja v a 2 s.c o m return node.valueOf("@class"); } }
From source file:org.kuali.kra.budget.nonpersonnel.BudgetJustificationWrapper.java
License:Educational Community License
/** * This method parses the raw budgetJustification String into the fields needed for this class * Expected format:/*from w w w . j ava2 s.c o m*/ * <budgetJustification lastUpdateBy="" lastUpdateOn=""> * <![CDATA[ * Justification text * ]]> * </justification> */ private void parse(String budgetJustificationAsXML) { if (budgetJustificationAsXML == null || budgetJustificationAsXML.trim().length() == 0) { return; } try { Document document = DocumentHelper.parseText(budgetJustificationAsXML); Node node = document.selectSingleNode("//budgetJustification"); lastUpdateUser = node.valueOf("@lastUpdateBy"); lastUpdateTime = node.valueOf("@lastUpdateOn"); justificationText = node.getText(); } catch (DocumentException e) { LOG.warn(e.getMessage(), e); } }
From source file:org.light.portal.core.action.PortalConfigAction.java
License:Apache License
public Object uploadAllOpml(HttpServletRequest request, HttpServletResponse response) throws Exception { boolean upload = true; try {/*from w ww .j a va 2 s .c o m*/ StringBuffer buffer = new StringBuffer(); ServletInputStream in = request.getInputStream(); int i; boolean added = false; while ((i = in.read()) != -1) { buffer.append((char) i); } String text = buffer.toString(); int index = text.indexOf("<?xml"); int endIndex = text.indexOf("</opml>"); if (endIndex <= 0) return false; String result = text.substring(index, endIndex + 7); Document document = DocumentHelper.parseText(result); List list1 = document.selectNodes("//opml/body/outline"); for (Iterator iter = list1.iterator(); iter.hasNext();) { Node node = (Node) iter.next(); String title = node.valueOf("@title"); String feed = node.valueOf("@xmlUrl"); String name = node.valueOf("@name"); String userId = node.valueOf("@userId"); String tag = node.valueOf("@tag"); String subTag = node.valueOf("@subTag"); String language = node.valueOf("@language"); if (feed != null && feed.trim().length() > 0) addFeedFromOpml(request, title, feed, name, userId, tag, subTag, language); } List list = document.selectNodes("//opml/body/outline/outline"); for (Iterator iter = list.iterator(); iter.hasNext();) { Node node = (Node) iter.next(); String title = node.valueOf("@title"); String feed = node.valueOf("@xmlUrl"); String name = node.valueOf("@name"); String userId = node.valueOf("@userId"); String tag = node.valueOf("@tag"); String subTag = node.valueOf("@subTag"); String language = node.valueOf("@language"); if (feed != null && feed.trim().length() > 0) addFeedFromOpml(request, title, feed, name, userId, tag, subTag, language); } } catch (Exception e) { e.printStackTrace(); upload = false; } return upload; }
From source file:org.light.portal.core.action.PortalConfigAction.java
License:Apache License
public Object uploadOpml(HttpServletRequest request, HttpServletResponse response) throws Exception { boolean upload = true; try {//from w w w.j a va 2 s . com StringBuffer buffer = new StringBuffer(); ServletInputStream in = request.getInputStream(); int i; boolean added = false; while ((i = in.read()) != -1) { buffer.append((char) i); } String text = buffer.toString(); int index = text.indexOf("<?xml"); int endIndex = text.indexOf("</opml>"); if (endIndex <= 0) return false; String result = text.substring(index, endIndex + 7); Document document = DocumentHelper.parseText(result); List list1 = document.selectNodes("//opml/body/outline"); for (Iterator iter = list1.iterator(); iter.hasNext();) { Node node = (Node) iter.next(); String title = node.valueOf("@title"); String feed = node.valueOf("@xmlUrl"); if (feed != null && feed.trim().length() > 0) addMyFeedFromOpml(request, title, feed); } List list = document.selectNodes("//opml/body/outline/outline"); for (Iterator iter = list.iterator(); iter.hasNext();) { Node node = (Node) iter.next(); String title = node.valueOf("@title"); String feed = node.valueOf("@xmlUrl"); if (feed != null && feed.trim().length() > 0) addMyFeedFromOpml(request, title, feed); } } catch (Exception e) { e.printStackTrace(); upload = false; } return upload; }
From source file:org.light.portlets.weather.WeatherLocations.java
License:Apache License
public void setDocument(Document document) { this.lastRefreshTime = System.currentTimeMillis(); this.document = document; List list = document.selectNodes("//search/loc"); if (list != null) { if (list.size() > 0) { for (Iterator iter = list.iterator(); iter.hasNext();) { Node node = (Node) iter.next(); String name = node.getText(); String id = node.valueOf("@id"); this.locations.add(new WeatherLocation(id, name)); }//from w ww . ja v a 2 s . com } else { this.errorFound = true; this.error = "The location which you just input is not avaliable in The Weather Channel, please check the locaiton."; } } else { this.errorFound = true; Node node1 = document.selectSingleNode("//error/err"); this.error = node1.getText(); } }
From source file:org.nuxeo.ecm.platform.sync.manager.VocabularySynchronizeManager.java
License:Open Source License
@SuppressWarnings("rawtypes") protected List<Map<String, Object>> extractVocabulary(String directorySchema, String res) throws DocumentException { ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); Document domDoc = DocumentHelper.parseText(res); List nodes = domDoc.selectNodes("//entries/entry"); SchemaManager schemaManager = Framework.getLocalService(SchemaManager.class); Schema vocSchema = schemaManager.getSchema(directorySchema); Collection<Field> vocSchemaField = vocSchema.getFields(); for (Object object : nodes) { Node nodeEntry = ((Node) object); Map<String, Object> entryMap = new HashMap<String, Object>(); for (Field field : vocSchemaField) { String fieldName = field.getName().getLocalName(); Type type = field.getType(); String entryValue = nodeEntry.valueOf("@" + fieldName); if (!entryValue.trim().isEmpty()) { if (type instanceof StringType) { entryMap.put(fieldName, entryValue); } else if (type instanceof LongType) { Long longEntry = Long.valueOf(entryValue); entryMap.put(fieldName, longEntry); } else if (type instanceof IntegerType) { Integer integerEntry = Integer.valueOf(entryValue); entryMap.put(fieldName, integerEntry); } else { log.warn("Vocabulary sychronizer only serialize int, long or string fields type. " + fieldName + "(" + type.getName() + ") has been ignored"); }// w w w. j a v a 2 s . com } } list.add(entryMap); } return list; }
From source file:org.pengyou.client.web.MimeTypeIcons.java
License:Apache License
public static String getImgUrl(String fileName, String resType) { log.info(fileName);/* w w w . j a v a2 s . c o m*/ if (resType.equals("COLLECTION")) { return "./img/mimetypes/48x48/gnome-fs-directory.png"; } String fileType = getFileType(fileName); try { Node node = doc.selectSingleNode("//fileTypes/extension[@type='" + fileType + "']"); if (node == null) return "./img/mimetypes/48x48/gnome-mime-text-x-authors.png"; return "./img/mimetypes/48x48/" + node.valueOf("img"); } catch (Exception e) { log.error("can't select the right img", e); return "./img/mimetypes/48x48/gnome-mime-text-x-authors.png"; } }
From source file:org.pengyou.client.web.MimeTypeIcons.java
License:Apache License
public static String getImgUrlSmall(String fileName, String resType) { log.info(fileName);// w w w . ja va2 s . c om if (resType.equals("COLLECTION")) { return "./img/mimetypes/16x16/deb.png"; } String fileType = getFileType(fileName); try { Node node = doc.selectSingleNode("//fileTypes/extension[@type='" + fileType + "']"); if (node == null) return "./img/mimetypes/16x16/unknown.png"; return "./img/mimetypes/16x16/" + node.valueOf("img"); } catch (Exception e) { log.error("can't select the right img", e); return "./img/mimetypes/16x16/unknown.png"; } }