dmitri 2003/01/19 15:58:27
Modified: jxpath/src/java/org/apache/commons/jxpath/ri/model
VariablePointer.java
Log:
Fixed issues with variables: qualified names and indexing
Revision Changes Path
1.12 +13 -18
jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/VariablePointer.java
Index: VariablePointer.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/VariablePointer.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- VariablePointer.java 12 Jan 2003 01:52:56 -0000 1.11
+++ VariablePointer.java 19 Jan 2003 23:58:27 -0000 1.12
@@ -68,7 +68,6 @@
import org.apache.commons.jxpath.Variables;
import org.apache.commons.jxpath.ri.QName;
import org.apache.commons.jxpath.ri.compiler.NodeTest;
-import org.apache.commons.jxpath.ri.model.beans.NullPointer;
import org.apache.commons.jxpath.util.ValueUtils;
/**
@@ -108,7 +107,7 @@
if (!actual) {
throw new JXPathException("Undefined variable: " + name);
}
- return variables.getVariable(name.getName());
+ return variables.getVariable(name.toString());
}
public boolean isLeaf() {
@@ -129,7 +128,7 @@
}
return value;
}
-
+
public void setValue(Object value) {
if (!actual) {
throw new JXPathException("Cannot set undefined variable: " + name);
@@ -140,30 +139,26 @@
ValueUtils.setValue(collection, index, value);
}
else {
- variables.declareVariable(name.getName(), value);
+ variables.declareVariable(name.toString(), value);
}
}
public boolean isActual() {
return actual;
}
+
+ public void setIndex(int index) {
+ super.setIndex(index);
+ valuePointer = null;
+ }
public NodePointer getImmediateValuePointer() {
if (valuePointer == null) {
Object value = null;
if (actual) {
value = getImmediateNode();
- valuePointer =
- NodePointer.newChildNodePointer(this, null, value);
- }
- else {
- return new NullPointer(this, getName()) {
- public Object getImmediateNode() {
- throw new JXPathException(
- "Undefined variable: " + name);
- }
- };
}
+ valuePointer = NodePointer.newChildNodePointer(this, null, value);
}
return valuePointer;
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>