* @return Pointer created
*/
private Pointer setValue(String xpath, Expression expr, Object value,
boolean create) {
Object result = expr.computeValue(getEvalContext());
Pointer pointer = null;
if (result instanceof Pointer) {
pointer = (Pointer) result;
}
else if (result instanceof EvalContext) {
EvalContext ctx = (EvalContext) result;
pointer = ctx.getSingleNodePointer();
}
else {
if (create) {
checkSimplePath(expr);
}
// This should never happen
throw new JXPathException("Cannot set value for xpath: " + xpath);
}
if (create) {
pointer = ((NodePointer) pointer).createPath(this, value);
}
else {
pointer.setValue(value);
}
return pointer;
}