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


Java JXPathContext.setValue方法代码示例

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


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

示例1: main

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
public static void main(String[] args) {
    Request request = new Request();
    JXPathContext context = JXPathContext.newContext(request);
    context.setValue("foo", new Foo());
    context.setValue("foo/subscriberNumber", "1234567890");
    context.setValue("foo/bar", new Bar());
    context.setValue("foo/bar/numbers[1]", "123"); // this fails
    System.out.println(request);
}
 
开发者ID:kinow,项目名称:commons-sandbox,代码行数:10,代码来源:TestsJxpath.java

示例2: transfer

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
@Override
public void transfer(OutputStream out) {
	this.context.put("create", true);
	
	JXPathContext xPathContext = getXPathContext();
	xPathContext.setLenient(true);
	Object o = xPathContext.getValue(getPath());
	if (o != null) {
		throw new IllegalArgumentException("Path '" + getPath() + "' exists.");
	}
	setupTX();
	
	Pointer p = xPathContext.createPath(getPath());
	
	JXPathContext relContext = getRelativeContext(p);
	
	for (String outputAttribute : getInputAttributeNameAsArray()) {
		
		/*
		Iterator<Pointer> outputAttrPointersIter = context.iteratePointers(outputAttribute);
		while(outputAttrPointersIter.hasNext()) {
			Pointer vPointer = outputAttrPointersIter.next();
			Object values = getValues(outputAttribute);
			//NodePointer nP = (NodePointer)vPointer;
			//nP.getImmediateValuePointer().setValue(values);
			vPointer.setValue(values);
		}
		*/	
		Object values = getValues(outputAttribute);
		relContext.setValue(outputAttribute, values);
	}
	
	processTX();
}
 
开发者ID:luox12,项目名称:onecmdb,代码行数:35,代码来源:CreateCommand.java

示例3: transfer

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
/**
 * Transfer the content to the stream.
 * Execute the update.
 * 
 * @param out
 */
public void transfer(OutputStream out) {
	
	String[] inputAttributes = getInputAttributeNameAsArray();
	
	setupTX();
	
	Iterator<Pointer> iter = getPathPointers();
	
	// Check that we have found the root object.
	if (!iter.hasNext()) {
		throw new IllegalArgumentException("No object matching path " + getPath() + " found!");
	}
	
	while(iter.hasNext()) {
		Pointer p = (Pointer)iter.next();
		
		JXPathContext context = getRelativeContext(p);
		
		for (String outputAttribute : inputAttributes) {
			
			/*
			Iterator<Pointer> outputAttrPointersIter = context.iteratePointers(outputAttribute);
			while(outputAttrPointersIter.hasNext()) {
				Pointer vPointer = outputAttrPointersIter.next();
				Object values = getValues(outputAttribute);
				//NodePointer nP = (NodePointer)vPointer;
				//nP.getImmediateValuePointer().setValue(values);
				vPointer.setValue(values);
			}
			*/	
			Object values = getValues(outputAttribute);
			if (values == null) {
				String valueExpr = attributeMap.get(outputAttribute);
				throw new IllegalArgumentException("No value matching expr " + valueExpr + " found!");
			}
			context.setValue(outputAttribute, values);
		}
	}
	
	// Process the TX.
	processTX();
	
}
 
开发者ID:luox12,项目名称:onecmdb,代码行数:50,代码来源:UpdateCommand.java


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