本文整理汇总了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);
}
示例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();
}
示例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();
}