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


Java Filter类代码示例

本文整理汇总了Java中org.jdom2.filter.Filter的典型用法代码示例。如果您正苦于以下问题:Java Filter类的具体用法?Java Filter怎么用?Java Filter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Filter类属于org.jdom2.filter包,在下文中一共展示了Filter类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DataDrivenTest

import org.jdom2.filter.Filter; //导入依赖的package包/类
private DataDrivenTest(Element e) {
    super(e.getAttributeValue("desc"));

    Filter prologFilter = new AbstractFilter() {
        @Override
        public Object filter(Object o) {
            if (o instanceof Element
                    || o instanceof Comment
                    || o instanceof ProcessingInstruction) {
                return o;
            }
            return null;
        }
    };

    target.addContent(XmlHelper.clone(e.getChild("target").getContent(prologFilter)));
    diff.setRootElement((Element) e.getChild("diff").clone());
    expectedResult.addContent(XmlHelper.clone(e.getChild("result").getContent(prologFilter)));

    String errorName = e.getChild("result").getAttributeValue("error");
    expectedError = errorName == null ? null : ErrorCondition.valueOf(errorName);
}
 
开发者ID:dnault,项目名称:xml-patch,代码行数:23,代码来源:DataDrivenTest.java

示例2: getFirstImageSource

import org.jdom2.filter.Filter; //导入依赖的package包/类
private ImageResource getFirstImageSource(Resource CoverPageResource, Resources resources)
{
    try
    {
        Document titlePageDocument = ResourceUtil.getAsDocument(CoverPageResource);
        Filter<Element> imgFilter = new ElementFilter("img");
        List<Element> imageElements = titlePageDocument.getRootElement().getContent(imgFilter);
        for (Element imageElement : imageElements)
        {
            String relativeImageHref = imageElement.getAttributeValue("src");
            String absoluteImageHref = calculateAbsoluteImageHref(relativeImageHref, CoverPageResource.getHref());
            ImageResource imageResource = (ImageResource)resources.getByHref(absoluteImageHref);
            if (imageResource != null)
            {
                return imageResource;
            }
        }
    }
    catch (Exception e)
    {
        log.error(e.getMessage(), e);
    }
    return null;
}
 
开发者ID:finanzer,项目名称:epubfx,代码行数:25,代码来源:CoverpageBookProcessor.java

示例3: setOnNode

import org.jdom2.filter.Filter; //导入依赖的package包/类
/**
 * Executes an Xpath for an element and executes the consumer
 *
 * @param element Element the xpath is executed against
 * @param expressionStr Xpath
 * @param consumer Consumer to execute if the xpath matches
 * @param filter Filter to apply for the xpath
 * @param selectOne Whether to execute for the first match or multiple matches
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
void setOnNode(Element element, String expressionStr,
				Consumer consumer, Filter<?> filter, boolean selectOne) {
	XPathExpression<?> expression = XPathFactory.instance().compile(expressionStr, filter, null,  xpathNs);

	if (selectOne) {
		Optional.ofNullable(expression.evaluateFirst(element)).ifPresent(consumer);
	} else {
		List<?> elems = expression.evaluate(element);
		Optional.ofNullable(elems)
				.ifPresent(notNullElems -> notNullElems.forEach(consumer));
	}
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:23,代码来源:XmlInputDecoder.java

示例4: evaluate

import org.jdom2.filter.Filter; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public static List<Object> evaluate(String expr, Object parent, Filter filter) throws FatalIndexerException {
    XPathBuilder<Object> builder = new XPathBuilder<>(expr.trim().replace("\n", ""), filter);
    // Add all namespaces
    for (String key : Configuration.getInstance().getNamespaces().keySet()) {
        Namespace value = Configuration.getInstance().getNamespaces().get(key);
        builder.setNamespace(key, value.getURI());
    }
    XPathExpression<Object> xpath = builder.compileWith(XPathFactory.instance());
    return xpath.evaluate(parent);

}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:13,代码来源:JDomXP.java

示例5: compile

import org.jdom2.filter.Filter; //导入依赖的package包/类
@Override
public <T> XPathExpression<T> compile(String expression, Filter<T> filter, Map<String, Object> variables,
    Namespace... namespaces) {
    XPathExpression<T> jaxenCompiled = super.compile(expression, filter, variables, namespaces);

    if (functions.stream().anyMatch(function -> function.isCalledIn(expression))) {
        addExtensionFunctions(jaxenCompiled, namespaces);
    }
    return jaxenCompiled;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:11,代码来源:MCRJaxenXPathFactory.java

示例6: executeXPath

import org.jdom2.filter.Filter; //导入依赖的package包/类
/**
 * Execute an XPath
 * 
 * @param document
 *            the Document
 * @param xpathStr
 *            the Xpath String
 * @param namespaceStr
 *            the namespace str
 * @param filter
 *            the filter
 * @return the list<? extends content>
 */
static public List<? extends Content> executeXPath(final Object document,
		final String xpathStr, final String namespaceStr,
		final Filter<? extends Content> filter) {
	final XPathFactory xpathFactory = XPathFactory.instance();
	// XPathExpression<Object> expr = xpathFactory.compile(xpathStr);

	XPathExpression<? extends Content> expr = null;
	if (namespaceStr != null)
		expr = xpathFactory.compile(xpathStr, filter, null,
				Namespace.getNamespace("x", namespaceStr));
	else
		expr = xpathFactory.compile(xpathStr, filter);

	List<? extends Content> xPathSearchedNodes = null;
	try {
		xPathSearchedNodes = expr.evaluate(document);
	}
	// TODO: Add better handling for these kinds of exceptions
	catch (final Exception e) {
		throw new CsfRuntimeException("Error in querying the message", e);
	}
	return xPathSearchedNodes;
	/*
	 * for (int i = 0; i < xPathSearchedNodes.size(); i++) { Content content =
	 * xPathSearchedNodes.get(i); System.out.println("content: " + i + ": " +
	 * content.getValue()); }
	 */
}
 
开发者ID:OpenSimulationSystems,项目名称:CABSF_Java,代码行数:42,代码来源:XMLUtilities.java

示例7: getAllElementsByFilter

import org.jdom2.filter.Filter; //导入依赖的package包/类
private List<Element> getAllElementsByFilter(Document document, Filter<Element> filter) {
    List<Element> allElems = new ArrayList<>();
    Iterator<Element> it = document.getRootElement().getDescendants(filter);

    while (it.hasNext()) {
        allElems.add(it.next());
    }

    return allElems;
}
 
开发者ID:matthiasgeiger,项目名称:BPMNspector-fixSeqFlow,代码行数:11,代码来源:SequenceFlowSolver.java

示例8: decodeGSEControlBlock

import org.jdom2.filter.Filter; //导入依赖的package包/类
void decodeGSEControlBlock(String appID_name) throws IEC61850_GOOSE_Exception
{	
	boolean found_GSEControlBlock = false;
	
	// Retrieves all elements named "GSEControl" within IED node
	Filter<Element> elementFilter = new ElementFilter("GSEControl");
	
	// Search for a GSEControl block with a matching appID
	for (Iterator<Element> GSEControl_IT = IED_section.getDescendants(elementFilter);
			GSEControl_IT.hasNext();)
	{
		Element current_element = GSEControl_IT.next();
		
		if(current_element.getAttributeValue("type").equals("GOOSE") && 
				current_element.getAttributeValue("appID").equals(appID_name))
		{
			// We found the right control block
			GSEControl_node =  current_element;
			found_GSEControlBlock = true;
		}
	}
	
	if (found_GSEControlBlock == false)
		throw new IEC61850_GOOSE_Exception("<GSEControl> Block with corresponding appID_name: " + appID_name + " name not found in <IED>");
	
	gseControlBlockAppIDName = GSEControl_node.getAttributeValue("appID");
	gseControlBlockName = GSEControl_node.getAttributeValue("name");
	gseControlBlockConfRev = GSEControl_node.getAttributeValue("confRev");
	gseControlBlockDatSet = GSEControl_node.getAttributeValue("datSet");
	
	ln0ClassName = GSEControl_node.getParentElement().getAttributeValue("lnClass");

	return;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:35,代码来源:IEC61850_GOOSE_ICD_file.java

示例9: evaluateXpath

import org.jdom2.filter.Filter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> T evaluateXpath(String xPath, Filter filter) throws IOException, XmlException {
	XPathExpression<Attribute> xpath = xpf.compile(xPath, filter);
	return (T) xpath.evaluateFirst(XmlUtils.parseXmlStream(XmlUtils.fileToStream(path)));
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:6,代码来源:JsonPathToXpathHelper.java

示例10: evaluateXpath

import org.jdom2.filter.Filter; //导入依赖的package包/类
private Object evaluateXpath(String xPath, Filter filter) throws IOException, XmlException {
	XPathExpression<Object> xpath = XPF.compile(xPath, filter);
	return xpath.evaluateFirst(XmlUtils.parseXmlStream(XmlUtils.fileToStream(PATH)));
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:5,代码来源:ValidationApiAcceptance.java

示例11: decodeGSEBlock

import org.jdom2.filter.Filter; //导入依赖的package包/类
void decodeGSEBlock(String GSEControlBlock_name) throws IEC61850_GOOSE_Exception
{
	boolean found_GSEBlock = false;
	boolean found_APPID = false;
	boolean found_MACAddress = false;
	
	// Retrieves all elements named "GSE" within ConnectedAP in Communication section
	Filter<Element> elementFilter = new ElementFilter("GSE");
	
	// Search for a GSE with a matching cbName
	for (Iterator<Element> GSE_IT = ConnectedAP_in_Comm_section.getDescendants(elementFilter);
		GSE_IT.hasNext();)
	{
		Element current_element = GSE_IT.next();
		
		if(current_element.getAttributeValue("cbName").equals(GSEControlBlock_name))
		{
			GSE_node = current_element;
			found_GSEBlock = true;
		}
	}
	
	if (found_GSEBlock == false)
		throw new IEC61850_GOOSE_Exception("<GSE> Block with cbName: " + GSEControlBlock_name + " not found in <ConnectedAP> block");
	
	gseldInst = GSE_node.getAttributeValue("ldInst");
	
	// walks to the "Address" children 
	Element GSE_Address = GSE_node.getChild("Address", root_namespace);
	List<Element> p_nodes_LIST = GSE_Address.getChildren("P", root_namespace);
	
	// Walks all P nodes to retrieve addressing data
	for ( int position = 0; position < p_nodes_LIST.size(); position++)
	{
		if(p_nodes_LIST.get(position).getAttributeValue("type").contentEquals("APPID"))
		{
			gseAPPID = Integer.parseInt(p_nodes_LIST.get(position).getValue());
			found_APPID = true;
		}
		
		if (p_nodes_LIST.get(position).getAttributeValue("type").contentEquals("MAC-Address"))
		{
			gseMACAddress = p_nodes_LIST.get(position).getValue();
			found_MACAddress = true;
		}
	}
	
	if (found_APPID == false)
		throw new IEC61850_GOOSE_Exception("<APPID> type not found in <GSE> Block with cbName:" + GSEControlBlock_name);
	
	if(found_MACAddress == false)
		throw new IEC61850_GOOSE_Exception("<MAC-Address> type not found in <GSE> Block with cbName:" + GSEControlBlock_name);
		
	// Retrieves the maxtime
	Element GSE_Maxtime = GSE_node.getChild("MaxTime", root_namespace);
	
	if (GSE_Maxtime == null)
		//throw new IEC61850_GOOSE_Exception("<MaxTime> not found in <GSE> Block with cbName:" + GSEControlBlock_name);
		// If the value is not set in the ICD file, we set it to 0.
		gseMaxTime = 0;
	
	else
		gseMaxTime =  Integer.parseInt(GSE_Maxtime.getValue());
	
	// Retrieves the mintime
	Element GSE_Mintime = GSE_node.getChild("MinTime", root_namespace);
	
	if (GSE_Mintime == null)
		//throw new IEC61850_GOOSE_Exception("<MinTime> not found in <GSE> Block with cbName:" + GSEControlBlock_name);
		// If the value is not set in the ICD file, we set it to 0.
		gseMinTime = 0;
	
	else
		gseMinTime = Integer.parseInt(GSE_Mintime.getValue());
	
	return;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:78,代码来源:IEC61850_GOOSE_ICD_file.java

示例12: WithChildFilter

import org.jdom2.filter.Filter; //导入依赖的package包/类
public WithChildFilter( Filter<Element> childFilter ) {
	this( null, childFilter );
}
 
开发者ID:Vhati,项目名称:Slipstream-Mod-Manager,代码行数:4,代码来源:XMLPatcher.java


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