本文整理汇总了Java中org.jdom2.filter.Filters类的典型用法代码示例。如果您正苦于以下问题:Java Filters类的具体用法?Java Filters怎么用?Java Filters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Filters类属于org.jdom2.filter包,在下文中一共展示了Filters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPerformanceTimeRangeOnNode
import org.jdom2.filter.Filters; //导入依赖的package包/类
/**
* Acquires the reporting parameters within the xml and inserts into a given node
*
* @param element XML document that contains the reporting parameters act
* @param thisNode Reporting parameter node
*/
private void setPerformanceTimeRangeOnNode(Element element, Node thisNode) {
String performanceStartExprStr = getXpath(PERFORMANCE_START);
String performanceEndExprStr = getXpath(PERFORMANCE_END);
Consumer<? super Attribute> performanceStartConsumer =
p -> {
String start = p.getValue();
thisNode.putValue(PERFORMANCE_START, start, false);
//start is formatted as follows: yyyyMMddHHmmss
thisNode.putValue(PERFORMANCE_YEAR, start.substring(0, 4));
};
Consumer<? super Attribute> performanceEndConsumer =
p -> thisNode.putValue(PERFORMANCE_END, p.getValue(), false);
setOnNode(element, performanceStartExprStr, performanceStartConsumer, Filters.attribute(), false);
setOnNode(element, performanceEndExprStr, performanceEndConsumer, Filters.attribute(), false);
}
示例2: executeAttributeTest
import org.jdom2.filter.Filters; //导入依赖的package包/类
public void executeAttributeTest(String jsonPath, String expectedValue) {
String xPath = PathCorrelator.prepPath(jsonPath, wrapper);
Attribute attribute = null;
try {
attribute = evaluateXpath(xPath, Filters.attribute());
} catch (IOException | XmlException e) {
fail(e.getMessage());
}
if (attribute == null) {
System.out.println("no attribute for path: " + jsonPath
+ "\n xpath: " + xPath);
}
if (!expectedValue.equals(attribute.getValue())) {
System.err.println("( " + jsonPath + " ) value ( " + expectedValue +
" ) does not equal ( " + attribute.getValue() +
" ) at \n( " + xPath + " ). \nPlease investigate.");
}
assertThat(attribute.getValue()).isNotNull();
}
示例3: readMesasurementFilesFromSafe
import org.jdom2.filter.Filters; //导入依赖的package包/类
/**
* Return the mesaurements
*
* @return
*/
public void readMesasurementFilesFromSafe() {
XPathExpression<Element> expr = xFactory
.compile(
"/xfdu:XFDU/dataObjectSection/dataObject[@repID='s1Level1ProductSchema']/byteStream/fileLocation",
Filters.element(), null, xfdu);
List<Element> values = expr.evaluate(safe);
this.measurements=new File[values.size()];
File safefile = new File(safePath);
String measurementPath = safefile.getParent() + "/measurement";
for (int i = 0; i < values.size(); i++) {
Element e = values.get(i);
String href = e.getAttributeValue("href");
if (href.startsWith("./"))
href = href.substring(2);
measurements[i] = new File(measurementPath + "/" + href);
System.out.println(measurements[i]);
}
}
示例4: readGeneralProductInformation
import org.jdom2.filter.Filters; //导入依赖的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);
}
}
示例5: readAcquisitionPeriod
import org.jdom2.filter.Filters; //导入依赖的package包/类
/**
* Read the acquisition period
*
* @throws JAXBException
* @throws SAXException
*/
public void readAcquisitionPeriod() throws JAXBException, SAXException {
acquPeriod = new AcquisitionPeriod();
String xPathStartTime = "/xfdu:XFDU/metadataSection/metadataObject/metadataWrap/xmlData//*[name()='safe:startTime']";
String xPathStopTime = "/xfdu:XFDU/metadataSection/metadataObject/metadataWrap/xmlData//*[name()='safe:stopTime']";
XPathExpression<Element> expr = xFactory.compile(xPathStartTime,
Filters.element(), null, xfdu, safeNs);
Element e = expr.evaluateFirst(safe);
if (e != null)
acquPeriod.setStartTime(e.getValue());
expr = xFactory.compile(xPathStopTime, Filters.element(), null, xfdu,
safeNs);
e = expr.evaluateFirst(safe);
if (e != null)
acquPeriod.setStopTime(e.getValue());
}
示例6: readMesasurementFilesFromSafe
import org.jdom2.filter.Filters; //导入依赖的package包/类
public void readMesasurementFilesFromSafe() {
XPathExpression<Element> expr = xFactory
.compile(
"/xfdu:XFDU/dataObjectSection/dataObject[@repID='s1Level1ProductSchema']/byteStream/fileLocation",
Filters.element(), null, xfdu);
List<Element> values = expr.evaluate(safe);
this.measurements=new File[values.size()];
String measurementPath = safefile.getParent() + "/measurement";
for (int i = 0; i < values.size(); i++) {
Element e = values.get(i);
String href = e.getAttributeValue("href");
if (href.startsWith("./"))
href = href.substring(2);
measurements[i] = new File(measurementPath + "/" + href);
System.out.println(measurements[i]);
}
}
示例7: readGeneralProductInformation
import org.jdom2.filter.Filters; //导入依赖的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);
}
}
示例8: readAcquisitionPeriod
import org.jdom2.filter.Filters; //导入依赖的package包/类
public void readAcquisitionPeriod() throws JAXBException, SAXException {
acquPeriod = new AcquisitionPeriod();
String xPathStartTime = "/xfdu:XFDU/metadataSection/metadataObject/metadataWrap/xmlData//*[name()='safe:startTime']";
String xPathStopTime = "/xfdu:XFDU/metadataSection/metadataObject/metadataWrap/xmlData//*[name()='safe:stopTime']";
XPathExpression<Element> expr = xFactory.compile(xPathStartTime,
Filters.element(), null, xfdu, safeNs);
Element e = expr.evaluateFirst(safe);
if (e != null)
acquPeriod.setStartTime(e.getValue());
expr = xFactory.compile(xPathStopTime, Filters.element(), null, xfdu,
safeNs);
e = expr.evaluateFirst(safe);
if (e != null)
acquPeriod.setStopTime(e.getValue());
}
示例9: getPublicationsForAuthor
import org.jdom2.filter.Filters; //导入依赖的package包/类
public Set<Element> getPublicationsForAuthor(PublicationAuthor author)
throws IOException, JDOMException, SAXException {
if (!author.getScopusAuthorID().isEmpty()) {
Set<Element> publications = new HashSet<>();
String queryURL = API_URL + "/author/AUTHOR_ID:" + author.getScopusAuthorID()
+ "?start=0&count=200&view=DOCUMENTS&apikey=" + API_KEY;
XPathExpression<Element> xPath = XPathFactory.instance().compile(pathToDocumentIdentifier,
Filters.element());
List<Element> identifierElements = xPath
.evaluate(getResponse(queryURL).asXML().detachRootElement().clone());
for (Element idElement : identifierElements) {
publications.add(getPublicationByID(idElement.getValue()));
}
return publications;
} else
return null;
}
示例10: getCitationInformation
import org.jdom2.filter.Filters; //导入依赖的package包/类
public Element getCitationInformation(String scopusID)
throws IOException, JDOMException, SAXException {
// build API URL
String queryURL = API_URL + "/abstract/citation-count?scopus_id=" + scopusID + "&apikey=" + API_KEY
+ "&httpAccept=application%2Fxml";
XPathExpression<Element> xPathCount = XPathFactory.instance().compile(pathToCitationCount, Filters.element());
XPathExpression<Element> xPathLink = XPathFactory.instance().compile(pathToCitationLink, Filters.element());
XPathExpression<Element> xPathArticleLink = XPathFactory.instance().compile(pathToArticleLink, Filters.element());
Element response = getResponse(queryURL).asXML().detachRootElement().clone();
String citationCount = xPathCount.evaluateFirst(response).getValue();
String citationLink = xPathLink.evaluateFirst(response).getAttributeValue("href");
String articleLink = xPathArticleLink.evaluateFirst(response).getAttributeValue("href");
Element citationInformation = new Element("citationInformation");
citationInformation.addContent(new Element("count").setText(citationCount));
citationInformation.addContent(new Element("citationLink").setText(citationLink));
citationInformation.addContent(new Element("articleLink").setText(articleLink));
return citationInformation;
}
示例11: evaluateToAttributes
import org.jdom2.filter.Filters; //导入依赖的package包/类
/**
* Evaluates the given XPath expression to a list of attributes.
*
* @param expr XPath expression to evaluate.
* @param parent If not null, the expression is evaluated relative to this element.
* @return {@link ArrayList} or null
* @throws FatalIndexerException
* @should return all values
*/
public List<Attribute> evaluateToAttributes(String expr, Object parent) throws FatalIndexerException {
List<Attribute> retList = new ArrayList<>();
if (parent == null) {
parent = doc;
}
List<Object> list = evaluate(expr, parent, Filters.attribute());
if (list == null) {
return null;
}
for (Object object : list) {
if (object instanceof Attribute) {
Attribute attr = (Attribute) object;
retList.add(attr);
}
}
return retList;
}
示例12: evaluateToString
import org.jdom2.filter.Filters; //导入依赖的package包/类
/**
* Evaluates the given XPath expression to a single string.
*
* @param expr XPath expression to evaluate.
* @param parent If not null, the expression is evaluated relative to this element.
* @return {@link String} or null
* @throws FatalIndexerException
* @should return value correctly
*/
public String evaluateToString(String expr, Object parent) throws FatalIndexerException {
if (parent == null) {
parent = doc;
}
// JDOM2 requires '/text()' for string evaluation
if (expr != null && !expr.endsWith("/text()")) {
expr += "/text()";
}
List<Object> list = evaluate(expr, parent, Filters.text());
if (list == null || list.isEmpty()) {
return null;
}
if (objectToString(list.get(0)) != null) {
return objectToString(list.get(0));
}
return "";
}
示例13: evaluateToStringList
import org.jdom2.filter.Filters; //导入依赖的package包/类
/**
* Evaluates the given XPath expression to a list of strings.
*
* @param expr XPath expression to evaluate.
* @param parent If not null, the expression is evaluated relative to this element.
* @return {@link ArrayList} or null
* @throws FatalIndexerException
* @should return all values
*/
public List<String> evaluateToStringList(String expr, Object parent) throws FatalIndexerException {
if (parent == null) {
parent = doc;
}
List<Object> list = evaluate(expr, parent, Filters.fpassthrough());
if (list == null) {
return null;
}
List<String> retList = new ArrayList<>();
for (Object object : list) {
retList.add(objectToString(object));
}
return retList;
}
示例14: evaluateToCdata
import org.jdom2.filter.Filters; //导入依赖的package包/类
/**
* Evaluates given XPath expression to the first found CDATA element.
*
* @param expr
* @param parent
* @return
* @throws FatalIndexerException
* @should return value correctly
*/
public String evaluateToCdata(String expr, Object parent) throws FatalIndexerException {
if (parent == null) {
parent = doc;
}
// JDOM2 requires '/text()' for string evaluation
if (expr != null && !expr.endsWith("/text()")) {
expr += "/text()";
}
List<Object> list = evaluate(expr, parent, Filters.cdata());
if (list == null || list.isEmpty()) {
return null;
}
if (objectToString(list.get(0)) != null) {
return objectToString(list.get(0));
}
return "";
}
示例15: load
import org.jdom2.filter.Filters; //导入依赖的package包/类
@Override
public TestCaseData load() {
TestCaseData tcData = new TestCaseData();
XPathFactory xFactory = XPathFactory.instance();
Element testCase = xFactory.compile("//testcase[@name='" + name + "']", Filters.element()).evaluateFirst(xmlDocument);
List<Element> scenarios = testCase.getChildren();
for (Element scenario : scenarios) {
List<Element> parameters = scenario.getChildren();
ScenarioData testScenario = new ScenarioData(scenario.getName(), testCase.getName());
for (Element parameter : parameters) {
testScenario.putScenarioData(parameter.getName(), parameter.getValue());
}
tcData.addScenarioData(testScenario);
}
return tcData;
}