本文整理了Java中org.jdom2.Element.getValue()
方法的一些代码示例,展示了Element.getValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getValue()
方法的具体详情如下:
包路径:org.jdom2.Element
类名称:Element
方法名:getValue
[英]Returns the XPath 1.0 string value of this element, which is the complete, ordered content of all text node descendants of this element (i.e. the text that's left after all references are resolved and all other markup is stripped out.)
[中]返回此元素的XPath 1.0字符串值,它是此元素的所有文本节点子体的完整有序内容(即解析所有引用并除去所有其他标记后剩下的文本)
代码示例来源:origin: gocd/gocd
public HashMap<String, String> parseInfoToGetUUID(String output, String queryURL, SAXBuilder builder) {
HashMap<String, String> uidToUrlMap = new HashMap<>();
try {
Document document = builder.build(new StringReader(output));
Element root = document.getRootElement();
List<Element> entries = root.getChildren("entry");
for (Element entry : entries) {
uidToUrlMap.put(queryURL, entry.getChild("repository").getChild("uuid").getValue());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return uidToUrlMap;
}
代码示例来源:origin: gocd/gocd
public CommandSnippet parse(String xmlContent, String fileName, String relativeFilePath) {
try {
Document document = buildXmlDocument(xmlContent, CommandSnippet.class.getResource("command-snippet.xsd"));
CommandSnippetComment comment = getComment(document);
Element execTag = document.getRootElement();
String commandName = execTag.getAttributeValue("command");
List<String> arguments = new ArrayList<>();
for (Object child : execTag.getChildren()) {
Element element = (Element) child;
arguments.add(element.getValue());
}
return new CommandSnippet(commandName, arguments, comment, fileName, relativeFilePath);
} catch (Exception e) {
String errorMessage = String.format("Reason: %s", e.getMessage());
LOGGER.info("Could not load command '{}'. {}", fileName, errorMessage);
return CommandSnippet.invalid(fileName, errorMessage, new EmptySnippetComment());
}
}
代码示例来源:origin: gocd/gocd
List<Element> encryptedNode = xpathExpression.evaluate(document);
for (Element element : encryptedNode) {
element.setText(reEncryptUsingNewKey(decodeHex(oldCipher), decodeHex(newCipher), element.getValue()));
LOGGER.debug("Replaced encrypted value at {}", element.toString());
代码示例来源:origin: geotools/geotools
private static List<String> getXPathValues(String xpathString, JXPathContext context) {
List values = null;
try {
values = context.selectNodes(xpathString);
} catch (RuntimeException e) {
throw new RuntimeException("Error reading xpath " + xpathString, e);
}
List<String> ls = null;
if (values == null) {
ls = new ArrayList<String>();
} else {
ls = new ArrayList<String>(values.size());
for (int i = 0; i < values.size(); i++) {
Object value = values.get(i);
String unwrappedValue = "";
if (value instanceof org.jdom2.Attribute) {
unwrappedValue = ((org.jdom2.Attribute) value).getValue();
} else if (value instanceof org.jdom2.Element) {
unwrappedValue = ((org.jdom2.Element) value).getValue();
}
ls.add(unwrappedValue);
}
}
return ls;
}
}
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
/**
* @return the element value.
* @see org.jdom2.Element#getValue()
*/
public String getValue()
{
return element.getValue();
}
代码示例来源:origin: net.sf.cuf/cuf-swing
/**
* Parses the content of a minsize, maxsize or prefsize tag and converts it into an Dimension object.
* @param pElement The tag element.
* @return The specified size as a Dimension object.
*/
protected Dimension parseSizeTag(Element pElement)
{
String[] size = pElement.getValue().split(",");
return new Dimension(Integer.parseInt(size[0]), Integer.parseInt(size[1]));
}
代码示例来源:origin: TheHolyWaffle/League-of-Legends-XMPP-Chat-Library
private String get(XMLProperty p) {
final Element child = getElement(p);
if (child == null) {
return "";
}
return child.getValue();
}
代码示例来源:origin: ch.epfl.bbp.nlp/bluima_xml
private static String getVal(Element el, String nodeName) {
try {
return el.getChild(nodeName, BAMS).getValue();
} catch (Exception e) {
// System.out.println(nodeName+" "+e);
return null;
}
}
}
代码示例来源:origin: bcdev/beam
static String getValue(Element root, String... childs) {
Element element = root;
int index = 0;
while (element != null && index < childs.length) {
String childName = childs[index++];
element = element.getChild(childName);
}
return element != null ? element.getValue() : null;
}
代码示例来源:origin: senbox-org/s1tbx
private static String getElementString(final Element elem) {
final Element value = elem.getChild("value");
return value.getValue();
}
代码示例来源:origin: senbox-org/s1tbx
private static int getElementInt(final Element elem) {
final Element value = elem.getChild("value");
return Integer.parseInt(value.getValue());
}
代码示例来源:origin: senbox-org/s1tbx
private static double getElementDouble(final Element elem) {
final Element value = elem.getChild("value");
return Double.parseDouble(value.getValue());
}
代码示例来源:origin: jpos/jPOS
public void dump(PrintStream p, String indent) {
String inner = indent + " ";
p.println(indent + "<ContextMaker name='" + getName() + "'>");
for (Element e : contextValues) {
p.println(indent+"<"+indent+e.getName()+">"+e.getValue()+"</"+indent+e.getName()+">");
}
p.println(indent + "</ContextMaker>");
}
}
代码示例来源:origin: senbox-org/s1tbx
private static double[] getElementArray(final Element elem) {
final Element value = elem.getChild("value");
final Element ptr = value.getChild("parameter");
final Element val = ptr.getChild("value");
String str = val.getValue();
str = str.replace("[","").replace("]","");
return stringToDoubleArray(str, ",");
}
代码示例来源:origin: org.apache.marmotta/ldclient-provider-mediawiki
protected List<String> parseRevision(URI resource, String requestUrl, Model model, ValueFactory valueFactory,
Element revisions, Context context) throws RepositoryException {
List<String> followUp = Collections.emptyList();
if (revisions == null) return followUp;
final Element rev = revisions.getChild("rev");
if (rev == null) return followUp;
final Resource subject = resource;
if (context == Context.META && "0".equals(rev.getAttributeValue("parentid"))) {
// This is the first revision, so we use the creation date
addLiteralTriple(subject, Namespaces.NS_DC_TERMS + "created", rev.getAttributeValue("timestamp"), Namespaces.NS_XSD + "dateTime", model,
valueFactory);
}
if (context == Context.CONTENT && rev.getValue() != null && rev.getValue().trim().length() > 0) {
final String content = rev.getValue().trim();
final Matcher m = REDIRECT_PATTERN.matcher(content);
if (((Element) revisions.getParent()).getAttribute("redirect") != null && m.find()) {
followUp = Collections.singletonList(buildApiPropQueryUrl(requestUrl, m.group(1), "info", getDefaultParams("info", null),
Context.REDIRECT));
} else {
addLiteralTriple(subject, Namespaces.NS_RSS_CONTENT + "encoded", content, Namespaces.NS_XSD + "string", model, valueFactory);
}
}
return followUp;
}
代码示例来源:origin: com.theoryinpractise/halbuilder-xml
private void readProperties(Representation resource, Element element) {
List<Element> properties = element.getChildren();
for (Element property : properties) {
if (!property.getName().matches("(link|resource)")) {
if (property.getAttribute("nil", XSI_NAMESPACE) != null) {
resource.withProperty(property.getName(), null);
} else {
resource.withProperty(property.getName(), property.getValue());
}
}
}
}
代码示例来源:origin: pwm-project/pwm
static StoredValue readPropertyValue(
final StoredConfigReference storedConfigReference,
final Element settingElement
)
{
final String key = storedConfigReference.getRecordID();
LOGGER.trace( () -> "parsing property key=" + key + ", profile=" + storedConfigReference.getProfileID() );
if ( settingElement.getChild( StoredConfiguration.XML_ELEMENT_DEFAULT ) != null )
{
return new StringValue( settingElement.getValue() );
}
return null;
}
代码示例来源:origin: jpos/jPOS
public void run() {
Thread.currentThread().setName(getName());
while (running()) {
Object o = sp.in(in, timeout);
if (o != null) {
Context ctx = new Context();
ctx.put(contextName, o);
if (contextValues != null) {
for (Element e : contextValues) {
ctx.put(e.getName(),e.getValue());
}
}
sp.out(out, ctx);
}
}
}
代码示例来源:origin: crosswire/jsword
@Override
public void processContent(Book book, Key key, Element ele) {
String refstr = ele.getValue();
try {
if (ele.getAttribute(OSISUtil.OSIS_ATTR_REF) == null) {
Passage ref = PassageKeyFactory.instance().getKey(KeyUtil.getVersification(key), refstr, key);
String osisname = ref.getOsisRef();
ele.setAttribute(OSISUtil.OSIS_ATTR_REF, osisname);
}
} catch (NoSuchKeyException ex) {
DataPolice.report(book, key, "scripRef has no passage attribute, unable to guess: (" + refstr + ") due to " + ex.getMessage());
}
}
}
代码示例来源:origin: Unidata/thredds
@Test
public void testGetCapabilites() throws IOException, JDOMException {
String endpoint = TestOnLocalServer.withHttpPath(dataset1+"&request=GetCapabilities");
byte[] result = TestOnLocalServer.getContent(endpoint, 200, ContentType.xml);
Reader in = new StringReader( new String(result, CDM.utf8Charset));
SAXBuilder sb = new SAXBuilder();
Document doc = sb.build(in);
//XPathExpression<Element> xpath = XPathFactory.instance().compile("ns:/WCS_Capabilities/ContentMetadata/CoverageOfferingBrief", Filters.element(), null, NS_WCS);
XPathExpression<Element> xpath = XPathFactory.instance().compile("//wcs:CoverageOfferingBrief", Filters.element(), null, NS_WCS);
List<Element> elements = xpath.evaluate(doc);
for (Element emt : elements) {
logger.debug("XPath has result: {}", emt.getContent());
}
assertEquals(7, elements.size());
XPathExpression<Element> xpath2 = XPathFactory.instance().compile("//wcs:CoverageOfferingBrief/wcs:name", Filters.element(), null, NS_WCS);
List<String> names = new ArrayList<>();
for (Element elem : xpath2.evaluate(doc)) {
logger.debug(" {}=={}", elem.getName(), elem.getValue());
names.add(elem.getValue());
}
Assert.assertEquals(7, names.size());
assert names.contains("Relative_humidity_height_above_ground");
assert names.contains("Pressure_reduced_to_MSL");
}
内容来源于网络,如有侵权,请联系作者删除!