You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by dm...@apache.org on 2002/08/10 18:13:05 UTC
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom DOMAttributeIterator.java DOMAttributePointer.java DOMNamespaceIterator.java DOMNodeIterator.java DOMNodePointer.java NamespacePointer.java
dmitri 2002/08/10 09:13:05
Modified: jxpath/src/java/org/apache/commons/jxpath Pointer.java
jxpath/src/java/org/apache/commons/jxpath/ri/axes
PredicateContext.java
jxpath/src/java/org/apache/commons/jxpath/ri/model
NodePointer.java VariablePointer.java
jxpath/src/java/org/apache/commons/jxpath/ri/model/beans
BeanPropertyPointer.java CollectionPointer.java
DynamicPropertyPointer.java
LangAttributePointer.java NullElementPointer.java
NullPropertyPointer.java PropertyOwnerPointer.java
PropertyPointer.java
jxpath/src/java/org/apache/commons/jxpath/ri/model/container
ContainerPointer.java
jxpath/src/java/org/apache/commons/jxpath/ri/model/dom
DOMAttributeIterator.java DOMAttributePointer.java
DOMNamespaceIterator.java DOMNodeIterator.java
DOMNodePointer.java NamespacePointer.java
Log:
Made getNode() a public method on Pointer
Revision Changes Path
1.4 +20 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/Pointer.java
Index: Pointer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/Pointer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Pointer.java 16 Jun 2002 03:22:22 -0000 1.3
+++ Pointer.java 10 Aug 2002 16:13:03 -0000 1.4
@@ -81,9 +81,24 @@
/**
* Returns the value of the object, property or collection element
- * this pointer represents.
+ * this pointer represents. May convert the value to one of the
+ * canonical InfoSet types: String, Number, Boolean, Set.
+ *
+ * For example, in the case of an XML element, getValue() will
+ * return the text contained by the element rather than
+ * the element itself.
*/
Object getValue();
+
+ /**
+ * Returns the raw value of the object, property or collection element
+ * this pointer represents. Never converts the object to a
+ * canonical type: returns it as is.
+ *
+ * For example, for an XML element, getNode() will
+ * return the element itself rather than the text it contains.
+ */
+ Object getNode();
/**
* Modifies the value of the object, property or collection element
1.13 +5 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java
Index: PredicateContext.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- PredicateContext.java 10 Aug 2002 01:33:58 -0000 1.12
+++ PredicateContext.java 10 Aug 2002 16:13:03 -0000 1.13
@@ -110,7 +110,7 @@
else {
Object pred = expression.computeValue(parentContext);
if (pred instanceof NodePointer){
- pred = ((NodePointer)pred).getNodeValue();
+ pred = ((NodePointer)pred).getNode();
}
if (pred instanceof Number){
int pos = (int)InfoSetUtil.doubleValue(pred);
1.10 +17 -7 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/NodePointer.java
Index: NodePointer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/NodePointer.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- NodePointer.java 10 Aug 2002 01:49:46 -0000 1.9
+++ NodePointer.java 10 Aug 2002 16:13:03 -0000 1.10
@@ -159,7 +159,7 @@
* If true, this node does not have children
*/
public boolean isLeaf() {
- Object value = getNodeValue();
+ Object value = getNode();
return value == null
|| JXPathIntrospector.getBeanInfo(value.getClass()).isAtomic();
}
@@ -214,7 +214,7 @@
* return its string value.
*/
public Object getValue() {
- return getNodeValue();
+ return getNode();
}
/**
@@ -262,9 +262,19 @@
/**
* Returns the object the pointer points to; does not convert it
* to a "canonical" type.
+ *
+ * @deprecated 1.1 Please use getNode()
*/
- public abstract Object getNodeValue();
+ public Object getNodeValue(){
+ return getNode();
+ }
+ /**
+ * Returns the object the pointer points to; does not convert it
+ * to a "canonical" type.
+ */
+ public abstract Object getNode();
+
/**
* Converts the value to the required type and changes the corresponding
* object to that value.
1.6 +7 -7 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- VariablePointer.java 8 May 2002 23:05:04 -0000 1.5
+++ VariablePointer.java 10 Aug 2002 16:13:03 -0000 1.6
@@ -109,7 +109,7 @@
return variables.getVariable(name.getName());
}
- public Object getNodeValue(){
+ public Object getNode(){
Object value = getBaseValue();
if (index != WHOLE_COLLECTION){
return ValueUtils.getValue(value, index);
@@ -139,7 +139,7 @@
if (valuePointer == null){
Object value = null;
if (actual){
- value = getNodeValue();
+ value = getNode();
}
valuePointer = NodePointer.newChildNodePointer(this, null, value);
}
@@ -282,7 +282,7 @@
buffer.append('[').append(index + 1).append(']');
}
}
- else if (index != WHOLE_COLLECTION && (getNodeValue() == null || isCollection())){
+ else if (index != WHOLE_COLLECTION && (getNode() == null || isCollection())){
buffer.append('[').append(index + 1).append(']');
}
return buffer.toString();
1.7 +6 -6 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/BeanPropertyPointer.java
Index: BeanPropertyPointer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/BeanPropertyPointer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- BeanPropertyPointer.java 10 Aug 2002 01:44:30 -0000 1.6
+++ BeanPropertyPointer.java 10 Aug 2002 16:13:04 -0000 1.7
@@ -176,7 +176,7 @@
* property. If the property is not a collection, index should be zero
* and the value will be the property itself.
*/
- public Object getNodeValue(){
+ public Object getNode(){
if (value == UNINITIALIZED){
PropertyDescriptor pd = getPropertyDescriptor();
if (pd == null){
@@ -223,7 +223,7 @@
}
public NodePointer createPath(JXPathContext context){
- if (getNodeValue() == null){
+ if (getNode() == null){
AbstractFactory factory = getAbstractFactory(context);
int inx = (index == WHOLE_COLLECTION ? 0 : index);
if (!factory.createObject(context, this, getBean(),
1.6 +9 -9 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointer.java
Index: CollectionPointer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CollectionPointer.java 10 Aug 2002 01:46:19 -0000 1.5
+++ CollectionPointer.java 10 Aug 2002 16:13:04 -0000 1.6
@@ -102,7 +102,7 @@
return index == WHOLE_COLLECTION;
}
- public Object getNodeValue(){
+ public Object getNode(){
if (index != WHOLE_COLLECTION){
return ValueUtils.getValue(collection, index);
}
@@ -129,7 +129,7 @@
valuePointer = this;
}
else {
- Object value = getNodeValue();
+ Object value = getNode();
valuePointer = NodePointer.newChildNodePointer(this, getName(), value);
}
}
@@ -143,7 +143,7 @@
else {
Object collection = getBaseValue();
if (ValueUtils.getLength(collection) <= index){
- ValueUtils.expandCollection(getNodeValue(), index + 1);
+ ValueUtils.expandCollection(getNode(), index + 1);
}
ValueUtils.setValue(collection, index, value);
NodePointer ptr = (NodePointer)clone();
@@ -159,7 +159,7 @@
else {
Object collection = getBaseValue();
if (ValueUtils.getLength(collection) <= index){
- ValueUtils.expandCollection(getNodeValue(), index + 1);
+ ValueUtils.expandCollection(getNode(), index + 1);
}
return this;
}
@@ -172,7 +172,7 @@
else {
Object collection = getBaseValue();
if (ValueUtils.getLength(collection) <= index){
- ValueUtils.expandCollection(getNodeValue(), index + 1);
+ ValueUtils.expandCollection(getNode(), index + 1);
}
return this;
}
1.8 +6 -6 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/DynamicPropertyPointer.java
Index: DynamicPropertyPointer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/DynamicPropertyPointer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DynamicPropertyPointer.java 30 May 2002 01:57:23 -0000 1.7
+++ DynamicPropertyPointer.java 10 Aug 2002 16:13:04 -0000 1.8
@@ -210,7 +210,7 @@
* property. If the property is not a collection, index should be zero
* and the value will be the property itself.
*/
- public Object getNodeValue(){
+ public Object getNode(){
Object value;
if (index == WHOLE_COLLECTION){
value = handler.getProperty(getBean(), getPropertyName());
@@ -304,7 +304,7 @@
}
public NodePointer createPath(JXPathContext context){
- if (getNodeValue() == null){
+ if (getNode() == null){
AbstractFactory factory = getAbstractFactory(context);
int inx = (index == WHOLE_COLLECTION ? 0 : index);
if (!factory.createObject(context, this, getBean(), getPropertyName(), inx)){
1.4 +5 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/LangAttributePointer.java
Index: LangAttributePointer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/LangAttributePointer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LangAttributePointer.java 26 Apr 2002 01:00:37 -0000 1.3
+++ LangAttributePointer.java 10 Aug 2002 16:13:04 -0000 1.4
@@ -93,7 +93,7 @@
return parent.getLocale().toString().replace('_', '-');
}
- public Object getNodeValue(){
+ public Object getNode(){
return getBaseValue();
}
1.8 +5 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/NullElementPointer.java
Index: NullElementPointer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/NullElementPointer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- NullElementPointer.java 10 Aug 2002 01:49:46 -0000 1.7
+++ NullElementPointer.java 10 Aug 2002 16:13:04 -0000 1.8
@@ -94,7 +94,7 @@
return null;
}
- public Object getNodeValue(){
+ public Object getNode(){
return null;
}
1.7 +5 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/NullPropertyPointer.java
Index: NullPropertyPointer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/NullPropertyPointer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- NullPropertyPointer.java 10 Aug 2002 01:49:46 -0000 1.6
+++ NullPropertyPointer.java 10 Aug 2002 16:13:04 -0000 1.7
@@ -96,7 +96,7 @@
return null;
}
- public Object getNodeValue(){
+ public Object getNode(){
return null;
}
1.8 +5 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyOwnerPointer.java
Index: PropertyOwnerPointer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyOwnerPointer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PropertyOwnerPointer.java 10 Aug 2002 01:49:46 -0000 1.7
+++ PropertyOwnerPointer.java 10 Aug 2002 16:13:04 -0000 1.8
@@ -136,7 +136,7 @@
private static final Object UNINITIALIZED = new Object();
private Object value = UNINITIALIZED;
- public Object getNodeValue(){
+ public Object getNode(){
if (value == UNINITIALIZED){
if (index == WHOLE_COLLECTION){
value = getBaseValue();
1.5 +7 -7 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyPointer.java
Index: PropertyPointer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyPointer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PropertyPointer.java 29 May 2002 00:40:58 -0000 1.4
+++ PropertyPointer.java 10 Aug 2002 16:13:04 -0000 1.5
@@ -102,7 +102,7 @@
public Object getBean(){
if (bean == null){
- bean = getParent().getNodeValue();
+ bean = getParent().getNode();
}
return bean;
}
@@ -132,7 +132,7 @@
private static final Object UNINITIALIZED = new Object();
private Object value = UNINITIALIZED;
- public Object getNodeValue(){
+ public Object getNode(){
if (value == UNINITIALIZED){
if (index == WHOLE_COLLECTION){
value = getBaseValue();
@@ -149,7 +149,7 @@
* selected property value.
*/
public NodePointer getValuePointer(){
- return NodePointer.newChildNodePointer(this, getName(), getNodeValue());
+ return NodePointer.newChildNodePointer(this, getName(), getNode());
}
public int hashCode(){
1.3 +12 -7 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/container/ContainerPointer.java
Index: ContainerPointer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/container/ContainerPointer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ContainerPointer.java 26 Apr 2002 01:00:38 -0000 1.2
+++ ContainerPointer.java 10 Aug 2002 16:13:04 -0000 1.3
@@ -107,10 +107,15 @@
return container.getValue();
}
- public Object getNodeValue(){
+ public Object getNode(){
Object value = getBaseValue();
if (index != WHOLE_COLLECTION){
- return ValueUtils.getValue(value, index);
+ if (index >= 0 && index < getLength()){
+ return ValueUtils.getValue(value, index);
+ }
+ else {
+ return null;
+ }
}
return value;
}
@@ -121,7 +126,7 @@
public NodePointer getValuePointer(){
if (valuePointer == null){
- Object value = getNodeValue();
+ Object value = getNode();
valuePointer = NodePointer.newChildNodePointer(this, getName(), value).getValuePointer();
}
return valuePointer;
1.6 +5 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMAttributeIterator.java
Index: DOMAttributeIterator.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMAttributeIterator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DOMAttributeIterator.java 18 Jun 2002 11:50:35 -0000 1.5
+++ DOMAttributeIterator.java 10 Aug 2002 16:13:04 -0000 1.6
@@ -88,7 +88,7 @@
this.parent = parent;
this.name = name;
attributes = new ArrayList();
- Node node = (Node)parent.getNodeValue();
+ Node node = (Node)parent.getNode();
if (node.getNodeType() == Node.ELEMENT_NODE){
String lname = name.getName();
if (!lname.equals("*")){
1.6 +5 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMAttributePointer.java
Index: DOMAttributePointer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMAttributePointer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DOMAttributePointer.java 8 May 2002 23:05:05 -0000 1.5
+++ DOMAttributePointer.java 10 Aug 2002 16:13:04 -0000 1.6
@@ -103,7 +103,7 @@
return attr;
}
- public Object getNodeValue(){
+ public Object getNode(){
String value = attr.getValue();
if (value == null){
return null;
1.4 +5 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNamespaceIterator.java
Index: DOMNamespaceIterator.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNamespaceIterator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DOMNamespaceIterator.java 26 Apr 2002 01:00:38 -0000 1.3
+++ DOMNamespaceIterator.java 10 Aug 2002 16:13:04 -0000 1.4
@@ -84,7 +84,7 @@
public DOMNamespaceIterator(NodePointer parent){
this.parent = parent;
attributes = new ArrayList();
- collectNamespaces(attributes, (Node)parent.getNodeValue());
+ collectNamespaces(attributes, (Node)parent.getNode());
}
private void collectNamespaces(List attributes, Node node){
1.5 +6 -6 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodeIterator.java
Index: DOMNodeIterator.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodeIterator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DOMNodeIterator.java 10 Aug 2002 01:48:36 -0000 1.4
+++ DOMNodeIterator.java 10 Aug 2002 16:13:04 -0000 1.5
@@ -83,9 +83,9 @@
public DOMNodeIterator(NodePointer parent, NodeTest nodeTest, boolean reverse, NodePointer startWith){
this.parent = parent;
- this.node = (Node)parent.getNodeValue();
+ this.node = (Node)parent.getNode();
if (startWith != null){
- this.child = (Node)startWith.getNodeValue();
+ this.child = (Node)startWith.getNode();
}
this.nodeTest = nodeTest;
this.reverse = reverse;
1.8 +6 -6 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java
Index: DOMNodePointer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DOMNodePointer.java 8 Jun 2002 22:47:25 -0000 1.7
+++ DOMNodePointer.java 10 Aug 2002 16:13:04 -0000 1.8
@@ -293,7 +293,7 @@
return node;
}
- public Object getNodeValue(){
+ public Object getNode(){
return node;
}
@@ -624,7 +624,7 @@
return 1;
}
else if (t1 == Node.ATTRIBUTE_NODE && t2 == Node.ATTRIBUTE_NODE){
- NamedNodeMap map = ((Node)getNodeValue()).getAttributes();
+ NamedNodeMap map = ((Node)getNode()).getAttributes();
int length = map.getLength();
for (int i = 0; i < length; i++){
Node n = map.item(i);
1.5 +5 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/NamespacePointer.java
Index: NamespacePointer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/NamespacePointer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- NamespacePointer.java 29 May 2002 00:40:58 -0000 1.4
+++ NamespacePointer.java 10 Aug 2002 16:13:04 -0000 1.5
@@ -96,7 +96,7 @@
return null;
}
- public Object getNodeValue(){
+ public Object getNode(){
return getNamespaceURI();
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>