本文整理匯總了Java中org.jdom2.Element.getValue方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.getValue方法的具體用法?Java Element.getValue怎麽用?Java Element.getValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jdom2.Element
的用法示例。
在下文中一共展示了Element.getValue方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getConfig
import org.jdom2.Element; //導入方法依賴的package包/類
/**
* 獲取指定名稱的Config配置
* @return
*/
public Map<String,String> getConfig(String name) {
Element rootEle = doc.getRootElement();
Element elements = rootEle.getChild(name);
Map<String,String> configMap = new HashMap<String, String>();
if (elements != null) {
List<Element> childElementList = elements.getChildren();
for(Element childElement : childElementList) {
String lname = childElement.getName();
String lvalue = childElement.getValue();
configMap.put(lname, lvalue);
}
}
return configMap;
}
示例2: readGeneralProductInformation
import org.jdom2.Element; //導入方法依賴的package包/類
/**
* Read the generalProductInformation:
* productType,instrumentConfigurationID,
* missionDataTakeID,transmitterReceiverPolarisation
* ,productTimelinessCategory,sliceProductFlag
*
* @throws JAXBException
* @throws SAXException
*/
public void readGeneralProductInformation() throws JAXBException,
SAXException {
String xPathGenProdInfo = "/xfdu:XFDU/metadataSection/metadataObject/metadataWrap/xmlData/*[name()='generalProductInformation']";
String xPathStandAloneInfo = "/xfdu:XFDU/metadataSection/metadataObject/metadataWrap/xmlData/s1sarl1:standAloneProductInformation']";
XPathExpression<Element> expr = xFactory.compile(xPathGenProdInfo,
Filters.element(), null, xfdu);
List<Element> value = expr.evaluate(safe);
if (value == null || value.isEmpty()) {
expr = xFactory.compile(xPathStandAloneInfo, Filters.element(),
null, s1sarl1, xfdu);
value = expr.evaluate(safe);
}
List<Element> informationsNode = value.get(0).getChildren();
productInformation = new ProductInformation();
for (Element e : informationsNode) {
String name = e.getName();
String val = e.getValue();
productInformation.putValueInfo(name, val);
}
}
示例3: readGeneralProductInformation
import org.jdom2.Element; //導入方法依賴的package包/類
public void readGeneralProductInformation() throws JAXBException,
SAXException {
String xPathGenProdInfo = "/xfdu:XFDU/metadataSection/metadataObject/metadataWrap/xmlData/*[name()='generalProductInformation']";
String xPathStandAloneInfo = "/xfdu:XFDU/metadataSection/metadataObject/metadataWrap/xmlData/s1sarl1:standAloneProductInformation";
XPathExpression<Element> expr = xFactory.compile(xPathGenProdInfo,
Filters.element(), null, xfdu);
List<Element> value = expr.evaluate(safe);
if (value == null || value.isEmpty()) {
expr = xFactory.compile(xPathStandAloneInfo, Filters.element(),
null, s1sarl1, xfdu);
value = expr.evaluate(safe);
}
List<Element> informationsNode = value.get(0).getChildren();
productInformation = new ProductInformation();
for (Element e : informationsNode) {
String name = e.getName();
String val = e.getValue();
productInformation.putValueInfo(name, val);
}
}
示例4: parse
import org.jdom2.Element; //導入方法依賴的package包/類
public static GameRulesModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
Map<GameRule, Boolean> gameRules = new HashMap<>();
for (Element gameRulesElement : doc.getRootElement().getChildren("gamerules")) {
for (Element gameRuleElement : gameRulesElement.getChildren()) {
GameRule gameRule = GameRule.forName(gameRuleElement.getName());
String value = gameRuleElement.getValue();
if (gameRule == null) {
throw new InvalidXMLException(gameRuleElement.getName() + " is not a valid gamerule", gameRuleElement);
}
if (value == null) {
throw new InvalidXMLException("Missing value for gamerule " + gameRule.getValue(), gameRuleElement);
} else if (!(value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false"))) {
throw new InvalidXMLException(gameRuleElement.getValue() + " is not a valid gamerule value", gameRuleElement);
}
if (gameRules.containsKey(gameRule)){
throw new InvalidXMLException(gameRule.getValue() + " has already been specified", gameRuleElement);
}
gameRules.put(gameRule, Boolean.valueOf(value));
}
}
return new GameRulesModule(gameRules);
}
示例5: checkValue
import org.jdom2.Element; //導入方法依賴的package包/類
private String checkValue(Element element) {
if (element == null) {
return null;
}
return element.getValue();
}
示例6: getMCRIDs
import org.jdom2.Element; //導入方法依賴的package包/類
private List<String> getMCRIDs(PublicationAuthor author) throws IOException, JDOMException, SAXException {
//prepare list of results blocks
String query = prepareAuthorQuery(author);
//divide API request in blocks a 100 documents
int numberOfPublications = getNumberOfPublications(query);
String pathToID = "result/doc/str[@name='id']";
// String pathToID = "lst[@name='responseHeader']";
XPathExpression<Element> xPath = XPathFactory.instance().compile(pathToID, Filters.element());
List<String> foundMCRIds = new ArrayList<>();
//at the moment only testing, two blocks a 10 documents
for (int i = 0; i < ( (numberOfPublications / 100) + 1); i++) {
int start = 100 * i;
//build API URL
String queryURL = query + "&rows=100&start=" + start;
Element response = getResponse(queryURL).asXML().detachRootElement().clone();
List<Element> foundMCRIDElements = xPath.evaluate(response);
LOGGER.info("found " + foundMCRIDElements.size() + " mods elements");
for (Element mcrIDElement : foundMCRIDElements) {
String mcrID = mcrIDElement.getValue();
if (!mcrID.contains("-"))
foundMCRIds.add(mcrID);
}
}
LOGGER.info("retrieved " + foundMCRIds.size() + " entries from MyCoRe repository.");
//return API-response
return foundMCRIds;
}
示例7: updateCitationCount
import org.jdom2.Element; //導入方法依賴的package包/類
public Document updateCitationCount(Document doc) throws JDOMException, SAXException {
Document newDoc = new Document();
// extract DOI
String doi = "";
Element rootElement = doc.getRootElement();
List<Element> children = rootElement.getChildren("identifier", MODS_NS);
for (Element element : children) {
List<Attribute> attributes = element.getAttributes();
for (Attribute attribute : attributes) {
if ("type".equals(attribute.getName()) && "doi".equals(attribute.getValue())) {
doi = element.getValue();
}
}
}
// get Doc with new citation count
try {
newDoc = getPublicationByDOI(doi).asXML();
} catch (IOException ex) {
}
// extract new citation count
Element newRootElement = newDoc.getRootElement();
Element newChild = newRootElement.getChild("extension", MODS_NS).getChild("sourcetext")
.getChild("abstracts-retrieval-response", ELSEVIER_Namespace).getChild("coredata", ELSEVIER_Namespace)
.getChild("citedby-count", ELSEVIER_Namespace);
String newCitationCount = newChild.getValue();
// replace old citation count
Element child = rootElement.getChild("extension", MODS_NS).getChild("sourcetext")
.getChild("abstracts-retrieval-response", ELSEVIER_Namespace).getChild("coredata", ELSEVIER_Namespace)
.getChild("citedby-count", ELSEVIER_Namespace);
child.setText(newCitationCount);
return doc;
}
示例8: getServerUrl
import org.jdom2.Element; //導入方法依賴的package包/類
/**
* 讀取目標測試服務器URL
* @return
*/
public String getServerUrl() {
Element rootEle = doc.getRootElement();
Element serverUrlEle = rootEle.getChild("server-url");
return serverUrlEle.getValue();
}