286N/A * reserved comment block 286N/A * DO NOT REMOVE OR ALTER! 286N/A * Copyright 1999-2004 The Apache Software Foundation. 286N/A * Licensed under the Apache License, Version 2.0 (the "License"); 286N/A * you may not use this file except in compliance with the License. 286N/A * You may obtain a copy of the License at 286N/A * Unless required by applicable law or agreed to in writing, software 286N/A * distributed under the License is distributed on an "AS IS" BASIS, 286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 286N/A * See the License for the specific language governing permissions and 286N/A * limitations under the License. 286N/A * An instance of this class compiles an XPath string expression into 286N/A * a Expression object. This class compiles the string into a sequence 286N/A * of operation codes (op map) and then builds from that into an Expression 286N/A * Construct a Compiler object with a specific ErrorListener and 286N/A * SourceLocator where the expression is located. 286N/A * @param errorHandler Error listener where messages will be sent, or null 286N/A * if messages should be sent to System err. 286N/A * @param locator The location object where the expression lives, which 286N/A * may be null, but which, if not null, must be valid over 286N/A * the long haul, in other words, it will not be cloned. 286N/A * @param fTable The FunctionTable object where the xpath build-in 286N/A * functions are stored. 286N/A * Construct a Compiler instance that has a null error listener and a 286N/A * Execute the XPath object from a given opcode position. 286N/A * @param opPos The current position in the xpath.m_opMap array. 286N/A * @return The result of the XPath. 286N/A * @throws TransformerException if there is a syntax or other error. 286N/A // System.out.println(getPatternString()+"op: "+op); 286N/A// case OpCodes.OP_QUO : 286N/A// expr = quo(opPos); break; 286N/A new Object[]{
"quo" });
//"ERROR! Unknown op code: "+m_opMap[opPos]); 286N/A// expr.setSourceLocator(m_locator); 286N/A * Bottle-neck compilation of an operation with left and right operands. 286N/A * @param operation non-null reference to parent operation. 286N/A * @param opPos The op map position of the parent operation. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Operation} instance. 286N/A * @throws TransformerException if there is a syntax or other error. 286N/A * Bottle-neck compilation of a unary operation. 286N/A * @param unary The parent unary operation. 286N/A * @param opPos The position in the op map of the parent operation. 286N/A * @return The unary argument. 286N/A * @throws TransformerException if syntax or other error occurs. 286N/A * Compile an 'or' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Or} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile an 'and' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.And} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a '!=' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.NotEquals} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a '=' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Equals} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a '<=' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Lte} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a '<' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Lt} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a '>=' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Gte} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a '>' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Gt} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a '+' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Plus} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a '-' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Minus} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a '*' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Mult} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a 'div' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Div} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a 'mod' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Mod} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a 'quo' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Quo} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A// protected Expression quo(int opPos) throws TransformerException 286N/A// return compileOperation(new Quo(), opPos); 286N/A * Compile a unary '-' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Neg} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a 'string(...)' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.String} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a 'boolean(...)' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Bool} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a 'number(...)' operation. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Number} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a literal string value. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.objects.XString} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a literal number value. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.objects.XNumber} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a variable reference. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Variable} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile an expression group. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to the contained expression. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a function argument. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to the argument expression. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a location path union. The UnionPathIterator itself may create 286N/A * {@link com.sun.org.apache.xpath.internal.axes.LocPathIterator} children. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.axes.LocPathIterator} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Get the level of the location path or union being constructed. 286N/A * @return 0 if it is a top-level path. 286N/A * Get the function table 286N/A * Compile a location path. The LocPathIterator itself may create 286N/A * {@link com.sun.org.apache.xpath.internal.axes.AxesWalker} children. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.axes.LocPathIterator} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a location step predicate expression. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return the contained predicate expression. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile an entire match pattern expression. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.patterns.UnionPattern} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compile a location match pattern unit expression. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.patterns.StepPattern} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Get a {@link org.w3c.dom.traversal.NodeFilter} bit set that tells what 286N/A * to show for a given node test. 286N/A * @param opPos the op map position for the location step. 286N/A * @return {@link org.w3c.dom.traversal.NodeFilter} bit set that tells what 286N/A * to show for a given node test. 286N/A // System.out.println("testType: "+testType); 286N/A// return DTMFilter.SHOW_TEXT | DTMFilter.SHOW_COMMENT; 286N/A// return DTMFilter.SHOW_ALL; 286N/A // System.err.println("We should never reach here."); 286N/A * Compile a step pattern unit expression, used for both location paths 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @param stepCount The number of steps to expect. 286N/A * @param ancestorPattern The owning StepPattern, which may be null. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.patterns.StepPattern} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A // int nextStepType = getOpMap()[endStep]; 286N/A // boolean isSimple = ((OpCodes.ENDOP == nextStepType) && (stepCount == 0)); 286N/A // bit-o-hackery, but this code is due for the morgue anyway... 286N/A // This is the magic and invisible "." at the head of every 286N/A // match pattern, and corresponds to the current node in the context 286N/A // list, from where predicates are counted. 286N/A // So, in order to calculate "foo[3]", it has to count from the 286N/A // current node in the context list, so, from that current node, 286N/A // the full pattern is really "self::node()/child::foo[3]". If you 286N/A // translate this to a select pattern from the node being tested, 286N/A // which is really how we're treating match patterns, it works out to 286N/A /* if(addMagicSelf && pattern.getPredicateCount() > 0) 286N/A StepPattern selfPattern = new StepPattern(DTMFilter.SHOW_ALL, 286N/A Axis.PARENT, Axis.CHILD); 286N/A // We need to keep the new nodetest from affecting the score... 286N/A XNumber score = pattern.getStaticScore(); 286N/A pattern.setRelativePathPattern(selfPattern); 286N/A pattern.setStaticScore(score); 286N/A selfPattern.setStaticScore(score); 286N/A // System.out.println("Setting "+ancestorPattern+" as relative to "+pattern); 286N/A * Compile a zero or more predicates for a given match pattern. 286N/A * @param opPos The position of the first predicate the m_opMap array. 286N/A * @return reference to array of {@link com.sun.org.apache.xpath.internal.Expression} instances. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Count the number of predicates in the step. 286N/A * @param opPos The position of the first predicate the m_opMap array. 286N/A * @return The number of predicates for this step. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * Compiles predicates in the step. 286N/A * @param opPos The position of the first predicate the m_opMap array. 286N/A * @param predicates An empty pre-determined array of 286N/A * {@link com.sun.org.apache.xpath.internal.Expression}s, that will be filled in. 286N/A * @throws TransformerException 286N/A * Compile a built-in XPath function. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.functions.Function} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A * It is a trick for function-available. Since the function table is an 286N/A * instance field, insert this table at compilation time for later usage 286N/A // System.out.println("argPos: "+ p); 286N/A // System.out.println("argCode: "+ m_opMap[p]); 286N/A //"name + " only allows " + wnae.getMessage() + " arguments", m_locator)); 286N/A // The current id for extension functions. 286N/A * Get the next available method id 286N/A * Compile an extension function. 286N/A * @param opPos The current position in the m_opMap array. 286N/A * @return reference to {@link com.sun.org.apache.xpath.internal.functions.FuncExtFunction} instance. 286N/A * @throws TransformerException if a error occurs creating the Expression. 286N/A // We create a method key to uniquely identify this function so that we 286N/A // can cache the object needed to invoke it. This way, we only pay the 286N/A // reflection overhead on the first call. 286N/A ;
// should never happen 286N/A * Warn the user of an problem. 286N/A * @param msg An error msgkey that corresponds to one of the constants found 286N/A * in {@link com.sun.org.apache.xpath.internal.res.XPATHErrorResources}, which is 286N/A * a key for a format string. 286N/A * @param args An array of arguments represented in the format string, which 286N/A * @throws TransformerException if the current ErrorListoner determines to 286N/A * Tell the user of an assertion error, and probably throw an 286N/A * @param b If false, a runtime exception will be thrown. 286N/A * @param msg The assertion message, which should be informative. 286N/A * @throws RuntimeException if the b argument is false. 286N/A * Tell the user of an error, and probably throw an 286N/A * @param msg An error msgkey that corresponds to one of the constants found 286N/A * in {@link com.sun.org.apache.xpath.internal.res.XPATHErrorResources}, which is 286N/A * a key for a format string. 286N/A * @param args An array of arguments represented in the format string, which 286N/A * @throws TransformerException if the current ErrorListoner determines to 286N/A // System.out.println(te.getMessage() 286N/A // +"; file "+te.getSystemId() 286N/A // +"; line "+te.getLineNumber() 286N/A // +"; column "+te.getColumnNumber()); 286N/A * The current prefixResolver for the execution context. 286N/A * Get the current namespace context for the xpath. 286N/A * @return The current prefix resolver, *may* be null, though hopefully not. 286N/A * Set the current namespace context for the xpath. 286N/A * @param pr The resolver for prefixes in the XPath expression. 286N/A /** The error listener where errors will be sent. If this is null, errors 286N/A * and warnings will be sent to System.err. May be null. */ 286N/A /** The source locator for the expression being compiled. May be null. */ 286N/A * The FunctionTable for all xpath build-in functions