当前位置: 首页>>代码示例>>Java>>正文


Java Filters类代码示例

本文整理汇总了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);
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:24,代码来源:ReportingParametersActDecoder.java

示例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();
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:24,代码来源:JsonPathToXpathHelper.java

示例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]);
	}

}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:28,代码来源:SumoSafeReader.java

示例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);
	}

}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:34,代码来源:SumoSafeReader.java

示例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());
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:26,代码来源:SumoSafeReader.java

示例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]);
	}

}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:22,代码来源:SumoXPathSafeReader.java

示例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);
	}

}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:25,代码来源:SumoXPathSafeReader.java

示例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());
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:20,代码来源:SumoXPathSafeReader.java

示例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;
}
 
开发者ID:ETspielberg,项目名称:bibliometrics,代码行数:18,代码来源:ScopusConnector.java

示例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;
}
 
开发者ID:ETspielberg,项目名称:bibliometrics,代码行数:19,代码来源:ScopusConnector.java

示例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;
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:27,代码来源:JDomXP.java

示例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 "";
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:27,代码来源:JDomXP.java

示例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;
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:26,代码来源:JDomXP.java

示例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 "";
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:27,代码来源:JDomXP.java

示例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;
}
 
开发者ID:AgileTestingFramework,项目名称:atf-toolbox-java,代码行数:24,代码来源:XMLDataDriver.java


注:本文中的org.jdom2.filter.Filters类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。