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


Java JXPathContext.iteratePointers方法代码示例

本文整理汇总了Java中org.apache.commons.jxpath.JXPathContext.iteratePointers方法的典型用法代码示例。如果您正苦于以下问题:Java JXPathContext.iteratePointers方法的具体用法?Java JXPathContext.iteratePointers怎么用?Java JXPathContext.iteratePointers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.jxpath.JXPathContext的用法示例。


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

示例1: fillCollectionSet

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
/**
 * Fill collection set.
 *
 * @param agent the agent
 * @param collectionSet the collection set
 * @param source the source
 * @param json the JSON Object
 * @throws ParseException the parse exception
 */
@SuppressWarnings("unchecked")
protected void fillCollectionSet(CollectionAgent agent, XmlCollectionSet collectionSet, XmlSource source, JSONObject json) throws ParseException {
    JXPathContext context = JXPathContext.newContext(json);
    for (XmlGroup group : source.getXmlGroups()) {
        log().debug("fillCollectionSet: getting resources for XML group " + group.getName() + " using XPATH " + group.getResourceXpath());
        Date timestamp = getTimeStamp(context, group);
        Iterator<Pointer> itr = context.iteratePointers(group.getResourceXpath());
        while (itr.hasNext()) {
            JXPathContext relativeContext = context.getRelativeContext(itr.next());
            String resourceName = getResourceName(relativeContext, group);
            log().debug("fillCollectionSet: processing XML resource " + resourceName);
            XmlCollectionResource collectionResource = getCollectionResource(agent, resourceName, group.getResourceType(), timestamp);
            AttributeGroupType attribGroupType = new AttributeGroupType(group.getName(), group.getIfType());
            for (XmlObject object : group.getXmlObjects()) {
                String value = (String) relativeContext.getValue(object.getXpath());
                XmlCollectionAttributeType attribType = new XmlCollectionAttributeType(object, attribGroupType);
                collectionResource.setAttributeValue(attribType, value);
            }
            processXmlResource(collectionResource, attribGroupType);
            collectionSet.getCollectionResources().add(collectionResource);
        }
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:33,代码来源:AbstractJsonCollectionHandler.java

示例2: testXpath

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
/**
 * Test to verify XPath content.
 *
 * @throws Exception the exception
 */
@Test
@SuppressWarnings("unchecked")
public void testXpath() throws Exception {
    JSONObject json = MockDocumentBuilder.getJSONDocument();
    JXPathContext context = JXPathContext.newContext(json);
    Iterator<Pointer> itr = context.iteratePointers("/zones/zone");
    while (itr.hasNext()) {
        Pointer resPtr = itr.next();
        JXPathContext relativeContext = context.getRelativeContext(resPtr);
        String resourceName = (String) relativeContext.getValue("@name");
        Assert.assertNotNull(resourceName);
        String value = (String) relativeContext.getValue("parameter[@key='nproc']/@value");
        Assert.assertNotNull(Integer.valueOf(value));
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:21,代码来源:JsonCollectorSolarisZonesTest.java

示例3: getValues

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
protected Object getValues(String outputAttribute) {
	// Parse if not already done
	parseInputAttributes();
	
	// Fetch the values strings, un parsed if expression.
	String value = attributeMap.get(outputAttribute);
	if (value == null) {
		return(null);
	}
	
	Object parsedValue = null;
		
	// Check if it's an expression
	if (value.startsWith("[")) {
		if (!value.endsWith("]")) {
			throw new IllegalArgumentException("ERROR: Value expression must be ended with a ']' ");
		}
		String path = value.substring(1);
		path = path.substring(0, path.length()-1);
			
		JXPathContext context = getXPathContext();
		Iterator<Pointer> pointers = (Iterator<Pointer>)context.iteratePointers(path);
		while(pointers.hasNext()) {
			Pointer pointer = pointers.next();
			parsedValue = pointer.getValue();
			// Migth warn here if there exists multiple.
		}
	} else {
			// No need to parse this, will be a String representaion of the value.
			parsedValue = value;
	}
		
	return(parsedValue);
	
}
 
开发者ID:luox12,项目名称:onecmdb,代码行数:36,代码来源:UpdateCommand.java

示例4: getPathPointers

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
public Iterator<Pointer> getPathPointers() {
	JXPathContext context = getXPathContext();
	return((Iterator<Pointer>)context.iteratePointers(getPath()));
}
 
开发者ID:luox12,项目名称:onecmdb,代码行数:5,代码来源:AbstractPathCommand.java

示例5: getRelativePointers

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
public Iterator<Pointer> getRelativePointers(Pointer p, String outputAttribute) {		
	JXPathContext relContext = getXPathContext().getRelativeContext(p);
	return((Iterator<Pointer>)relContext.iteratePointers(outputAttribute));
}
 
开发者ID:luox12,项目名称:onecmdb,代码行数:5,代码来源:AbstractPathCommand.java


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