You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by vi...@apache.org on 2003/08/11 16:45:54 UTC
cvs commit: xml-xalan/java/xpath_rwapi/src2/org/apache/xpath XPath20Utilities.java
villard 2003/08/11 07:45:54
Modified: java/xpath_rwapi/src2/org/apache/xpath/impl Tag: xslt20
PathExprImpl.java NameTestImpl.java
KindTestImpl.java StepExprImpl.java
java/xpath_rwapi/src2/org/apache/xpath/impl/parser Tag:
xslt20 DefaultNodeFactory.java NodeFactory.java
Axis.java SimpleNode.java QNameWrapper.java
java/xpath_rwapi/src2/org/apache/xpath/expression Tag:
xslt20 CastableAsExpr.java NodeTest.java
CastOrTreatAsExpr.java package.html Variable.java
PathExpr.java StepExpr.java Expr.java Literal.java
java/xpath_rwapi/src2/org/apache/xpath Tag: xslt20
XPath20Utilities.java
Added: java/xpath_rwapi/src2/org/apache/xpath/expression Tag:
xslt20 Leaver.java KindTest.java NameTest.java
Log:
- Added KindTest interface that allows in particular the representation of element and attribute tests
- Added a "leaver" which is similar to a visitor but send callback after all children of a node were sent
- javadoc...
Revision Changes Path
No revision
No revision
1.1.2.5 +1 -1 xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/PathExprImpl.java
Index: PathExprImpl.java
===================================================================
RCS file: /home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/Attic/PathExprImpl.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- PathExprImpl.java 31 Jul 2003 02:29:28 -0000 1.1.2.4
+++ PathExprImpl.java 11 Aug 2003 14:45:53 -0000 1.1.2.5
@@ -206,7 +206,7 @@
int et = step.getExprType();
return (
- ((et == STEP) && ((StepExpr) step).isPrimaryExpr())
+ ((et == STEP) && ((StepExpr) step).isFilterStep())
|| (et == LITERAL_EXPR)
|| (et == FUNCTION_CALL_EXPR)
|| (et == SEQUENCE_EXPR)
1.1.2.6 +160 -97 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.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- NameTestImpl.java 30 Jul 2003 18:52:58 -0000 1.1.2.5
+++ NameTestImpl.java 11 Aug 2003 14:45:53 -0000 1.1.2.6
@@ -56,111 +56,174 @@
package org.apache.xpath.impl;
import org.apache.xml.QName;
-
import org.apache.xpath.XPath20Exception;
+import org.apache.xpath.expression.Expr;
+import org.apache.xpath.expression.NameTest;
import org.apache.xpath.expression.NodeTest;
+import org.apache.xpath.expression.Visitor;
import org.apache.xpath.impl.parser.Node;
+import org.apache.xpath.impl.parser.QNameWrapper;
import org.apache.xpath.impl.parser.SimpleNode;
import org.apache.xpath.impl.parser.XPathTreeConstants;
-
/**
* Default implementation of name test.
*/
-public class NameTestImpl extends SimpleNode implements NodeTest
+public class NameTestImpl extends SimpleNode implements NodeTest, NameTest
{
- /**
- * Name test
- */
- QName m_qname;
-
- /**
- * Constructor for NameTestImpl. Internal uses only
- *
- * @param i
- */
- public NameTestImpl(int i)
- {
- super(i);
- }
-
- /**
- * Constructor for NodeTestImpl. Internal uses only
- */
- public NameTestImpl(QName qname)
- {
- super(XPathTreeConstants.JJTNAMETEST);
-
- m_qname = qname;
- }
-
- /**
- * @see org.apache.xpath.expression.NodeTest#isNameTest()
- */
- public boolean isNameTest()
- {
- return true;
- }
-
- /**
- * @see org.apache.xpath.expression.NodeTest#isKindTest()
- */
- public boolean isKindTest()
- {
- return false;
- }
-
- /**
- * @see org.apache.xpath.expression.NodeTest#getKindTest()
- */
- public short getKindTest() throws XPath20Exception
- {
- throw new XPath20Exception("Invalid call of this method on NameTest node"); //I8
- }
-
- /**
- * @see org.apache.xpath.expression.NodeTest#getLocalNameTest()
- */
- public QName getNameTest() throws XPath20Exception
- {
- return m_qname;
- }
-
- /**
- * @see org.apache.xpath.expression.Expr#getString(boolean)
- */
- public String getString(boolean abbreviate)
- {
- return m_qname.toString();
- }
-
-
- /**
- * @see org.apache.xpath.impl.parser.Node#jjtAddChild(Node, int)
- */
- public void jjtAddChild(Node n, int i)
- {
- // don't add n in the tree
- m_qname = ((org.apache.xpath.impl.parser.QNameWrapper) n).getQName();
- }
-
- /**
- * @see org.apache.xpath.impl.ExprImpl#getString(StringBuffer,
- * boolean)
- */
- public void getString(StringBuffer expr, boolean abbreviate)
- {
- expr.append(m_qname.toString());
- }
-
- /**
- * Override to print out useful instance data.
- *
- * @see org.apache.xpath.impl.parser.SimpleNode#toString()
- */
- public String toString()
- {
- return XPathTreeConstants.jjtNodeName[id] + " " + getClass() + " "
- + getString(false);
- }
+ /**
+ * Name test
+ */
+ QName m_qname;
+
+ /**
+ * NCName
+ */
+ String m_ncname;
+
+ /**
+ * Nametest type
+ */
+ short m_type;
+
+ // Constructors
+
+ /**
+ * Constructor for NameTestImpl. Internal uses only
+ *
+ * @param i
+ */
+ public NameTestImpl(int i)
+ {
+ super(i);
+ }
+
+ /**
+ * Constructor for NodeTestImpl. Internal uses only
+ */
+ public NameTestImpl(QName qname)
+ {
+ super(XPathTreeConstants.JJTNAMETEST);
+
+ m_qname = qname;
+ m_type = QNAME;
+ }
+
+ /**
+ * @see org.apache.xpath.expression.NodeTest#isNameTest()
+ */
+ public boolean isNameTest()
+ {
+ return true;
+ }
+
+ /**
+ * @see org.apache.xpath.expression.NodeTest#isKindTest()
+ */
+ public boolean isKindTest()
+ {
+ return false;
+ }
+
+ /**
+ * @see org.apache.xpath.expression.NodeTest#getKindTest()
+ */
+ public short getKindTest() throws XPath20Exception
+ {
+ throw new XPath20Exception("Invalid call of this method on NameTest node");
+ //I8
+ }
+
+ /**
+ * @see org.apache.xpath.expression.NodeTest#getLocalNameTest()
+ */
+ public NameTest getNameTest() throws XPath20Exception
+ {
+ return this;
+ }
+
+ // Implements Expr
+
+ public String getString(boolean abbreviate)
+ {
+ switch (m_type)
+ {
+ case WILDCARD :
+ return "*";
+ case QNAME :
+ return m_qname.toString();
+ case NCNAME_WILDCARD :
+ return m_ncname + ":*";
+ case WILDCARD_NCNAME :
+ return "*:" + m_ncname;
+ default:
+ throw new IllegalStateException("Invalid NameTest type " + m_type);
+ }
+ }
+
+ //
+ public Expr cloneExpression()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public short getExprType()
+ {
+ return NODE_TEST;
+ }
+
+ //
+ public boolean visit(Visitor visitor)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void jjtAddChild(Node n, int i)
+ {
+ QNameWrapper w = (QNameWrapper) n;
+
+ m_type = w.m_type;
+ m_ncname = w.m_ncname;
+ m_qname = w.getQName();
+ }
+
+ public void getString(StringBuffer expr, boolean abbreviate)
+ {
+ expr.append(getString(abbreviate));
+ }
+
+ /**
+ * Override to print out useful instance data.
+ *
+ * @see org.apache.xpath.impl.parser.SimpleNode#toString()
+ */
+ public String toString()
+ {
+ return XPathTreeConstants.jjtNodeName[id]
+ + " "
+ + getClass()
+ + " "
+ + getString(false);
+ }
+
+ // Implements NameTest
+
+ public QName getName()
+ {
+ return m_qname;
+ }
+
+ public String getNCName()
+ {
+ return m_ncname;
+ }
+
+ public short getNameTestType()
+ {
+ return m_type;
+ }
+
+
}
1.1.2.6 +24 -7 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.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- KindTestImpl.java 30 Jul 2003 18:52:58 -0000 1.1.2.5
+++ KindTestImpl.java 11 Aug 2003 14:45:53 -0000 1.1.2.6
@@ -55,10 +55,11 @@
*/
package org.apache.xpath.impl;
-import org.apache.xml.QName;
-
import org.apache.xpath.XPath20Exception;
+import org.apache.xpath.expression.Expr;
+import org.apache.xpath.expression.NameTest;
import org.apache.xpath.expression.NodeTest;
+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;
@@ -80,7 +81,7 @@
/**
* PI target
*/
- protected QName m_pitarget;
+ protected NameTestImpl m_pitarget;
/**
* Creates an any kind test node. Internal uses only
@@ -154,7 +155,7 @@
/**
* @see org.apache.xpath.expression.NodeTest#getLocalNameTest()
*/
- public QName getNameTest() throws XPath20Exception
+ public NameTest getNameTest() throws XPath20Exception
{
if (m_kindTest == PROCESSING_INSTRUCTION_TEST)
{
@@ -166,13 +167,29 @@
}
}
- /**
- * @see org.apache.xpath.expression.Expr#getString(boolean)
- */
+ // Implements Expr
+
public String getString(boolean abbreviate)
{
return KIND_TEST_NAME[m_kindTest];
}
+
+ public Expr cloneExpression()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public short getExprType()
+ {
+ return Expr.NODE_TEST;
+ }
+
+ public boolean visit(Visitor visitor)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
/**
* @see org.apache.xpath.impl.parser.Node#jjtAddChild(Node, int)
1.1.2.9 +1 -1 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.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- StepExprImpl.java 30 Jul 2003 18:52:58 -0000 1.1.2.8
+++ StepExprImpl.java 11 Aug 2003 14:45:53 -0000 1.1.2.9
@@ -194,7 +194,7 @@
/**
* @see org.apache.xpath.expression.StepExpr#isPrimaryExpr()
*/
- public boolean isPrimaryExpr()
+ public boolean isFilterStep()
{
return m_axisType == STEP_IS_PRIMARYEXPR;
}
No revision
No revision
1.1.2.6 +1 -3 xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/parser/Attic/DefaultNodeFactory.java
Index: DefaultNodeFactory.java
===================================================================
RCS file: /home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/parser/Attic/DefaultNodeFactory.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- DefaultNodeFactory.java 31 Jul 2003 15:56:29 -0000 1.1.2.5
+++ DefaultNodeFactory.java 11 Aug 2003 14:45:53 -0000 1.1.2.6
@@ -81,8 +81,6 @@
public class DefaultNodeFactory implements NodeFactory
{
- final static public String FACTORY_PROPERTY_KEY = "org.apache.xpath.impl.parser.NodeFactory";
-
final static private NodeFactory DEFAULT_NODE_FACTORY = new DefaultNodeFactory();
static protected NodeFactory createNodeFactory()
1.1.2.6 +4 -0 xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/parser/Attic/NodeFactory.java
Index: NodeFactory.java
===================================================================
RCS file: /home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/parser/Attic/NodeFactory.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- NodeFactory.java 31 Jul 2003 15:56:29 -0000 1.1.2.5
+++ NodeFactory.java 11 Aug 2003 14:45:53 -0000 1.1.2.6
@@ -75,6 +75,10 @@
*/
public interface NodeFactory
{
+ final static public String FACTORY_PROPERTY_KEY = "org.apache.xpath.impl.parser.NodeFactory";
+
+
+
/**
* Creates NameTest AST node
*
1.1.2.2 +1 -1 xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/parser/Attic/Axis.java
Index: Axis.java
===================================================================
RCS file: /home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/parser/Attic/Axis.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- Axis.java 13 Mar 2003 20:28:16 -0000 1.1.2.1
+++ Axis.java 11 Aug 2003 14:45:53 -0000 1.1.2.2
@@ -58,7 +58,7 @@
import org.apache.xpath.expression.StepExpr;
/**
- * Represent an Axis AST node.
+ * Represents an Axis AST node.
*/
public class Axis extends SimpleNode {
1.1.2.16 +6 -6 xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/parser/Attic/SimpleNode.java
Index: SimpleNode.java
===================================================================
RCS file: /home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/impl/parser/Attic/SimpleNode.java,v
retrieving revision 1.1.2.15
retrieving revision 1.1.2.16
diff -u -r1.1.2.15 -r1.1.2.16
--- SimpleNode.java 31 Jul 2003 15:56:29 -0000 1.1.2.15
+++ SimpleNode.java 11 Aug 2003 14:45:53 -0000 1.1.2.16
@@ -243,15 +243,15 @@
break;
// The nodes belows are filtered: no customisation possible
- case XPathTreeConstants.JJTQNAME:
- case XPathTreeConstants.JJTQNAMELPAR:
+
case XPathTreeConstants.JJTSTAR:
case XPathTreeConstants.JJTNCNAMECOLONSTAR:
case XPathTreeConstants.JJTSTARCOLONNCNAME:
- newNode = new QNameWrapper(id);
-
- break;
-
+ case XPathTreeConstants.JJTQNAME:
+ case XPathTreeConstants.JJTQNAMELPAR:
+ newNode = new QNameWrapper(id);
+ break;
+
case XPathTreeConstants.JJTDOTDOT:
newNode = Singletons.DOTDOT;
1.1.2.6 +20 -23 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.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- QNameWrapper.java 31 Jul 2003 02:29:28 -0000 1.1.2.5
+++ QNameWrapper.java 11 Aug 2003 14:45:53 -0000 1.1.2.6
@@ -56,6 +56,7 @@
package org.apache.xpath.impl.parser;
import org.apache.xml.QName;
+import org.apache.xpath.expression.NameTest;
/**
* QNameNode wrappers a 'real' QName object.
@@ -69,6 +70,9 @@
* The wrapped QName
*/
QName m_qname;
+
+ public short m_type;
+ public String m_ncname;
/**
* Constructor for QName.
@@ -89,36 +93,31 @@
super(p, i);
}
- /**
- * @see org.apache.xpath.impl.parser.SimpleNode#processToken(Token)
- */
public void processToken(Token t)
{
super.processToken(t);
- String qname;
+
switch (id)
{
case XPathTreeConstants.JJTSTAR :
- m_qname =
- SimpleNode.getExpressionFactory().createQName(
- null,
- "*",
- null);
+ m_type = NameTest.WILDCARD;
break;
case XPathTreeConstants.JJTSTARCOLONNCNAME :
- qname = t.image.trim();
- qname = qname.substring(qname.indexOf(":") + 1);
- m_qname =
- SimpleNode.getExpressionFactory().createQName(
- null,
- qname,
- "*");
+ m_ncname = t.image.trim();
+ m_ncname = m_ncname.substring(m_ncname.indexOf(":") + 1);
+ m_type = NameTest.WILDCARD_NCNAME;
break;
case XPathTreeConstants.JJTNCNAMECOLONSTAR :
+ m_ncname = t.image.trim();
+ m_ncname = m_ncname.substring(0, m_ncname.indexOf(":"));
+ m_type = NameTest.NCNAME_WILDCARD;
+
+ break;
+
case XPathTreeConstants.JJTQNAME :
case XPathTreeConstants.JJTQNAMELPAR :
- qname = t.image;
+ String qname = t.image;
int parenIndex = qname.lastIndexOf("(");
if (parenIndex > 0)
{
@@ -133,8 +132,7 @@
null,
qname,
null);
- }
- else
+ } else
{
m_qname =
SimpleNode.getExpressionFactory().createQName(
@@ -142,6 +140,7 @@
qname.substring(colonIdx + 1),
qname.substring(0, colonIdx));
}
+ m_type = NameTest.QNAME;
break;
default :
@@ -150,9 +149,7 @@
}
}
- /**
- * @return org.apache.xml.QName
- */
+
public org.apache.xml.QName getQName()
{
return m_qname;
No revision
No revision
1.1.2.2 +1 -1 xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/CastableAsExpr.java
Index: CastableAsExpr.java
===================================================================
RCS file: /home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/CastableAsExpr.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- CastableAsExpr.java 26 Mar 2003 21:27:20 -0000 1.1.2.1
+++ CastableAsExpr.java 11 Aug 2003 14:45:53 -0000 1.1.2.2
@@ -58,7 +58,7 @@
import org.apache.xpath.datamodel.SequenceType;
/**
- * Represent "castable as" expression.
+ * Represent <em>castable as</em> expressions.
* @see <a href="http://www.w3.org/TR/xpath20/#id-castable">
* XPath 2.0 specification</a>
*/
1.1.2.6 +28 -12 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.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- NodeTest.java 31 Jul 2003 02:29:29 -0000 1.1.2.5
+++ NodeTest.java 11 Aug 2003 14:45:53 -0000 1.1.2.6
@@ -55,12 +55,11 @@
*/
package org.apache.xpath.expression;
-import org.apache.xml.QName;
import org.apache.xpath.XPath20Exception;
/**
- * Represents an item test. An item test includes both node tests
- * and the context item test (dot).
+ * Represents an <em>item test</em>. An item test includes both node tests
+ * and the context item test (the character '.').
* <p>
* A node test is either a name test or a kind test. For the former, use
* the method {@link #getNameTest()} to get the {@link QName} involved in the test.
@@ -79,38 +78,53 @@
* @see <a href="http://www.w3.org/TR/xpath20/#doc-NodeTest">Node test specification</a>
* @see <a href="http://www.w3.org/TR/xpath20/#abbrev">Context item specification</a>
*/
-public interface NodeTest {
+public interface NodeTest extends Expr {
/**
- * The item test is a processing instruction kind test
+ * Processing instruction test (kind test)
*/
static final short PROCESSING_INSTRUCTION_TEST = 0;
/**
- * The item test is a comment kind test
+ * Comment test (kind test)
*/
static final short COMMENT_TEST = 1;
/**
- * The item test is any kind of test (except context item test)
+ * Any kind test (except context item test)
*/
static final short ANY_KIND_TEST = 2;
/**
- * The item test is a text kind test
+ * Text test (kind test)
*/
static final short TEXT_TEST = 3;
/**
+ * Document test (kind test)
+ */
+ static final short DOCUMENT_TEST = 4;
+
+ /**
+ * Element test (kind test)
+ */
+ static final short ELEMENT_TEST = 5;
+
+ /**
+ * Attribute test (kind test)
+ */
+ static final short ATTRIBUTE_TEST = 6;
+
+ /**
* The node test is a context item test (belong to the kind test group)
*/
- static final short CONTEXT_ITEM_TEST = 4;
+ static final short CONTEXT_ITEM_TEST = 7;
/**
- * Full name of kind tests.
+ * Full name of simple kind tests (whithout parameters).
* This array is synchronized with the kind test constants
*/
- static final String[] KIND_TEST_NAME = { "processing-instruction()", "comment()", "node()", "text()", "." };
+ static final String[] KIND_TEST_NAME = { "processing-instruction()", "comment()", "node()", "text()", "document-node()", "element()", "attribute()", "." };
/**
* Return true whenever this node test is a name test
@@ -128,6 +142,7 @@
* Gets the kind test code.
* @return short One of the kind test constant value
* @throws XPath20Exception whenever this node test isn't a kind test
+ * @deprecated cast to KindTest
*/
short getKindTest() throws XPath20Exception;
@@ -138,8 +153,9 @@
* @return QName The name test
* @throws XPath20Exception whenever this node test isn't a name test
* or a pi kind test
+ * @deprecated cast to NameTest
*/
- QName getNameTest() throws XPath20Exception;
+ NameTest getNameTest() throws XPath20Exception;
}
1.1.2.2 +3 -3 xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/CastOrTreatAsExpr.java
Index: CastOrTreatAsExpr.java
===================================================================
RCS file: /home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/CastOrTreatAsExpr.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- CastOrTreatAsExpr.java 26 Mar 2003 03:42:56 -0000 1.1.2.1
+++ CastOrTreatAsExpr.java 11 Aug 2003 14:45:53 -0000 1.1.2.2
@@ -58,9 +58,9 @@
import org.apache.xpath.datamodel.SequenceType;
/**
- * Represents "cast as" and 'treat as' expression.
- * Use the method <code>getExprType()</code> to differentiate treat as and cast as
- * expressions.
+ * Represents <em>cast as</em> and <em>treat as</em> expression.
+ * Use the method {@link #getExprType()} to differentiate
+ * <em>treat as</em> from <em>cast as</em> expressions.
* @see <a href="http://www.w3.org/TR/xpath20/#id-cast">
* XPath 2.0 specification</a>
*/
1.1.2.5 +18 -13 xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/package.html
Index: package.html
===================================================================
RCS file: /home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/package.html,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- package.html 31 Jul 2003 03:03:30 -0000 1.1.2.4
+++ package.html 11 Aug 2003 14:45:53 -0000 1.1.2.5
@@ -6,21 +6,25 @@
<body>
<p>Public interfaces for XPath expression Abstract Syntax Tree nodes.
Primary external APIs for this XPath AST model.</p>
-<p>This XPath API is a compact set of Java interfaces that allow to
-encode and handle XPath 2.0/XQuery 1.0 expressions (although only XPath
-2.0 expressions are currently supported except for the let expression).
-It was designed to fulfill
+<p>This XPath API is a compact set of Java interfaces that allow the
+in-memory representation and manipulation of XPath 2.0 expressions.The
+main idea of this API is to manipulate XPath expressions independently
+of their actual underlying representation.<br>
+</p>
+<p>It was designed to fulfill
the following requirements:</p>
<ul>
<li style="font-weight: bold;">Read/Write: <span
- style="font-weight: normal;">capability of visiting and modifying the
-internal representation of expressions. The expression reading is
+ style="font-weight: normal;">it should be capable of querying/visiting
+and modifying the
+internal representation of XPath expressions. The expression reading is
performed by using either the visitor pattern or get-like methods.
Similarly, the</span><span style="font-weight: normal;"> expression </span><span
style="font-weight: normal;">writing is done through a bunch of
set-like methods.</span></li>
<li style="font-weight: bold;"><span style="font-weight: normal;"><span
- style="font-weight: bold;">Round-trip: </span>capability of getting
+ style="font-weight: bold;">Round-trip: </span>it should be capable of
+getting
string representation of expressions from its internal encoding.<br>
</span></li>
<li><span style="font-weight: bold;">Application-independent</span>:
@@ -30,14 +34,15 @@
namespace/qname manager and AST generalization and specialisation (see
implementation package).<span style="font-weight: bold;"><br>
</span></li>
- <li style="font-weight: bold;">Compactness: <span
- style="font-weight: normal;">keep the interface set as minimal as
-possible by factoring similar concepts. The best example is the
-interface OperatorExpr which allows to represent more than ten
+ <li style="font-weight: bold;">Lightweight: <span
+ style="font-weight: normal;">it should be compact and therefore should
+define a minimal set of Java interfaces in particular by factoring
+similar concepts. The best example is the
+interface OperatorExpr which allows the representation of more than ten
expression types.</span></li>
</ul>
-Right now, the XPath API do not provide a standard way to evaluate
-expressions. This should be done.<br>
+Right now, the XPath API do not provide a standard way to request the
+evaluation of expressions. This should be done.<br>
<p></p>
</body>
</html>
1.1.2.5 +11 -8 xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/Variable.java
Index: Variable.java
===================================================================
RCS file: /home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/Variable.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- Variable.java 30 Jul 2003 18:52:58 -0000 1.1.2.4
+++ Variable.java 11 Aug 2003 14:45:53 -0000 1.1.2.5
@@ -59,16 +59,19 @@
import org.apache.xpath.XPath20Exception;
/**
- * Represents variable.
+ * Represents <em>variable</em> references.
+ * @author <a href="mailto:villard@us.ibm.com">Lionel Villard</a>
+ * @version $Id$
*/
-public interface Variable extends Expr {
+public interface Variable extends Expr
+{
+
+ /**
+ * Gets the name of the variable.
+ * @return String
+ */
+ QName getVariableName();
- /**
- * Gets the name of the variable.
- * @return String
- */
- QName getVariableName();
-
/**
* Sets the name of the variable.
* @param name New name of the variable
1.1.2.3 +2 -2 xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/PathExpr.java
Index: PathExpr.java
===================================================================
RCS file: /home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/PathExpr.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- PathExpr.java 11 Jul 2003 21:29:26 -0000 1.1.2.2
+++ PathExpr.java 11 Aug 2003 14:45:53 -0000 1.1.2.3
@@ -56,8 +56,8 @@
package org.apache.xpath.expression;
/**
- * Represents <em>path</em> expression. <quote>It can be used to locate nodes within a tree.</quote>
- * <p>A path expression consists of a series of {@link StepExpr}.
+ * Represents <em>path</em> expressions. <quote>It can be used to locate nodes within a tree.</quote>
+ * <p>A path expression consists of a sequence of {@link StepExpr}.
* It's a {@link OperatorExpr operator-based} expression
* with {@link OperatorExpr#SLASH_STEP} as the operator separator
* and {@link Expr#PATH_EXPR} as the operator type.
1.1.2.6 +189 -172 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.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- StepExpr.java 30 Jul 2003 18:52:58 -0000 1.1.2.5
+++ StepExpr.java 11 Aug 2003 14:45:53 -0000 1.1.2.6
@@ -57,189 +57,206 @@
import org.apache.xpath.XPath20Exception;
-
/**
- * Represents a step.
- * <quote>A step generates a sequence of items and then filters the sequence
- * by zero or more predicates.</quote>
+ * Represents <em>step</em> expressions.
+ * A step is either a <em>axis step</em> or an <em>filter step</em>.
* @see <a href="http://www.w3.org/TR/xpath20/#id-axis-steps">XPath 2.0
* specification</a>
+ * @author <a href="mailto:villard@us.ibm.com">Lionel Villard</a>
+ * @version $Id$
*/
public interface StepExpr extends Expr
{
- /**
- * Full name of axis. This array is kept in synchronization with axis
- * constants.
- */
- static final String[] FULL_AXIS_NAME =
- {
- "", "child", "descendant",
- "parent", "attribute", "self",
- "descendant-or-self", "ancestor",
- "following-sibling",
- "preceding-sibling", "following",
- "preceding", "namespace",
- "ancestor-or-self"
- };
-
- /**
- * The step axis is child
- */
- static final short AXIS_CHILD = 1;
-
- /**
- * The step axis is descendant
- */
- static final short AXIS_DESCENDANT = 2;
-
- /**
- * The step axis is parent
- */
- static final short AXIS_PARENT = 3;
-
- /**
- * The step axis is attribute
- */
- static final short AXIS_ATTRIBUTE = 4;
-
- /**
- * The step axis is self
- */
- static final short AXIS_SELF = 5;
-
- /**
- * The step axis is descendant or self
- */
- static final short AXIS_DESCENDANT_OR_SELF = 6;
-
- /**
- * The step axis is ancestor
- */
- static final short AXIS_ANCESTOR = 7;
-
- /**
- * The step axis is following sibling
- */
- static final short AXIS_FOLLOWING_SIBLING = 8;
-
- /**
- * The step axis is preceding sibling
- */
- static final short AXIS_PRECEDING_SIBLING = 9;
-
- /**
- * The step axis is following
- */
- static final short AXIS_FOLLOWING = 10;
-
- /**
- * The step axis is preceding
- */
- static final short AXIS_PRECEDING = 11;
-
- /**
- * The step axis is namespace
- */
- static final short AXIS_NAMESPACE = 12;
-
- /**
- * The step axis is ancestor or self
- */
- static final short AXIS_ANCESTOR_OR_SELF = 13;
-
- /**
- * Tells whether or not this step is a foward axis step
- * @return boolean
- */
- boolean isForwardStep();
-
- /**
- * Tells whether or not this step is a reversed axis step
- * @return boolean
- */
- boolean isReversedStep();
-
- /**
- * Tells whether or not this step is a filter step.
- * @return boolean
- */
- boolean isPrimaryExpr();
-
- /**
- * Gets the type of step axis
- *
- * @return short The axis type corresponding to one of the constants defined above.
- * @throws XPath20Exception whenever the step is neither a forward step nor a reverse
- * step.
- */
- short getAxisType() throws XPath20Exception;
-
- /**
- * Sets the type of the step axis
- * @param newType The new axis type
- * @throws XPath20Exception whenever the step is not a forward or reverse
- * step.
- */
- void setAxisType(short newType) throws XPath20Exception;
-
- /**
- * Gets the name of the step axis
- *
- * @return String Full name of the step axis
- * @throws XPath20Exception whenever the step is not a forward or reverse
- * step.
- */
- String getAxisName() throws XPath20Exception;
-
- /**
- * Gets the node test
- *
- * @return NodeTest
- * @throws XPath20Exception whenever the step is not a forward or reverse
- * step.
- */
- NodeTest getNodeTest() throws XPath20Exception;
-
+ /**
+ * Full name of axis. This array is kept in synchronization with axis
+ * constants.
+ */
+ static final String[] FULL_AXIS_NAME =
+ {
+ "",
+ "child",
+ "descendant",
+ "parent",
+ "attribute",
+ "self",
+ "descendant-or-self",
+ "ancestor",
+ "following-sibling",
+ "preceding-sibling",
+ "following",
+ "preceding",
+ "namespace",
+ "ancestor-or-self" };
+
+ /**
+ * The step axis is child
+ */
+ static final short AXIS_CHILD = 1;
+
+ /**
+ * The step axis is descendant
+ */
+ static final short AXIS_DESCENDANT = 2;
+
+ /**
+ * The step axis is parent
+ */
+ static final short AXIS_PARENT = 3;
+
+ /**
+ * The step axis is attribute
+ */
+ static final short AXIS_ATTRIBUTE = 4;
+
+ /**
+ * The step axis is self
+ */
+ static final short AXIS_SELF = 5;
+
+ /**
+ * The step axis is descendant or self
+ */
+ static final short AXIS_DESCENDANT_OR_SELF = 6;
+
+ /**
+ * The step axis is ancestor
+ */
+ static final short AXIS_ANCESTOR = 7;
+
+ /**
+ * The step axis is following sibling
+ */
+ static final short AXIS_FOLLOWING_SIBLING = 8;
+
+ /**
+ * The step axis is preceding sibling
+ */
+ static final short AXIS_PRECEDING_SIBLING = 9;
+
+ /**
+ * The step axis is following
+ */
+ static final short AXIS_FOLLOWING = 10;
+
+ /**
+ * The step axis is preceding
+ */
+ static final short AXIS_PRECEDING = 11;
+
+ /**
+ * The step axis is namespace
+ */
+ static final short AXIS_NAMESPACE = 12;
+
+ /**
+ * The step axis is ancestor or self
+ */
+ static final short AXIS_ANCESTOR_OR_SELF = 13;
+
+ /**
+ * Tells whether this step is a forward axis step.
+ * Includes the follwing axis:
+ * <ul>
+ * <li>{@link #AXIS_CHILD}</li>
+ * <li>{@link #AXIS_DESCENDANT}</li>
+ * <li>{@link #AXIS_DESCENDANT_OR_SELF}</li>
+ * <li>{@link #AXIS_ATTRIBUTE}</li>
+ * <li>{@link #AXIS_SELF}</li>
+ * <li>{@link #AXIS_FOLLOWING}</li>
+ * <li>{@link #AXIS_FOLLOWING_SIBLING}</li>
+ * <li>{@link #AXIS_NAMESPACE}</li>
+ * </ul>
+ * @return true whenever {@link #getAxisType()} returns one the
+ * constants right above.
+ */
+ boolean isForwardStep();
+
+ /**
+ * Tells whether this step is a reversed axis step.
+ * Includes the following axis:
+ * <ul>
+ * <li>{@link #AXIS_PARENT}</li>
+ * <li>{@link #AXIS_ANCESTOR}</li>
+ * <li>{@link #AXIS_PRECEDING}</li>
+ * <li>{@link #AXIS_PRECEDING_SIBLING}</li>
+ * <li>{@link #AXIS_ANCESTOR_OR_SELF}</li>
+ * </ul>
+ * @return true whenever {@link #getAxisType()} returns one the
+ * constants right above.
+ */
+ boolean isReversedStep();
+
+ /**
+ * Tells whether this step is a filter step
+ * @return boolean
+ */
+ boolean isFilterStep();
+
+ /**
+ * Gets the type of step axis
+ * @return short The axis type corresponding to one of the constants defined above.
+ * @throws XPath20Exception whenever the step isn't an axis step
+ */
+ short getAxisType() throws XPath20Exception;
+
+ /**
+ * Sets the type of the step axis
+ * @param newType The new axis type
+ * @throws XPath20Exception whenever the step isn't an axis step
+ */
+ void setAxisType(short newType) throws XPath20Exception;
+
+ /**
+ * Gets the name of the step axis
+ * @return String Full name of the step axis
+ * @throws XPath20Exception whenever the step isn't an axis step
+ */
+ String getAxisName() throws XPath20Exception;
+
+ /**
+ * Gets the node test
+ * @return NodeTest
+ * @throws XPath20Exception whenever the step isn't an axis step
+ */
+ NodeTest getNodeTest() throws XPath20Exception;
+
/**
* Sets the node test
- *
* @param NodeTest
- * @throws XPath20Exception whenever the step is not a forward or reverse
- * step.
+ * @throws XPath20Exception whenever the step isn't an axis step
*/
void setNodeTest(NodeTest test) throws XPath20Exception;
+ /**
+ * Gets the primary expression of the filter step.
+ * @return Expr The primary expression
+ * @throws XPath20Exception whenever the step isn't a filter step
+ */
+ Expr getPrimaryExpr() throws XPath20Exception;
- /**
- * Gets the step as a primary expression.
- *
- * @return Expr The primary expression
- */
- Expr getPrimaryExpr() throws XPath20Exception;
-
- /**
- * Gets the predicate expression at the specified position
- * @param i index of the predicate to return
- * @return The predicate at the ith position
- * @throws java.lang.ArrayIndexOutOfBoundsException
- */
- Expr getPredicateAt(int i);
-
- /**
- * Gets the number of predicate
- *
- * @return The number of predicates
- */
- int getPredicateCount();
-
- /**
- * Append the specified predicate
- * @param predicate The predicate to append
- */
- void appendPredicate(Expr predicate);
-
- /**
- * Remove the specified predicate
- */
- void removePredicate(Expr predicate);
+ /**
+ * Gets the predicate expression at the specified position
+ * @param i index of the predicate to return
+ * @return The predicate at the ith position
+ * @throws java.lang.ArrayIndexOutOfBoundsException
+ */
+ Expr getPredicateAt(int i);
+
+ /**
+ * Gets the number of predicate
+ * @return The number of predicates
+ */
+ int getPredicateCount();
+
+ /**
+ * Append the specified predicate at the end of the list of
+ * predicates
+ * @param predicate The predicate to append
+ */
+ void appendPredicate(Expr predicate);
+
+ /**
+ * Remove the specified predicate
+ */
+ void removePredicate(Expr predicate);
}
1.1.2.8 +22 -14 xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/Expr.java
Index: Expr.java
===================================================================
RCS file: /home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/Expr.java,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -u -r1.1.2.7 -r1.1.2.8
--- Expr.java 31 Jul 2003 02:29:28 -0000 1.1.2.7
+++ Expr.java 11 Aug 2003 14:45:53 -0000 1.1.2.8
@@ -57,8 +57,8 @@
/**
* Represents a XPath expression.
- * <p>Use {@link #getExprType()} to query the expression type.
- * More information about expression are obtained by casting it
+ * <p>Use {@link #getExprType()} to get the expression type.
+ * Then, more information about expression are obtained by casting it
* to its corresponding java type. Here the XPath expression type to Java type mapping table:
* </p>
* <table cellpadding="2" cellspacing="2" border="1">
@@ -161,7 +161,7 @@
* }
* } else
* {
- * System.out.println(e.getString(true) + " ");
+ * System.out.print(e.getString(true) + " ");
* }
* }
* </pre>
@@ -171,12 +171,13 @@
* </pre>
* <p>XPath expressions are always fully expanded. For example, the expression
* /a//b is expanded to fn:root(self::node())/descendant-or-self::node()/b.
- * The number of steps is 3 (and not 2).
+ * The number of steps is then 3 (and not 2).
* </p>
* <p>
- * An {@link Expr} object may be not a valid XPath expression but only a fragment.
- * For example a {@link StepExpr} expression is a fragment but can't be executed by
- * itself. To be valid, the top level expression must be an expression sequence.
+ * An {@link Expr} object may be not a valid XPath expression but only a fragment (or a part).
+ * For example {@link StepExpr} and {@link NodeTest} expression types are fragments
+ * and therefore can't be executed by themself. To be valid, the top level expression
+ * must be an expression sequence.
* </p>
* @see <a href="http://www.w3.org/TR/2002/WD-xpath20-20020816/#id-expressions">XPath 2.0 Specification</a>
* @author <a href="mailto:villard@us.ibm.com">Lionel Villard</a>
@@ -214,7 +215,7 @@
/**
* The expression is a quantified expression of type some
*/
- static final short SOME_EXPR = 22;
+ static final short SOME_EXPR = 8;
/**
* The expression is a comparison expression type.
@@ -254,11 +255,7 @@
*/
static final short VARIABLE_REF_EXPR = 15;
- /**
- * The expression is a step
- */
- static final short STEP = 17;
-
+
/**
* The expression is an instance of expression
*/
@@ -284,6 +281,17 @@
*/
static final short LET_EXPR = 23;
+ // Expression parts
+
+ /**
+ * The expression part is a step
+ */
+ static final short STEP = 17;
+
+ /**
+ * The expression part is a node test
+ */
+ static final short NODE_TEST = 11;
/**
* Gets the expression type.
1.1.2.5 +25 -38 xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/Literal.java
Index: Literal.java
===================================================================
RCS file: /home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/Literal.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- Literal.java 30 Jul 2003 18:52:58 -0000 1.1.2.4
+++ Literal.java 11 Aug 2003 14:45:53 -0000 1.1.2.5
@@ -62,18 +62,17 @@
/**
- * Represents literal expression type.
- * <pre>
- * [59] Literal ::= NumericLiteral | StringLiteral
- * [58] NumericLiteral ::= IntegerLiteral | DecimalLiteral | DoubleLiteral
- * [1] IntegerLiteral ::= Digits
- * [2] DecimalLiteral ::= ("." Digits) | (Digits "." [0-9]*)
- * [3] DoubleLiteral ::= (("." Digits) | (Digits ("." [0-9]*)?)) ("e" | "E") ("+" | "-")? Digits
- * [4] StringLiteral ::= ('"' (('"' '"') | [^"])* '"') | ("'" (("'" "'") | [^'])* "'")
- * </pre>
- *
- * @see <a href="http://www.w3.org/TR/xpath20#id-literals">XPath 2.0
- * Specification</a>
+ * Represents <em>literal</em> expressions.
+ * Use {@link #getLiteralType()} to get the type of literal, as following
+ * <ul>
+ * <li>{@link #INTEGER_LITERAL}: xs:integer datatype</li>
+ * <li>{@link #DOUBLE_LITERAL}: xs:double datatype</li>
+ * <li>{@link #DECIMAL_LITERAL}: xs:decimal datatype</li>
+ * <li>{@link #STRING_LITERAL}: xs:string datatype</li>
+ * </ul>
+ * @author <a href="mailto:villard@us.ibm.com">Lionel Villard</a>
+ * @version $Id$
+ * @see <a href="http://www.w3.org/TR/xpath20#id-literals">XPath 2.0 Specification</a>
*/
public interface Literal extends Expr
{
@@ -99,64 +98,52 @@
/**
* Gets the literal type
- *
* @return short One of the four following literal type:
- * <code>INTEGER_LITERAL</code>, <code>DECIMAL_LITERAL</code>,
- * <code>STRING_LITERAL</code>, <code>DOUBLE_LITERAL</code>.
+ * {@link #INTEGER_LITERAL}, {@link #DECIMAL_LITERAL},
+ * {@link #STRING_LITERAL}, {@link #DOUBLE_LITERAL}.
*/
short getLiteralType();
/**
- * Gets the integer literal
- *
- * @return DOCUMENT ME!
- *
- * @throws XPath20Exception when the literal isn't an integer or cannot be
- * represented by the primitive int type (in case of big integer)
+ * Gets the integer literal as primitive Java int type.
+ * @return int
+ * @throws XPath20Exception when the literal isn't an integer or when it cannot be
+ * represented as a primitive int type without approximations
*/
int getIntegerLiteralAsInt() throws XPath20Exception;
/**
- * Gets the integer literal
- *
- * @return DOCUMENT ME!
- *
+ * Gets the integer literal.
+ * @return BigInteger
* @throws XPath20Exception when the literal isn't an integer
*/
BigInteger getIntegerLiteral() throws XPath20Exception;
/**
* Gets the decimal literal
- *
- * @return DOCUMENT ME!
- *
+ * @return BigDecimal
* @throws XPath20Exception when the literal isn't a decimal
*/
BigDecimal getDecimalLiteral() throws XPath20Exception;
/**
* Gets the decimal literal as a double
- *
- * @return DOCUMENT ME!
- *
- * @throws XPath20Exception when the literal isn't a decimal
+ * @return double
+ * @throws XPath20Exception when the literal isn't a decimal or
+ * when it cannot be represented as a double without approximations
*/
double getDecimalLiteralAsDouble() throws XPath20Exception;
/**
* Gets the double literal
- *
- * @return DOCUMENT ME!
- *
+ * @return double
* @throws XPath20Exception when the literal isn't a double
*/
double getDoubleLiteral() throws XPath20Exception;
/**
* Gets the string literal
- *
- * @return DOCUMENT ME!
- *
+ * @return String
* @throws XPath20Exception when the literal isn't a string
*/
String getStringLiteral() throws XPath20Exception;
No revision
Index: Literal.java
===================================================================
RCS file: /home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/Literal.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- Literal.java 30 Jul 2003 18:52:58 -0000 1.1.2.4
+++ Literal.java 11 Aug 2003 14:45:53 -0000 1.1.2.5
@@ -62,18 +62,17 @@
/**
- * Represents literal expression type.
- * <pre>
- * [59] Literal ::= NumericLiteral | StringLiteral
- * [58] NumericLiteral ::= IntegerLiteral | DecimalLiteral | DoubleLiteral
- * [1] IntegerLiteral ::= Digits
- * [2] DecimalLiteral ::= ("." Digits) | (Digits "." [0-9]*)
- * [3] DoubleLiteral ::= (("." Digits) | (Digits ("." [0-9]*)?)) ("e" | "E") ("+" | "-")? Digits
- * [4] StringLiteral ::= ('"' (('"' '"') | [^"])* '"') | ("'" (("'" "'") | [^'])* "'")
- * </pre>
- *
- * @see <a href="http://www.w3.org/TR/xpath20#id-literals">XPath 2.0
- * Specification</a>
+ * Represents <em>literal</em> expressions.
+ * Use {@link #getLiteralType()} to get the type of literal, as following
+ * <ul>
+ * <li>{@link #INTEGER_LITERAL}: xs:integer datatype</li>
+ * <li>{@link #DOUBLE_LITERAL}: xs:double datatype</li>
+ * <li>{@link #DECIMAL_LITERAL}: xs:decimal datatype</li>
+ * <li>{@link #STRING_LITERAL}: xs:string datatype</li>
+ * </ul>
+ * @author <a href="mailto:villard@us.ibm.com">Lionel Villard</a>
+ * @version $Id$
+ * @see <a href="http://www.w3.org/TR/xpath20#id-literals">XPath 2.0 Specification</a>
*/
public interface Literal extends Expr
{
@@ -99,64 +98,52 @@
/**
* Gets the literal type
- *
* @return short One of the four following literal type:
- * <code>INTEGER_LITERAL</code>, <code>DECIMAL_LITERAL</code>,
- * <code>STRING_LITERAL</code>, <code>DOUBLE_LITERAL</code>.
+ * {@link #INTEGER_LITERAL}, {@link #DECIMAL_LITERAL},
+ * {@link #STRING_LITERAL}, {@link #DOUBLE_LITERAL}.
*/
short getLiteralType();
/**
- * Gets the integer literal
- *
- * @return DOCUMENT ME!
- *
- * @throws XPath20Exception when the literal isn't an integer or cannot be
- * represented by the primitive int type (in case of big integer)
+ * Gets the integer literal as primitive Java int type.
+ * @return int
+ * @throws XPath20Exception when the literal isn't an integer or when it cannot be
+ * represented as a primitive int type without approximations
*/
int getIntegerLiteralAsInt() throws XPath20Exception;
/**
- * Gets the integer literal
- *
- * @return DOCUMENT ME!
- *
+ * Gets the integer literal.
+ * @return BigInteger
* @throws XPath20Exception when the literal isn't an integer
*/
BigInteger getIntegerLiteral() throws XPath20Exception;
/**
* Gets the decimal literal
- *
- * @return DOCUMENT ME!
- *
+ * @return BigDecimal
* @throws XPath20Exception when the literal isn't a decimal
*/
BigDecimal getDecimalLiteral() throws XPath20Exception;
/**
* Gets the decimal literal as a double
- *
- * @return DOCUMENT ME!
- *
- * @throws XPath20Exception when the literal isn't a decimal
+ * @return double
+ * @throws XPath20Exception when the literal isn't a decimal or
+ * when it cannot be represented as a double without approximations
*/
double getDecimalLiteralAsDouble() throws XPath20Exception;
/**
* Gets the double literal
- *
- * @return DOCUMENT ME!
- *
+ * @return double
* @throws XPath20Exception when the literal isn't a double
*/
double getDoubleLiteral() throws XPath20Exception;
/**
* Gets the string literal
- *
- * @return DOCUMENT ME!
- *
+ * @return String
* @throws XPath20Exception when the literal isn't a string
*/
String getStringLiteral() throws XPath20Exception;
No revision
Index: Literal.java
===================================================================
RCS file: /home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/Literal.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- Literal.java 30 Jul 2003 18:52:58 -0000 1.1.2.4
+++ Literal.java 11 Aug 2003 14:45:53 -0000 1.1.2.5
@@ -62,18 +62,17 @@
/**
- * Represents literal expression type.
- * <pre>
- * [59] Literal ::= NumericLiteral | StringLiteral
- * [58] NumericLiteral ::= IntegerLiteral | DecimalLiteral | DoubleLiteral
- * [1] IntegerLiteral ::= Digits
- * [2] DecimalLiteral ::= ("." Digits) | (Digits "." [0-9]*)
- * [3] DoubleLiteral ::= (("." Digits) | (Digits ("." [0-9]*)?)) ("e" | "E") ("+" | "-")? Digits
- * [4] StringLiteral ::= ('"' (('"' '"') | [^"])* '"') | ("'" (("'" "'") | [^'])* "'")
- * </pre>
- *
- * @see <a href="http://www.w3.org/TR/xpath20#id-literals">XPath 2.0
- * Specification</a>
+ * Represents <em>literal</em> expressions.
+ * Use {@link #getLiteralType()} to get the type of literal, as following
+ * <ul>
+ * <li>{@link #INTEGER_LITERAL}: xs:integer datatype</li>
+ * <li>{@link #DOUBLE_LITERAL}: xs:double datatype</li>
+ * <li>{@link #DECIMAL_LITERAL}: xs:decimal datatype</li>
+ * <li>{@link #STRING_LITERAL}: xs:string datatype</li>
+ * </ul>
+ * @author <a href="mailto:villard@us.ibm.com">Lionel Villard</a>
+ * @version $Id$
+ * @see <a href="http://www.w3.org/TR/xpath20#id-literals">XPath 2.0 Specification</a>
*/
public interface Literal extends Expr
{
@@ -99,64 +98,52 @@
/**
* Gets the literal type
- *
* @return short One of the four following literal type:
- * <code>INTEGER_LITERAL</code>, <code>DECIMAL_LITERAL</code>,
- * <code>STRING_LITERAL</code>, <code>DOUBLE_LITERAL</code>.
+ * {@link #INTEGER_LITERAL}, {@link #DECIMAL_LITERAL},
+ * {@link #STRING_LITERAL}, {@link #DOUBLE_LITERAL}.
*/
short getLiteralType();
/**
- * Gets the integer literal
- *
- * @return DOCUMENT ME!
- *
- * @throws XPath20Exception when the literal isn't an integer or cannot be
- * represented by the primitive int type (in case of big integer)
+ * Gets the integer literal as primitive Java int type.
+ * @return int
+ * @throws XPath20Exception when the literal isn't an integer or when it cannot be
+ * represented as a primitive int type without approximations
*/
int getIntegerLiteralAsInt() throws XPath20Exception;
/**
- * Gets the integer literal
- *
- * @return DOCUMENT ME!
- *
+ * Gets the integer literal.
+ * @return BigInteger
* @throws XPath20Exception when the literal isn't an integer
*/
BigInteger getIntegerLiteral() throws XPath20Exception;
/**
* Gets the decimal literal
- *
- * @return DOCUMENT ME!
- *
+ * @return BigDecimal
* @throws XPath20Exception when the literal isn't a decimal
*/
BigDecimal getDecimalLiteral() throws XPath20Exception;
/**
* Gets the decimal literal as a double
- *
- * @return DOCUMENT ME!
- *
- * @throws XPath20Exception when the literal isn't a decimal
+ * @return double
+ * @throws XPath20Exception when the literal isn't a decimal or
+ * when it cannot be represented as a double without approximations
*/
double getDecimalLiteralAsDouble() throws XPath20Exception;
/**
* Gets the double literal
- *
- * @return DOCUMENT ME!
- *
+ * @return double
* @throws XPath20Exception when the literal isn't a double
*/
double getDoubleLiteral() throws XPath20Exception;
/**
* Gets the string literal
- *
- * @return DOCUMENT ME!
- *
+ * @return String
* @throws XPath20Exception when the literal isn't a string
*/
String getStringLiteral() throws XPath20Exception;
1.1.2.1 +56 -0 xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/Leaver.java
1.1.2.1 +147 -0 xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/KindTest.java
1.1.2.1 +50 -0 xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/expression/Attic/NameTest.java
No revision
No revision
1.1.2.2 +11 -1 xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/Attic/XPath20Utilities.java
Index: XPath20Utilities.java
===================================================================
RCS file: /home/cvs//xml-xalan/java/xpath_rwapi/src2/org/apache/xpath/Attic/XPath20Utilities.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- XPath20Utilities.java 30 Jul 2003 18:52:58 -0000 1.1.2.1
+++ XPath20Utilities.java 11 Aug 2003 14:45:54 -0000 1.1.2.2
@@ -152,5 +152,15 @@
}
return result;
}
+
+ /**
+ * Returns true whenever the specified expression is a
+ * <em>singleton sequence</em> (a sequence with only one item).
+ */
+ public static boolean isSingletonSequence(Expr e)
+ {
+ return e != null && e.getExprType() == Expr.SEQUENCE_EXPR
+ && ((OperatorExpr) e).getOperandCount() == 1;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org