本文整理了Java中org.dom4j.Node.valueOf()
方法的一些代码示例,展示了Node.valueOf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.valueOf()
方法的具体详情如下:
包路径:org.dom4j.Node
类名称:Node
方法名:valueOf
[英]valueOf
evaluates an XPath expression and returns the textual representation of the results the XPath string-value of this node. The string-value for a given node type is defined in the XPath specification.
[中]valueOf
对XPath表达式求值,并将结果的文本表示形式返回到此节点的XPath字符串值。给定节点类型的字符串值在XPath specification中定义。
代码示例来源:origin: spotbugs/spotbugs
Node node = constraintElement.selectSingleNode("./" + singleDetectorElementName);
if (node != null) {
String detectorClass = node.valueOf("@class");
return new SingleDetectorFactorySelector(plugin, detectorClass);
boolean spanPlugins = Boolean.valueOf(node.valueOf("@spanplugins")).booleanValue();
String categoryName = node.valueOf("@name");
if (!"".equals(categoryName)) {
if ("reporting".equals(categoryName)) {
boolean spanPlugins = Boolean.valueOf(node.valueOf("@spanplugins")).booleanValue();
String superName = node.valueOf("@super");
if (!"".equals(superName)) {
try {
代码示例来源:origin: spring-projects/spring-framework
@Test
public void withoutItemsEnumBindTarget() throws Exception {
BeanWithEnum testBean = new BeanWithEnum();
testBean.setTestEnum(TestEnum.VALUE_2);
getPageContext().getRequest().setAttribute("testBean", testBean);
this.tag.setPath("testEnum");
int result = this.tag.doStartTag();
assertEquals(Tag.SKIP_BODY, result);
String output = "<div>" + getOutput() + "</div>";
SAXReader reader = new SAXReader();
Document document = reader.read(new StringReader(output));
Element rootElement = document.getRootElement();
assertEquals(2, rootElement.elements().size());
Node value1 = rootElement.selectSingleNode("//input[@value = 'VALUE_1']");
Node value2 = rootElement.selectSingleNode("//input[@value = 'VALUE_2']");
assertEquals("TestEnum: VALUE_1",
rootElement.selectSingleNode("//label[@for = '" + value1.valueOf("@id") + "']").getText());
assertEquals("TestEnum: VALUE_2",
rootElement.selectSingleNode("//label[@for = '" + value2.valueOf("@id") + "']").getText());
assertEquals(value2, rootElement.selectSingleNode("//input[@checked]"));
}
代码示例来源:origin: spotbugs/spotbugs
List<Node> componentNodeList = XMLUtil.selectNodes(pluginDescriptor, "/FindbugsPlugin/PluginComponent");
for (Node componentNode : componentNodeList) {
@DottedClassName String componentKindname = componentNode.valueOf("@componentKind");
if (componentKindname == null) {
throw new PluginException("Missing @componentKind for " + plugin.getPluginId()
+ " loaded from " + loadedFrom);
@DottedClassName String componentClassname = componentNode.valueOf("@componentClass");
if (componentClassname == null) {
throw new PluginException("Missing @componentClassname for " + plugin.getPluginId()
+ " loaded from " + loadedFrom);
String componentId = componentNode.valueOf("@id");
if (componentId == null) {
throw new PluginException("Missing @id for " + plugin.getPluginId()
String propertiesLocation = componentNode.valueOf("@properties");
boolean disabled = Boolean.valueOf(componentNode.valueOf("@disabled"));
String key = node.valueOf("@key");
String value = node.getText();
properties.setProperty(key, value);
List<Node> findBugsMainList = XMLUtil.selectNodes(pluginDescriptor, "/FindbugsPlugin/FindBugsMain");
for (Node main : findBugsMainList) {
String className = main.valueOf("@class");
if (className == null) {
throw new PluginException("Missing @class for FindBugsMain in plugin" + plugin.getPluginId()
+ " loaded from " + loadedFrom);
代码示例来源:origin: spring-projects/spring-framework
@Test
public void withoutItemsEnumBindTargetWithExplicitLabelsAndValues() throws Exception {
BeanWithEnum testBean = new BeanWithEnum();
testBean.setTestEnum(TestEnum.VALUE_2);
getPageContext().getRequest().setAttribute("testBean", testBean);
this.tag.setPath("testEnum");
this.tag.setItemLabel("enumLabel");
this.tag.setItemValue("enumValue");
int result = this.tag.doStartTag();
assertEquals(Tag.SKIP_BODY, result);
String output = "<div>" + getOutput() + "</div>";
SAXReader reader = new SAXReader();
Document document = reader.read(new StringReader(output));
Element rootElement = document.getRootElement();
assertEquals(2, rootElement.elements().size());
Node value1 = rootElement.selectSingleNode("//input[@value = 'Value: VALUE_1']");
Node value2 = rootElement.selectSingleNode("//input[@value = 'Value: VALUE_2']");
assertEquals("Label: VALUE_1",
rootElement.selectSingleNode("//label[@for = '" + value1.valueOf("@id") + "']").getText());
assertEquals("Label: VALUE_2",
rootElement.selectSingleNode("//label[@for = '" + value2.valueOf("@id") + "']").getText());
assertEquals(value2, rootElement.selectSingleNode("//input[@checked]"));
}
代码示例来源:origin: spotbugs/spotbugs
String key = optionNode.valueOf("@key");
String value = optionNode.getText().trim();
constructedPlugin.setMyGlobalOption(key, value);
代码示例来源:origin: pentaho/pentaho-kettle
nodevalue = node.valueOf( XPathValue );
} else {
代码示例来源:origin: stackoverflow.com
for (Node n : fooNodes) {
String a = n.valueOf("@a");
String b = n.valueOf("@b");
String c = n.valueOf("@c");
fooNodes.add(new Foo(a, b, c));
}
代码示例来源:origin: org.appdapter/org.appdapter.lib.core
public static Integer getOptionalIntegerValueAtXPath(Node dom4JDoc, String xpath) throws Throwable {
Integer result = null;
String val = dom4JDoc.valueOf(xpath);
if ((val != null) && (val.length() > 0)) {
result = Integer.parseInt(val);
}
return result;
}
代码示例来源:origin: com.atlassian.jira.plugins/jira-fisheye-plugin
public List<Review> parse(List<Node> reviewNodes, String baseUrl, List<String> p4JobIds) {
final List<Review> reviews = new ArrayList<Review>();
for (final Node n : reviewNodes) {
final String id = n.valueOf("permaId/id");
final String title = n.valueOf("name");
final String description = n.valueOf("description");
final String state = n.valueOf("state");
final String linkedIssue = n.valueOf("jiraIssueKey");
final int metaState = MetaStateResolver.resolve(state);
final ReviewImpl review = new ReviewImpl(id, title, description, state, metaState, baseUrl, p4JobIds, linkedIssue);
if (passesFilter(review)) {
reviews.add(review);
}
}
return reviews;
}
代码示例来源:origin: com.atlassian.jira.plugins/jira-fisheye-plugin
public List<CrucibleProject> parse(FishEyeDocumentHolder docHolder) throws IOException {
Document doc = docHolder.getDoc();
List<CrucibleProject> projects = new ArrayList<CrucibleProject>();
List<Node> rows = doc.selectNodes("/projects/projectData");
for (Node row : rows) {
String key = row.valueOf("key");
String name = row.valueOf("name");
String defaultRepositoryName = row.valueOf("defaultRepositoryName");
int id = Integer.parseInt(row.valueOf("id"));
int permissionSchemeId = Integer.parseInt(row.valueOf("permissionSchemeId"));
boolean allowReviewersToJoin = Boolean.valueOf(row.valueOf("allowReviewersToJoin"));
projects.add(new CrucibleProjectImpl(id, key, name, defaultRepositoryName,
permissionSchemeId, allowReviewersToJoin));
}
return projects;
}
代码示例来源:origin: com.bladejava/blade-kit
public String attrValue(String strXPath) {
Node n = document.selectSingleNode(strXPath);
if (n != null) {
return (n.valueOf("@value"));
} else {
return null;
}
}
代码示例来源:origin: stackoverflow.com
String xmlFileName = "D:/validation/validator/src/summa/sample.xml";
String xPath = "//Root/Address";
Document document = getDocument( xmlFileName );
List<Node> nodes = document.selectNodes( xPath );
for (Node node : nodes)
{
String studentId = node.valueOf( "@studentId" );
stringArray.add( studentId );
}
代码示例来源:origin: com.atlassian.jira.plugins/jira-fisheye-plugin
public List parse(FishEyeDocumentHolder docHolder) throws IOException {
Document doc = docHolder.getDoc();
List projects = new ArrayList();
List rows = doc.selectNodes("/projects/projectData");
for (Iterator rowIterator = rows.iterator(); rowIterator.hasNext();) {
Node row = (Node) rowIterator.next();
String key = row.valueOf("key");
String name = row.valueOf("name");
String defaultRepositoryName = row.valueOf("defaultRepositoryName");
int id = Integer.parseInt(row.valueOf("id"));
int permissionSchemeId = Integer.parseInt(row.valueOf("permissionSchemeId"));
boolean allowReviewersToJoin = Boolean.valueOf(row.valueOf("allowReviewersToJoin")).booleanValue();
projects.add(new CrucibleProjectImpl(new Integer(id), key, name, defaultRepositoryName,
new Integer(permissionSchemeId), allowReviewersToJoin));
}
return projects;
}
代码示例来源:origin: junicorn/conf
public String attrValue(String strXPath) {
Node n = document.selectSingleNode(strXPath);
if (n != null) {
return (n.valueOf("@value"));
} else {
return null;
}
}
代码示例来源:origin: com.github.becauseQA/becauseQA-utils
public static String getNodeAttributeValue(String xpath, String attributeName) {
Node xPathNode = getXPathNode(xpath);
return xPathNode.valueOf("@" + attributeName);
}
代码示例来源:origin: net.sf.tacos/tacos-core
/**
* Get category listing.
* @return The category list
*/
public synchronized List getCategories() {
if (document == null) throw new IllegalStateException("No document set, call setResource and initialize.");
if (cachedCategoryList == null) {
List nodes = document.selectNodes("/sitemap/category[@name]");
cachedCategoryList = new ArrayList(nodes.size());
for(int i = 0, size = nodes.size(); i < size; i++) {
String category = ((Node)nodes.get(i)).valueOf("@name");
cachedCategoryList.add(category);
}
}
return cachedCategoryList;
}
代码示例来源:origin: com.atlassian.refapp/platform-ctk-plugin
/**
* Get the platform version.
*
* @return the platform version.
*/
public static String getPlatformVersion() throws RuntimeException {
Document document = readPlatformVersionDocument();
String xPath = "/platform";
List<Node> nodes = document.selectNodes(xPath);
return nodes.get(0).valueOf("@version");
}
代码示例来源:origin: com.github.becausetesting/commons
public String getNodeAttributeValue(String xpath, String attribute) {
// or use the xpath to get the attribute value://foo/bar/author/@name
String attributeValue = null;
Element rootElement = document.getRootElement();
String namespace = rootElement.getNamespaceURI();
if (namespace != null) {
DefaultXPath defaultXPath = new DefaultXPath(xpath);
Map<String, String> namespaces = new TreeMap<String, String>();
namespaces.put("ns", namespace);
defaultXPath.setNamespaceURIs(namespaces);
attributeValue = defaultXPath.selectSingleNode(document).valueOf("@" + attribute);
} else {
attributeValue = rootElement.selectSingleNode(xpath).valueOf("@" + attribute);
}
return attributeValue;
}
代码示例来源:origin: com.atlassian.ext/atlassian-plugin-repository-confluence-plugin
protected SortedMap parseHitMapXml(String hitMapXml) throws Exception
{
SortedMap hitMap = new TreeMap();
Document dom4jXPath = DocumentHelper.parseText(hitMapXml);
List node = dom4jXPath.selectNodes("/response/increment");
Iterator iterator = node.iterator();
while (iterator.hasNext())
{
Node o = (Node) iterator.next();
Node dateNode = o.selectSingleNode("date");
XStream xStream = new XStream();
xStream.setClassLoader(getClass().getClassLoader());
Date date = (Date)xStream.fromXML(dateNode.asXML());
String hitsString = o.valueOf("hits");
hitMap.put(date, hitsString);
}
return hitMap;
}
代码示例来源:origin: dom4j/dom4j
protected void testValueOf(Element documentTest, Element context,
Element valueOf) throws Exception {
String xpath = valueOf.attributeValue("select");
String description = "valueOf: " + xpath;
String expected = valueOf.getText();
String result = testContext.valueOf(xpath);
log(description);
log("\texpected: " + expected + " result: " + result);
assertEquals(description, expected, result);
}
内容来源于网络,如有侵权,请联系作者删除!