/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: Step.java,v 1.6 2006/06/06 22:34:34 spericas Exp $
*/
/**
* @author Jacek Ambroziak
* @author Santiago Pericas-Geertsen
* @author Morten Jorgensen
*/
/**
* This step's axis as defined in class Axis.
*/
private int _axis;
/**
* A vector of predicates (filters) defined on this step - may be null
*/
/**
* Some simple predicates can be handled by this class (and not by the
* Predicate class) and will be removed from the above vector as they are
* handled. We use this boolean to remember if we did have any predicates.
*/
private boolean _hadPredicates = false;
/**
* Type of the node test.
*/
private int _nodeType;
}
/**
* Set the parser for this element and all child predicates
*/
if (_predicates != null) {
final int n = _predicates.size();
for (int i = 0; i < n; i++) {
}
}
}
/**
* Define the axis (defined in Axis class) for this step
*/
public int getAxis() {
return _axis;
}
/**
* Get the axis (defined in Axis class) for this step
*/
}
/**
* Returns the node-type for this step
*/
public int getNodeType() {
return _nodeType;
}
/**
* Returns the vector containing all predicates for this step.
*/
return _predicates;
}
/**
* Returns the vector containing all predicates for this step.
*/
if (_predicates == null) {
}
else {
}
}
/**
* Returns 'true' if this step has a parent pattern.
* This method will return 'false' if this step occurs on its own under
* an element like <xsl:for-each> or <xsl:apply-templates>.
*/
private boolean hasParentPattern() {
return (parent instanceof ParentPattern ||
parent instanceof ParentLocationPath ||
parent instanceof UnionPathExpr ||
parent instanceof FilterParentPath);
}
/**
* Returns 'true' if this step has a parent location path.
*/
private boolean hasParentLocationPath() {
return getParent() instanceof ParentLocationPath;
}
/**
* Returns 'true' if this step has any predicates
*/
private boolean hasPredicates() {
}
/**
* Returns 'true' if this step is used within a predicate
*/
private boolean isPredicate() {
SyntaxTreeNode parent = this;
}
return false;
}
/**
* True if this step is the abbreviated step '.'
*/
public boolean isAbbreviatedDot() {
}
/**
* True if this step is the abbreviated step '..'
*/
public boolean isAbbreviatedDDot() {
}
/**
* Type check this step. The abbreviated steps '.' and '@attr' are
* assigned type node if they have no predicates. All other steps
* have type node-set.
*/
// Save this value for later - important for testing for special
// combinations of steps and patterns than can be optimised
// Special case for '.'
// in the case where '.' has a context such as book/.
// or .[false()] we can not optimize the nodeset to a single node.
if (isAbbreviatedDot()) {
}
else {
}
// Type check all predicates (expressions applied to the step)
if (_predicates != null) {
final int n = _predicates.size();
for (int i = 0; i < n; i++) {
}
}
// Return either Type.Node or Type.NodeSet
return _type;
}
/**
* Translate a step by pushing the appropriate iterator onto the stack.
* The abbreviated steps '.' and '@attr' do not create new iterators
* if they are not part of a LocationPath and have no filters.
* In these cases a node index instead of an iterator is pushed
* onto the stack.
*/
}
int predicateIndex) {
if (predicateIndex >= 0) {
} else {
int star = 0;
}
// If it is an attribute, but not '@*', '@pre:*' or '@node()',
// and has no parent
&& star == 0)
{
"getTypedAxisIterator",
"(II)"+NODE_ITERATOR_SIG);
return;
}
// Special case for '.'
if (isAbbreviatedDot()) {
// Put context node on stack if using Type.Node
}
else {
if (parent instanceof ParentLocationPath){
// Wrap the context node in a singleton iterator if not.
"<init>",
} else {
// DOM.getAxisIterator(int axis);
"getAxisIterator",
"(I)"+NODE_ITERATOR_SIG);
}
}
return;
}
// Special case for /foo/*/bar
if ((parent instanceof ParentLocationPath) &&
}
}
// "ELEMENT" or "*" or "@*" or ".." or "@attr" with a parent.
switch (_nodeType) {
// DOM.getAxisIterator(int axis);
"getAxisIterator",
"(I)"+NODE_ITERATOR_SIG);
break;
default:
if (star > 1) {
else
"getNamespaceAxisIterator",
"(II)"+NODE_ITERATOR_SIG);
break;
}
// DOM.getTypedAxisIterator(int axis, int type);
"getTypedAxisIterator",
"(II)"+NODE_ITERATOR_SIG);
// Get the typed iterator we're after
break;
}
}
}
/**
* Translate a sequence of predicates. Each predicate is translated
* by constructing an instance of <code>CurrentNodeListIterator</code>
* which is initialized from another iterator (recursive call),
* a filter and a closure (call to translate on the predicate) and "this".
*/
int predicateIndex) {
int idx = 0;
if (predicateIndex < 0) {
}
else {
// Special case for predicates that can use the NodeValueIterator
// instead of an auxiliary class. Certain path/predicates pairs
// are translated into a base path, on top of which we place a
// node value iterator that tests for the desired value:
// foo[@attr = 'str'] -> foo/@attr + test(value='str')
if (predicate.isNodeValueTest()) {
// If the predicate's Step is simply '.' we translate this Step
// and place the node test on top of the resulting iterator
if (step.isAbbreviatedDot()) {
}
// Otherwise we create a parent location path with this Step and
// the predicates Step, and place the node test on top of that
else {
try {
}
catch (TypeCheckError e) { }
}
}
// Handle '//*[n]' expression
else if (predicate.isNthDescendant()) {
// il.append(new ICONST(NodeTest.ELEMENT));
"getNthDescendant",
"(IIZ)"+NODE_ITERATOR_SIG);
}
// Handle 'elem[n]' expression
else if (predicate.isNthPositionFilter()) {
"<init>",
// Backwards branches are prohibited if an uninitialized object
// is on the stack by section 4.9.4 of the JVM Specification,
// 2nd Ed. We don't know whether this code might contain
// backwards branches, so we mustn't create the new object until
// after we've created the suspect arguments to its constructor.
// Instead we calculate the values of the arguments to the
// constructor first, store them in temporary variables, create
// the object and reload the arguments from the temporaries to
// avoid the problem.
}
else {
"<init>",
"("
+ NODE_SIG
+ ")V");
// Backwards branches are prohibited if an uninitialized object
// is on the stack by section 4.9.4 of the JVM Specification,
// 2nd Ed. We don't know whether this code might contain
// backwards branches, so we mustn't create the new object until
// after we've created the suspect arguments to its constructor.
// Instead we calculate the values of the arguments to the
// constructor first, store them in temporary variables, create
// the object and reload the arguments from the temporaries to
// avoid the problem.
// create new CurrentNodeListIterator
if (classGen.isExternal()) {
}
}
}
}
/**
* Returns a string representation of this step.
*/
if (_predicates != null) {
final int n = _predicates.size();
for (int i = 0; i < n; i++) {
}
}
}
}