villard 2003/03/28 14:47:41
Modified: java/xpath_rwapi/src2/org/apache/xpath/impl Tag: xslt20
KindTestImpl.java NameTestImpl.java
StepExprImpl.java OperatorImpl.java ExprImpl.java
java/xpath_rwapi/src2/org/apache/xpath/expression Tag:
xslt20 StepExpr.java NodeTest.java
java/xpath_rwapi/src2/org/apache/xpath/impl/parser Tag:
xslt20 QNameWrapper.java
Log:
- add the method setNodeTest in StepExpr
- Implementation of step cloneage and step predicate removal
Revision Changes Path
No revision
No revision
1.1.2.3 +34 -29
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/KindTestImpl.java
Index: KindTestImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/KindTestImpl.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- KindTestImpl.java 27 Mar 2003 15:11:27 -0000 1.1.2.2
+++ KindTestImpl.java 28 Mar 2003 22:47:40 -0000 1.1.2.3
@@ -55,8 +55,9 @@
*/
package org.apache.xpath.impl;
+import org.apache.xml.QName;
+
import org.apache.xpath.XPathException;
-import org.apache.xpath.expression.Expr;
import org.apache.xpath.expression.NodeTest;
import org.apache.xpath.impl.parser.Node;
import org.apache.xpath.impl.parser.SimpleNode;
@@ -65,22 +66,28 @@
/**
- *
+ * Default implementation of XPath kind test.
*/
public class KindTestImpl extends SimpleNode implements NodeTest
{
+ //@TODO: define constants for each possible kind test
+
+ /**
+ * The type of kindtest
+ */
protected short m_kindTest;
/**
- * Creates an any kind test node
- */
+ * Creates an any kind test node. Internal uses only
+ */
public KindTestImpl()
{
super(XPathTreeConstants.JJTANYKINDTEST);
}
/**
- * Constructor for KindTestImpl.
+ * Constructor for KindTestImpl. Internal uses only
+ *
* @param i
*/
public KindTestImpl(int i)
@@ -91,7 +98,8 @@
}
/**
- * Constructor for KindTestImpl.
+ * Constructor for KindTestImpl. Internal uses only
+ *
* @param p
* @param i
*/
@@ -103,6 +111,18 @@
}
/**
+ * Constructor for cloning
+ *
+ * @param kt
+ */
+ public KindTestImpl(KindTestImpl kt)
+ {
+ super(kt.id);
+
+ m_kindTest = kt.m_kindTest;
+ }
+
+ /**
* @see org.apache.xpath.expression.NodeTest#isNameTest()
*/
public boolean isNameTest()
@@ -129,25 +149,9 @@
/**
* @see org.apache.xpath.expression.NodeTest#getLocalNameTest()
*/
- public String getLocalNameTest() throws XPathException
- {
- throw new XPathException("Invalid call this method on kind test");
// I8
- }
-
- /**
- * @see org.apache.xpath.expression.NodeTest#getPrefix()
- */
- public String getPrefix() throws XPathException
- {
- throw new XPathException("Invalid call this method on kind test");
// I8
- }
-
- /**
- * @see org.apache.xpath.expression.Expr#cloneExpression()
- */
- public Expr cloneExpression()
+ public QName getNameTest() throws XPathException
{
- return null; //TODO
+ throw new XPathException("Invalid call this method on kind test");
// I18N
}
/**
@@ -163,11 +167,11 @@
*/
public void jjtAddChild(Node n, int i)
{
-
}
/**
* Set the kindtest type from JJT id
+ *
* @param id
*/
private void setKindTestFromJJTID(int id)
@@ -206,6 +210,7 @@
/**
* Sets the kindTest.
+ *
* @param kindTest The kindTest to set
*/
public void setKindTest(short kindTest)
@@ -214,13 +219,13 @@
}
/**
- * Override to print out useful instance data.
+ * Override to print out useful instance data.
+ *
* @see org.apache.xpath.impl.parser.SimpleNode#toString()
*/
public String toString()
{
- return XPathTreeConstants.jjtNodeName[id] + " "
- + getClass() + " "
- + getString(true);
+ return XPathTreeConstants.jjtNodeName[id] + " " + getClass() + " "
+ + getString(true);
}
}
1.1.2.3 +8 -23
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/NameTestImpl.java
Index: NameTestImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/NameTestImpl.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- NameTestImpl.java 26 Mar 2003 21:27:22 -0000 1.1.2.2
+++ NameTestImpl.java 28 Mar 2003 22:47:40 -0000 1.1.2.3
@@ -65,7 +65,7 @@
/**
- *
+ * Default implementation of name test.
*/
public class NameTestImpl extends SimpleNode implements NodeTest
{
@@ -75,7 +75,7 @@
QName m_qname;
/**
- * Constructor for NameTestImpl.
+ * Constructor for NameTestImpl. Internal uses only
*
* @param i
*/
@@ -85,7 +85,7 @@
}
/**
- * Constructor for NodeTestImpl.
+ * Constructor for NodeTestImpl. Internal uses only
*
* @param namespace DOCUMENT ME!
* @param localpart DOCUMENT ME!
@@ -96,7 +96,7 @@
m_qname = new QName(namespace, localpart);
}
-
+
/**
* @see org.apache.xpath.expression.NodeTest#isNameTest()
*/
@@ -124,19 +124,11 @@
/**
* @see org.apache.xpath.expression.NodeTest#getLocalNameTest()
*/
- public String getLocalNameTest() throws XPathException
+ public QName getNameTest() throws XPathException
{
- return m_qname.getLocalPart();
+ return m_qname;
}
-
- /**
- * @see org.apache.xpath.expression.NodeTest#getPrefix()
- */
- public String getPrefix() throws XPathException
- {
- return m_qname.getPrefix();
- }
-
+
/**
* @see org.apache.xpath.expression.Expr#getString(boolean)
*/
@@ -145,14 +137,7 @@
return m_qname.toString();
}
- /**
- * @see org.apache.xpath.impl.parser.SimpleNode#canBeFiltered()
- */
- protected boolean canBeFiltered()
- {
- return false;
- }
-
+
/**
* @see org.apache.xpath.impl.parser.Node#jjtAddChild(Node, int)
*/
1.1.2.4 +25 -7
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/StepExprImpl.java
Index: StepExprImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/StepExprImpl.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- StepExprImpl.java 27 Mar 2003 21:53:24 -0000 1.1.2.3
+++ StepExprImpl.java 28 Mar 2003 22:47:40 -0000 1.1.2.4
@@ -93,16 +93,16 @@
short m_axisType = NO_AXIS_TYPE;
/**
- * Constructor for StepExprImpl.
+ * Constructor for StepExprImpl. Internal uses only
* @param i
*/
public StepExprImpl(int i)
{
- super(i);
+ super(i);
}
/**
- * Constructor for StepExprImpl.
+ * Constructor for StepExprImpl. Internal uses only
* @param p
* @param i
*/
@@ -112,7 +112,7 @@
}
/**
- * Constructor for StepExprImpl.
+ * Constructor for factory. Internal uses only
* @param axisType
* @param NodeTest
*/
@@ -131,7 +131,9 @@
*/
private StepExprImpl(StepExprImpl step)
{
+ super(XPathTreeConstants.JJTSTEPEXPR);
+ m_children = step.cloneChildren();
}
/**
@@ -161,7 +163,10 @@
/**
* @see org.apache.xpath.expression.StepExpr#removePredicate(Expr)
*/
- public void removePredicate(Expr predicate) {}
+ public void removePredicate(Expr predicate)
+ {
+ super.jjtRemoveChild((Node) predicate);
+ }
/**
* @see org.apache.xpath.expression.Visitable#visit(Visitor)
@@ -246,6 +251,18 @@
return (NodeTest) m_children[0];
}
+
+ /* (non-Javadoc)
+ * @see
org.apache.xpath.expression.StepExpr#setNodeTest(org.apache.xpath.expression.NodeTest)
+ */
+ public void setNodeTest(NodeTest test) throws XPathException {
+ if (m_axisType == STEP_IS_PRIMARYEXPR)
+ {
+ throw new XPathException("Invalid call of this
method on step compose of primary expression");
+ }
+ super.jjtAddChild((Node) test, 0);
+ }
+
/**
* @see org.apache.xpath.expression.StepExpr#getPrimaryExpr()
@@ -265,7 +282,7 @@
*/
public StepExpr cloneStep()
{
- return null;
+ return new StepExprImpl(this);
}
/**
@@ -281,7 +298,7 @@
*/
public Expr cloneExpression()
{
- return null;
+ return new StepExprImpl(this);
}
/**
@@ -465,4 +482,5 @@
+ getClass() + " "
+ ((m_axisType == STEP_IS_PRIMARYEXPR) ? "InvalidAxis" :
StepExprImpl.FULL_AXIS_NAME[m_axisType]);
}
+
}
1.1.2.3 +1 -14
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/OperatorImpl.java
Index: OperatorImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/OperatorImpl.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- OperatorImpl.java 27 Mar 2003 21:53:24 -0000 1.1.2.2
+++ OperatorImpl.java 28 Mar 2003 22:47:40 -0000 1.1.2.3
@@ -200,20 +200,7 @@
m_exprType = expr.m_exprType;
m_opType = expr.m_opType;
- // clone operands
- int count = getOperandCount();
-
- for (int i = 0; i < count; i++)
- {
- try
- {
- addOperand(getOperand(i).cloneExpression());
- }
- catch (XPathException e)
- {
- // never
- }
- }
+ m_children = expr.cloneChildren();
}
/**
1.1.2.3 +69 -39
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/ExprImpl.java
Index: ExprImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/ExprImpl.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- ExprImpl.java 27 Mar 2003 21:53:24 -0000 1.1.2.2
+++ ExprImpl.java 28 Mar 2003 22:47:40 -0000 1.1.2.3
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -17,7 +17,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -25,7 +25,7 @@
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
@@ -55,61 +55,91 @@
*/
package org.apache.xpath.impl;
+import org.apache.xpath.XPathException;
import org.apache.xpath.expression.Expr;
import org.apache.xpath.expression.Visitor;
+import org.apache.xpath.impl.parser.Node;
import org.apache.xpath.impl.parser.SimpleNode;
import org.apache.xpath.impl.parser.XPath;
+
/**
*
*/
-public abstract class ExprImpl extends SimpleNode implements Expr{
+public abstract class ExprImpl extends SimpleNode implements Expr
+{
+ /**
+ *
+ */
+ protected ExprImpl()
+ {
+ super();
+ }
- /**
- *
- */
- protected ExprImpl() {
- super();
- }
-
- /**
- * Constructor for ExprImpl.
- * @param i
- */
- public ExprImpl(int i) {
- super(i);
- }
-
- /**
- * Constructor for ExprImpl.
- * @param p
- * @param i
- */
- public ExprImpl(XPath p, int i) {
- super(p, i);
- }
-
/**
- * Gets expression as external string representation
+ * Constructor for ExprImpl.
+ *
+ * @param i
*/
- public void getString(StringBuffer expr, boolean abbreviate) {
+ public ExprImpl(int i)
+ {
+ super(i);
}
+ /**
+ * Constructor for ExprImpl.
+ *
+ * @param p
+ * @param i
+ */
+ public ExprImpl(XPath p, int i)
+ {
+ super(p, i);
+ }
- /**
+ /**
+ * Gets expression as external string representation
+ *
+ * @param expr DOCUMENT ME!
+ * @param abbreviate DOCUMENT ME!
+ */
+ public void getString(StringBuffer expr, boolean abbreviate)
+ {
+ }
+
+ /**
* @see org.apache.xpath.expression.Expr#getString(boolean)
*/
- public String getString(boolean abbreviate) {
+ public String getString(boolean abbreviate)
+ {
StringBuffer buf = new StringBuffer();
getString(buf, abbreviate);
+
return buf.toString();
}
- /**
- * @see org.apache.xpath.expression.Visitable#visit(Visitor)
- */
- public boolean visit(Visitor visitor) {
- return true;
- }
+ /**
+ * @see org.apache.xpath.expression.Visitable#visit(Visitor)
+ */
+ public boolean visit(Visitor visitor)
+ {
+ return true;
+ }
+
+ /**
+ * Clone children
+ *
+ * @return DOCUMENT ME!
+ */
+ protected Node[] cloneChildren()
+ {
+ Node[] clone = new Node[m_children.length];
+
+ for (int i = 0; i < m_children.length; i++)
+ {
+ clone[i] = (Node) ((Expr) m_children[i]).cloneExpression();
+ }
+ return clone;
+ }
}
No revision
No revision
1.1.2.3 +10 -0
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/StepExpr.java
Index: StepExpr.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/StepExpr.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- StepExpr.java 27 Mar 2003 15:11:27 -0000 1.1.2.2
+++ StepExpr.java 28 Mar 2003 22:47:41 -0000 1.1.2.3
@@ -206,6 +206,16 @@
* step.
*/
NodeTest getNodeTest() throws XPathException;
+
+ /**
+ * Sets the node test
+ *
+ * @param NodeTest
+ * @throws XPathException whenever the step is not a forward or reverse
+ * step.
+ */
+ void setNodeTest(NodeTest test) throws XPathException;
+
/**
* Gets the step as a primary expression.
1.1.2.2 +6 -10
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/NodeTest.java
Index: NodeTest.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/NodeTest.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- NodeTest.java 13 Mar 2003 20:28:17 -0000 1.1.2.1
+++ NodeTest.java 28 Mar 2003 22:47:41 -0000 1.1.2.2
@@ -55,6 +55,7 @@
*/
package org.apache.xpath.expression;
+import org.apache.xml.QName;
import org.apache.xpath.XPathException;
/**
@@ -81,7 +82,7 @@
/**
* The node test is a wildcard
*/
- static final String WILDCARD = "*";
+ static final QName WILDCARD = new QName("*");
/**
* The item test is a processing instruction kind test
@@ -110,7 +111,7 @@
/**
* Full name of kind tests.
- * This array is kept in synchronization with kind test constants
+ * This array is synchronized with kind test constants
*/
static final String[] KIND_TEST_NAME = { "processing-instruction()",
"comment()", "node()", "text()", "." };
@@ -135,17 +136,12 @@
/**
* Gets the local part of the name test
- * @return String The local part of the name test or [EMAIL PROTECTED]
#WILDCARD}
+ * @return QName The name test or [EMAIL PROTECTED] #WILDCARD}
* @throws XPathException whenever this node test isn't name test
*/
- String getLocalNameTest() throws XPathException;
+ QName getNameTest() throws XPathException;
- /**
- * Gets the prefix of the name test
- * @return String The prefix part of the name test or [EMAIL PROTECTED]
#WILDCARD}
- * @throws XPathException whenever this node test isn't a name test
- */
- String getPrefix() throws XPathException;
+
}
No revision
No revision
1.1.2.3 +2 -2
xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/parser/Attic/QNameWrapper.java
Index: QNameWrapper.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/parser/Attic/QNameWrapper.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- QNameWrapper.java 27 Mar 2003 21:53:25 -0000 1.1.2.2
+++ QNameWrapper.java 28 Mar 2003 22:47:41 -0000 1.1.2.3
@@ -94,12 +94,12 @@
String qname;
switch (id) {
case XPathTreeConstants.JJTSTAR :
- m_qname = new QName(NodeTest.WILDCARD);
+ m_qname = NodeTest.WILDCARD;
break;
case XPathTreeConstants.JJTSTARCOLONNCNAME :
qname = t.image.trim();
qname = qname.substring(qname.indexOf(":")+1);
- m_qname = new QName(NodeTest.WILDCARD, qname,
NodeTest.WILDCARD);
+ m_qname = new QName("*", qname, "*");
break;
case XPathTreeConstants.JJTNCNAMECOLONSTAR :
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]