src/java.xml/share/classes/com/sun/org/apache/xpath/internal/Expression.java
author joehw
Wed, 18 Oct 2017 13:25:49 -0700
changeset 47359 e1a6c0168741
parent 47216 71c04702a3d5
child 48409 5ab69533994b
permissions -rw-r--r--
8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked Reviewed-by: lancea, rriggs, mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
     3
 * @LastModified: Oct 2017
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
/*
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     6
 * Licensed to the Apache Software Foundation (ASF) under one or more
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     7
 * contributor license agreements.  See the NOTICE file distributed with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     8
 * this work for additional information regarding copyright ownership.
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     9
 * The ASF licenses this file to You under the Apache License, Version 2.0
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    10
 * (the "License"); you may not use this file except in compliance with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    11
 * the License.  You may obtain a copy of the License at
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 *
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    13
 *      http://www.apache.org/licenses/LICENSE-2.0
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * Unless required by applicable law or agreed to in writing, software
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 * distributed under the License is distributed on an "AS IS" BASIS,
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * See the License for the specific language governing permissions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 * limitations under the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
 */
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    21
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
package com.sun.org.apache.xpath.internal;
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
import com.sun.org.apache.xalan.internal.res.XSLMessages;
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
import com.sun.org.apache.xml.internal.dtm.DTM;
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
import com.sun.org.apache.xml.internal.dtm.DTMIterator;
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    27
import com.sun.org.apache.xml.internal.utils.QName;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
import com.sun.org.apache.xml.internal.utils.XMLString;
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
import com.sun.org.apache.xpath.internal.objects.XNodeSet;
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
import com.sun.org.apache.xpath.internal.objects.XObject;
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
import com.sun.org.apache.xpath.internal.res.XPATHErrorResources;
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    32
import java.util.List;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    33
import javax.xml.transform.ErrorListener;
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    34
import javax.xml.transform.TransformerException;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
import org.xml.sax.ContentHandler;
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
 * This abstract class serves as the base for all expression objects.  An
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
 * Expression can be executed to return a {@link com.sun.org.apache.xpath.internal.objects.XObject},
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
 * normally has a location within a document or DOM, can send error and warning
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
 * events, and normally do not hold state and are meant to be immutable once
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
 * construction has completed.  An exception to the immutibility rule is iterators
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
 * and walkers, which must be cloned in order to be used -- the original must
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
 * still be immutable.
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
public abstract class Expression implements java.io.Serializable, ExpressionNode, XPathVisitable
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
{
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
    static final long serialVersionUID = 565665869777906902L;
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
   * The location where this expression was built from.  Need for diagnostic
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
   *  messages. May be null.
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
   *  @serial
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
  private ExpressionNode m_parent;
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
   * Tell if this expression or it's subexpressions can traverse outside
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
   * the current subtree.
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
   * @return true if traversal outside the context node's subtree can occur.
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
  public boolean canTraverseOutsideSubtree()
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
    return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
//  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
//   * Set the location where this expression was built from.
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
//   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
//   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
//   * @param locator the location where this expression was built from, may be
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
//   *                null.
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
//   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
//  public void setSourceLocator(SourceLocator locator)
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
//  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
//    m_slocator = locator;
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
//  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
   * Execute an expression in the XPath runtime context, and return the
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
   * result of the expression.
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
   * @param xctxt The XPath runtime context.
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
   * @param currentNode The currentNode.
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
   * @return The result of the expression in the form of a <code>XObject</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
   * @throws javax.xml.transform.TransformerException if a runtime exception
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
   *         occurs.
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
  public XObject execute(XPathContext xctxt, int currentNode)
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
          throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
    // For now, the current node is already pushed.
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
    return execute(xctxt);
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
   * Execute an expression in the XPath runtime context, and return the
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
   * result of the expression.
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
   * @param xctxt The XPath runtime context.
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
   * @param currentNode The currentNode.
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
   * @param dtm The DTM of the current node.
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
   * @param expType The expanded type ID of the current node.
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
   * @return The result of the expression in the form of a <code>XObject</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
   * @throws javax.xml.transform.TransformerException if a runtime exception
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
   *         occurs.
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
  public XObject execute(
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
          XPathContext xctxt, int currentNode, DTM dtm, int expType)
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
            throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
    // For now, the current node is already pushed.
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
    return execute(xctxt);
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
   * Execute an expression in the XPath runtime context, and return the
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
   * result of the expression.
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
   * @param xctxt The XPath runtime context.
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
   * @return The result of the expression in the form of a <code>XObject</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
   * @throws javax.xml.transform.TransformerException if a runtime exception
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
   *         occurs.
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
  public abstract XObject execute(XPathContext xctxt)
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
    throws javax.xml.transform.TransformerException;
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
   * Execute an expression in the XPath runtime context, and return the
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
   * result of the expression, but tell that a "safe" object doesn't have
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
   * to be returned.  The default implementation just calls execute(xctxt).
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
   * @param xctxt The XPath runtime context.
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
   * @param destructiveOK true if a "safe" object doesn't need to be returned.
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
   * @return The result of the expression in the form of a <code>XObject</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
   * @throws javax.xml.transform.TransformerException if a runtime exception
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
   *         occurs.
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
  public XObject execute(XPathContext xctxt, boolean destructiveOK)
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
    throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
        return execute(xctxt);
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
7f561c08de6b Initial load
duke
parents:
diff changeset
   159
7f561c08de6b Initial load
duke
parents:
diff changeset
   160
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   161
   * Evaluate expression to a number.
7f561c08de6b Initial load
duke
parents:
diff changeset
   162
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   163
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   164
   * @param xctxt The XPath runtime context.
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
   * @return The expression evaluated as a double.
7f561c08de6b Initial load
duke
parents:
diff changeset
   166
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   167
   * @throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   168
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   169
  public double num(XPathContext xctxt)
7f561c08de6b Initial load
duke
parents:
diff changeset
   170
          throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   171
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   172
    return execute(xctxt).num();
7f561c08de6b Initial load
duke
parents:
diff changeset
   173
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   174
7f561c08de6b Initial load
duke
parents:
diff changeset
   175
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   176
   * Evaluate expression to a boolean.
7f561c08de6b Initial load
duke
parents:
diff changeset
   177
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   178
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   179
   * @param xctxt The XPath runtime context.
7f561c08de6b Initial load
duke
parents:
diff changeset
   180
   * @return false
7f561c08de6b Initial load
duke
parents:
diff changeset
   181
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   182
   * @throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   183
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   184
  public boolean bool(XPathContext xctxt)
7f561c08de6b Initial load
duke
parents:
diff changeset
   185
          throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   187
    return execute(xctxt).bool();
7f561c08de6b Initial load
duke
parents:
diff changeset
   188
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   189
7f561c08de6b Initial load
duke
parents:
diff changeset
   190
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   191
   * Cast result object to a string.
7f561c08de6b Initial load
duke
parents:
diff changeset
   192
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   193
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   194
   * @param xctxt The XPath runtime context.
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
   * @return The string this wraps or the empty string if null
7f561c08de6b Initial load
duke
parents:
diff changeset
   196
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   197
   * @throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   199
  public XMLString xstr(XPathContext xctxt)
7f561c08de6b Initial load
duke
parents:
diff changeset
   200
          throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   201
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   202
    return execute(xctxt).xstr();
7f561c08de6b Initial load
duke
parents:
diff changeset
   203
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   204
7f561c08de6b Initial load
duke
parents:
diff changeset
   205
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   206
   * Tell if the expression is a nodeset expression.  In other words, tell
7f561c08de6b Initial load
duke
parents:
diff changeset
   207
   * if you can execute {@link #asNode(XPathContext) asNode} without an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
   208
   * @return true if the expression can be represented as a nodeset.
7f561c08de6b Initial load
duke
parents:
diff changeset
   209
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   210
  public boolean isNodesetExpr()
7f561c08de6b Initial load
duke
parents:
diff changeset
   211
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
    return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   213
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
7f561c08de6b Initial load
duke
parents:
diff changeset
   215
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   216
   * Return the first node out of the nodeset, if this expression is
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
   * a nodeset expression.
7f561c08de6b Initial load
duke
parents:
diff changeset
   218
   * @param xctxt The XPath runtime context.
7f561c08de6b Initial load
duke
parents:
diff changeset
   219
   * @return the first node out of the nodeset, or DTM.NULL.
7f561c08de6b Initial load
duke
parents:
diff changeset
   220
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   221
   * @throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   222
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   223
  public int asNode(XPathContext xctxt)
7f561c08de6b Initial load
duke
parents:
diff changeset
   224
          throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   225
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   226
        DTMIterator iter = execute(xctxt).iter();
7f561c08de6b Initial load
duke
parents:
diff changeset
   227
    return iter.nextNode();
7f561c08de6b Initial load
duke
parents:
diff changeset
   228
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   229
7f561c08de6b Initial load
duke
parents:
diff changeset
   230
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   231
   * Given an select expression and a context, evaluate the XPath
7f561c08de6b Initial load
duke
parents:
diff changeset
   232
   * and return the resulting iterator.
7f561c08de6b Initial load
duke
parents:
diff changeset
   233
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   234
   * @param xctxt The execution context.
7f561c08de6b Initial load
duke
parents:
diff changeset
   235
   * @param contextNode The node that "." expresses.
7f561c08de6b Initial load
duke
parents:
diff changeset
   236
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   237
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   238
   * @return A valid DTMIterator.
7f561c08de6b Initial load
duke
parents:
diff changeset
   239
   * @throws TransformerException thrown if the active ProblemListener decides
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
   * the error condition is severe enough to halt processing.
7f561c08de6b Initial load
duke
parents:
diff changeset
   241
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   242
   * @throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   243
   * @xsl.usage experimental
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   245
  public DTMIterator asIterator(XPathContext xctxt, int contextNode)
7f561c08de6b Initial load
duke
parents:
diff changeset
   246
          throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   247
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   248
7f561c08de6b Initial load
duke
parents:
diff changeset
   249
    try
7f561c08de6b Initial load
duke
parents:
diff changeset
   250
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   251
      xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
7f561c08de6b Initial load
duke
parents:
diff changeset
   252
7f561c08de6b Initial load
duke
parents:
diff changeset
   253
      return execute(xctxt).iter();
7f561c08de6b Initial load
duke
parents:
diff changeset
   254
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   255
    finally
7f561c08de6b Initial load
duke
parents:
diff changeset
   256
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   257
      xctxt.popCurrentNodeAndExpression();
7f561c08de6b Initial load
duke
parents:
diff changeset
   258
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   259
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   260
7f561c08de6b Initial load
duke
parents:
diff changeset
   261
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   262
   * Given an select expression and a context, evaluate the XPath
7f561c08de6b Initial load
duke
parents:
diff changeset
   263
   * and return the resulting iterator, but do not clone.
7f561c08de6b Initial load
duke
parents:
diff changeset
   264
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   265
   * @param xctxt The execution context.
7f561c08de6b Initial load
duke
parents:
diff changeset
   266
   * @param contextNode The node that "." expresses.
7f561c08de6b Initial load
duke
parents:
diff changeset
   267
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   268
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   269
   * @return A valid DTMIterator.
7f561c08de6b Initial load
duke
parents:
diff changeset
   270
   * @throws TransformerException thrown if the active ProblemListener decides
7f561c08de6b Initial load
duke
parents:
diff changeset
   271
   * the error condition is severe enough to halt processing.
7f561c08de6b Initial load
duke
parents:
diff changeset
   272
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   273
   * @throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   274
   * @xsl.usage experimental
7f561c08de6b Initial load
duke
parents:
diff changeset
   275
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   276
  public DTMIterator asIteratorRaw(XPathContext xctxt, int contextNode)
7f561c08de6b Initial load
duke
parents:
diff changeset
   277
          throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   278
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   279
7f561c08de6b Initial load
duke
parents:
diff changeset
   280
    try
7f561c08de6b Initial load
duke
parents:
diff changeset
   281
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   282
      xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
7f561c08de6b Initial load
duke
parents:
diff changeset
   283
7f561c08de6b Initial load
duke
parents:
diff changeset
   284
      XNodeSet nodeset = (XNodeSet)execute(xctxt);
7f561c08de6b Initial load
duke
parents:
diff changeset
   285
      return nodeset.iterRaw();
7f561c08de6b Initial load
duke
parents:
diff changeset
   286
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   287
    finally
7f561c08de6b Initial load
duke
parents:
diff changeset
   288
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   289
      xctxt.popCurrentNodeAndExpression();
7f561c08de6b Initial load
duke
parents:
diff changeset
   290
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   291
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   292
7f561c08de6b Initial load
duke
parents:
diff changeset
   293
7f561c08de6b Initial load
duke
parents:
diff changeset
   294
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   295
   * Execute an expression in the XPath runtime context, and return the
7f561c08de6b Initial load
duke
parents:
diff changeset
   296
   * result of the expression.
7f561c08de6b Initial load
duke
parents:
diff changeset
   297
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   298
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   299
   * @param xctxt The XPath runtime context.
7f561c08de6b Initial load
duke
parents:
diff changeset
   300
   * NEEDSDOC @param handler
7f561c08de6b Initial load
duke
parents:
diff changeset
   301
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   302
   * @return The result of the expression in the form of a <code>XObject</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   303
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   304
   * @throws javax.xml.transform.TransformerException if a runtime exception
7f561c08de6b Initial load
duke
parents:
diff changeset
   305
   *         occurs.
7f561c08de6b Initial load
duke
parents:
diff changeset
   306
   * @throws org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   307
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   308
  public void executeCharsToContentHandler(
7f561c08de6b Initial load
duke
parents:
diff changeset
   309
          XPathContext xctxt, ContentHandler handler)
7f561c08de6b Initial load
duke
parents:
diff changeset
   310
            throws javax.xml.transform.TransformerException,
7f561c08de6b Initial load
duke
parents:
diff changeset
   311
                   org.xml.sax.SAXException
7f561c08de6b Initial load
duke
parents:
diff changeset
   312
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   313
7f561c08de6b Initial load
duke
parents:
diff changeset
   314
    XObject obj = execute(xctxt);
7f561c08de6b Initial load
duke
parents:
diff changeset
   315
7f561c08de6b Initial load
duke
parents:
diff changeset
   316
    obj.dispatchCharactersEvents(handler);
7f561c08de6b Initial load
duke
parents:
diff changeset
   317
    obj.detach();
7f561c08de6b Initial load
duke
parents:
diff changeset
   318
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   319
7f561c08de6b Initial load
duke
parents:
diff changeset
   320
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   321
   * Tell if this expression returns a stable number that will not change during
7f561c08de6b Initial load
duke
parents:
diff changeset
   322
   * iterations within the expression.  This is used to determine if a proximity
7f561c08de6b Initial load
duke
parents:
diff changeset
   323
   * position predicate can indicate that no more searching has to occur.
7f561c08de6b Initial load
duke
parents:
diff changeset
   324
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   325
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   326
   * @return true if the expression represents a stable number.
7f561c08de6b Initial load
duke
parents:
diff changeset
   327
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   328
  public boolean isStableNumber()
7f561c08de6b Initial load
duke
parents:
diff changeset
   329
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   330
    return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   331
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   332
7f561c08de6b Initial load
duke
parents:
diff changeset
   333
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   334
   * This function is used to fixup variables from QNames to stack frame
7f561c08de6b Initial load
duke
parents:
diff changeset
   335
   * indexes at stylesheet build time.
7f561c08de6b Initial load
duke
parents:
diff changeset
   336
   * @param vars List of QNames that correspond to variables.  This list
7f561c08de6b Initial load
duke
parents:
diff changeset
   337
   * should be searched backwards for the first qualified name that
7f561c08de6b Initial load
duke
parents:
diff changeset
   338
   * corresponds to the variable reference qname.  The position of the
7f561c08de6b Initial load
duke
parents:
diff changeset
   339
   * QName in the vector from the start of the vector will be its position
7f561c08de6b Initial load
duke
parents:
diff changeset
   340
   * in the stack frame (but variables above the globalsTop value will need
7f561c08de6b Initial load
duke
parents:
diff changeset
   341
   * to be offset to the current stack frame).
7f561c08de6b Initial load
duke
parents:
diff changeset
   342
   * NEEDSDOC @param globalsSize
7f561c08de6b Initial load
duke
parents:
diff changeset
   343
   */
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   344
  public abstract void fixupVariables(List<QName> vars, int globalsSize);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   345
7f561c08de6b Initial load
duke
parents:
diff changeset
   346
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   347
   * Compare this object with another object and see
7f561c08de6b Initial load
duke
parents:
diff changeset
   348
   * if they are equal, include the sub heararchy.
7f561c08de6b Initial load
duke
parents:
diff changeset
   349
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   350
   * @param expr Another expression object.
7f561c08de6b Initial load
duke
parents:
diff changeset
   351
   * @return true if this objects class and the expr
7f561c08de6b Initial load
duke
parents:
diff changeset
   352
   * object's class are the same, and the data contained
7f561c08de6b Initial load
duke
parents:
diff changeset
   353
   * within both objects are considered equal.
7f561c08de6b Initial load
duke
parents:
diff changeset
   354
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   355
  public abstract boolean deepEquals(Expression expr);
7f561c08de6b Initial load
duke
parents:
diff changeset
   356
7f561c08de6b Initial load
duke
parents:
diff changeset
   357
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   358
   * This is a utility method to tell if the passed in
7f561c08de6b Initial load
duke
parents:
diff changeset
   359
   * class is the same class as this.  It is to be used by
7f561c08de6b Initial load
duke
parents:
diff changeset
   360
   * the deepEquals method.  I'm bottlenecking it here
7f561c08de6b Initial load
duke
parents:
diff changeset
   361
   * because I'm not totally confident that comparing the
7f561c08de6b Initial load
duke
parents:
diff changeset
   362
   * class objects is the best way to do this.
7f561c08de6b Initial load
duke
parents:
diff changeset
   363
   * @return true of the passed in class is the exact same
7f561c08de6b Initial load
duke
parents:
diff changeset
   364
   * class as this class.
7f561c08de6b Initial load
duke
parents:
diff changeset
   365
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   366
  protected final boolean isSameClass(Expression expr)
7f561c08de6b Initial load
duke
parents:
diff changeset
   367
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   368
        if(null == expr)
7f561c08de6b Initial load
duke
parents:
diff changeset
   369
          return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   370
7f561c08de6b Initial load
duke
parents:
diff changeset
   371
        return (getClass() == expr.getClass());
7f561c08de6b Initial load
duke
parents:
diff changeset
   372
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   373
7f561c08de6b Initial load
duke
parents:
diff changeset
   374
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   375
   * Warn the user of an problem.
7f561c08de6b Initial load
duke
parents:
diff changeset
   376
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   377
   * @param xctxt The XPath runtime context.
7f561c08de6b Initial load
duke
parents:
diff changeset
   378
   * @param msg An error msgkey that corresponds to one of the conststants found
7f561c08de6b Initial load
duke
parents:
diff changeset
   379
   *            in {@link com.sun.org.apache.xpath.internal.res.XPATHErrorResources}, which is
7f561c08de6b Initial load
duke
parents:
diff changeset
   380
   *            a key for a format string.
7f561c08de6b Initial load
duke
parents:
diff changeset
   381
   * @param args An array of arguments represented in the format string, which
7f561c08de6b Initial load
duke
parents:
diff changeset
   382
   *             may be null.
7f561c08de6b Initial load
duke
parents:
diff changeset
   383
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   384
   * @throws TransformerException if the current ErrorListoner determines to
7f561c08de6b Initial load
duke
parents:
diff changeset
   385
   *                              throw an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
   386
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   387
   * @throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   388
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   389
  public void warn(XPathContext xctxt, String msg, Object[] args)
7f561c08de6b Initial load
duke
parents:
diff changeset
   390
          throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   391
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   392
7f561c08de6b Initial load
duke
parents:
diff changeset
   393
    java.lang.String fmsg = XSLMessages.createXPATHWarning(msg, args);
7f561c08de6b Initial load
duke
parents:
diff changeset
   394
7f561c08de6b Initial load
duke
parents:
diff changeset
   395
    if (null != xctxt)
7f561c08de6b Initial load
duke
parents:
diff changeset
   396
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   397
      ErrorListener eh = xctxt.getErrorListener();
7f561c08de6b Initial load
duke
parents:
diff changeset
   398
7f561c08de6b Initial load
duke
parents:
diff changeset
   399
      // TO DO: Need to get stylesheet Locator from here.
7f561c08de6b Initial load
duke
parents:
diff changeset
   400
      eh.warning(new TransformerException(fmsg, xctxt.getSAXLocator()));
7f561c08de6b Initial load
duke
parents:
diff changeset
   401
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   402
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   403
7f561c08de6b Initial load
duke
parents:
diff changeset
   404
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   405
   * Tell the user of an assertion error, and probably throw an
7f561c08de6b Initial load
duke
parents:
diff changeset
   406
   * exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
   407
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   408
   * @param b  If false, a runtime exception will be thrown.
7f561c08de6b Initial load
duke
parents:
diff changeset
   409
   * @param msg The assertion message, which should be informative.
7f561c08de6b Initial load
duke
parents:
diff changeset
   410
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   411
   * @throws RuntimeException if the b argument is false.
7f561c08de6b Initial load
duke
parents:
diff changeset
   412
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   413
   * @throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   414
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   415
  public void assertion(boolean b, java.lang.String msg)
7f561c08de6b Initial load
duke
parents:
diff changeset
   416
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   417
7f561c08de6b Initial load
duke
parents:
diff changeset
   418
    if (!b)
7f561c08de6b Initial load
duke
parents:
diff changeset
   419
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   420
      java.lang.String fMsg = XSLMessages.createXPATHMessage(
7f561c08de6b Initial load
duke
parents:
diff changeset
   421
        XPATHErrorResources.ER_INCORRECT_PROGRAMMER_ASSERTION,
7f561c08de6b Initial load
duke
parents:
diff changeset
   422
        new Object[]{ msg });
7f561c08de6b Initial load
duke
parents:
diff changeset
   423
7f561c08de6b Initial load
duke
parents:
diff changeset
   424
      throw new RuntimeException(fMsg);
7f561c08de6b Initial load
duke
parents:
diff changeset
   425
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   426
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   427
7f561c08de6b Initial load
duke
parents:
diff changeset
   428
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   429
   * Tell the user of an error, and probably throw an
7f561c08de6b Initial load
duke
parents:
diff changeset
   430
   * exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
   431
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   432
   * @param xctxt The XPath runtime context.
7f561c08de6b Initial load
duke
parents:
diff changeset
   433
   * @param msg An error msgkey that corresponds to one of the constants found
7f561c08de6b Initial load
duke
parents:
diff changeset
   434
   *            in {@link com.sun.org.apache.xpath.internal.res.XPATHErrorResources}, which is
7f561c08de6b Initial load
duke
parents:
diff changeset
   435
   *            a key for a format string.
7f561c08de6b Initial load
duke
parents:
diff changeset
   436
   * @param args An array of arguments represented in the format string, which
7f561c08de6b Initial load
duke
parents:
diff changeset
   437
   *             may be null.
7f561c08de6b Initial load
duke
parents:
diff changeset
   438
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   439
   * @throws TransformerException if the current ErrorListoner determines to
7f561c08de6b Initial load
duke
parents:
diff changeset
   440
   *                              throw an exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
   441
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   442
   * @throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   443
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   444
  public void error(XPathContext xctxt, String msg, Object[] args)
7f561c08de6b Initial load
duke
parents:
diff changeset
   445
          throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   446
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   447
7f561c08de6b Initial load
duke
parents:
diff changeset
   448
    java.lang.String fmsg = XSLMessages.createXPATHMessage(msg, args);
7f561c08de6b Initial load
duke
parents:
diff changeset
   449
7f561c08de6b Initial load
duke
parents:
diff changeset
   450
    if (null != xctxt)
7f561c08de6b Initial load
duke
parents:
diff changeset
   451
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   452
      ErrorListener eh = xctxt.getErrorListener();
7f561c08de6b Initial load
duke
parents:
diff changeset
   453
      TransformerException te = new TransformerException(fmsg, this);
7f561c08de6b Initial load
duke
parents:
diff changeset
   454
7f561c08de6b Initial load
duke
parents:
diff changeset
   455
      eh.fatalError(te);
7f561c08de6b Initial load
duke
parents:
diff changeset
   456
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   457
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   458
7f561c08de6b Initial load
duke
parents:
diff changeset
   459
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   460
   * Get the first non-Expression parent of this node.
7f561c08de6b Initial load
duke
parents:
diff changeset
   461
   * @return null or first ancestor that is not an Expression.
7f561c08de6b Initial load
duke
parents:
diff changeset
   462
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   463
  public ExpressionNode getExpressionOwner()
7f561c08de6b Initial load
duke
parents:
diff changeset
   464
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   465
        ExpressionNode parent = exprGetParent();
7f561c08de6b Initial load
duke
parents:
diff changeset
   466
        while((null != parent) && (parent instanceof Expression))
7f561c08de6b Initial load
duke
parents:
diff changeset
   467
                parent = parent.exprGetParent();
7f561c08de6b Initial load
duke
parents:
diff changeset
   468
        return parent;
7f561c08de6b Initial load
duke
parents:
diff changeset
   469
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   470
7f561c08de6b Initial load
duke
parents:
diff changeset
   471
  //=============== ExpressionNode methods ================
7f561c08de6b Initial load
duke
parents:
diff changeset
   472
7f561c08de6b Initial load
duke
parents:
diff changeset
   473
  /** This pair of methods are used to inform the node of its
7f561c08de6b Initial load
duke
parents:
diff changeset
   474
    parent. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   475
  public void exprSetParent(ExpressionNode n)
7f561c08de6b Initial load
duke
parents:
diff changeset
   476
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   477
        assertion(n != this, "Can not parent an expression to itself!");
7f561c08de6b Initial load
duke
parents:
diff changeset
   478
        m_parent = n;
7f561c08de6b Initial load
duke
parents:
diff changeset
   479
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   480
7f561c08de6b Initial load
duke
parents:
diff changeset
   481
  public ExpressionNode exprGetParent()
7f561c08de6b Initial load
duke
parents:
diff changeset
   482
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   483
        return m_parent;
7f561c08de6b Initial load
duke
parents:
diff changeset
   484
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   485
7f561c08de6b Initial load
duke
parents:
diff changeset
   486
  /** This method tells the node to add its argument to the node's
7f561c08de6b Initial load
duke
parents:
diff changeset
   487
    list of children.  */
7f561c08de6b Initial load
duke
parents:
diff changeset
   488
  public void exprAddChild(ExpressionNode n, int i)
7f561c08de6b Initial load
duke
parents:
diff changeset
   489
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   490
        assertion(false, "exprAddChild method not implemented!");
7f561c08de6b Initial load
duke
parents:
diff changeset
   491
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   492
7f561c08de6b Initial load
duke
parents:
diff changeset
   493
  /** This method returns a child node.  The children are numbered
7f561c08de6b Initial load
duke
parents:
diff changeset
   494
     from zero, left to right. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   495
  public ExpressionNode exprGetChild(int i)
7f561c08de6b Initial load
duke
parents:
diff changeset
   496
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   497
        return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   498
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   499
7f561c08de6b Initial load
duke
parents:
diff changeset
   500
  /** Return the number of children the node has. */
7f561c08de6b Initial load
duke
parents:
diff changeset
   501
  public int exprGetNumChildren()
7f561c08de6b Initial load
duke
parents:
diff changeset
   502
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   503
        return 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
   504
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   505
7f561c08de6b Initial load
duke
parents:
diff changeset
   506
  //=============== SourceLocator methods ================
7f561c08de6b Initial load
duke
parents:
diff changeset
   507
7f561c08de6b Initial load
duke
parents:
diff changeset
   508
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   509
   * Return the public identifier for the current document event.
7f561c08de6b Initial load
duke
parents:
diff changeset
   510
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   511
   * <p>The return value is the public identifier of the document
7f561c08de6b Initial load
duke
parents:
diff changeset
   512
   * entity or of the external parsed entity in which the markup that
7f561c08de6b Initial load
duke
parents:
diff changeset
   513
   * triggered the event appears.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   514
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   515
   * @return A string containing the public identifier, or
7f561c08de6b Initial load
duke
parents:
diff changeset
   516
   *         null if none is available.
7f561c08de6b Initial load
duke
parents:
diff changeset
   517
   * @see #getSystemId
7f561c08de6b Initial load
duke
parents:
diff changeset
   518
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   519
  public String getPublicId()
7f561c08de6b Initial load
duke
parents:
diff changeset
   520
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   521
        if(null == m_parent)
7f561c08de6b Initial load
duke
parents:
diff changeset
   522
          return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   523
        return m_parent.getPublicId();
7f561c08de6b Initial load
duke
parents:
diff changeset
   524
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   525
7f561c08de6b Initial load
duke
parents:
diff changeset
   526
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   527
   * Return the system identifier for the current document event.
7f561c08de6b Initial load
duke
parents:
diff changeset
   528
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   529
   * <p>The return value is the system identifier of the document
7f561c08de6b Initial load
duke
parents:
diff changeset
   530
   * entity or of the external parsed entity in which the markup that
7f561c08de6b Initial load
duke
parents:
diff changeset
   531
   * triggered the event appears.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   532
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   533
   * <p>If the system identifier is a URL, the parser must resolve it
7f561c08de6b Initial load
duke
parents:
diff changeset
   534
   * fully before passing it to the application.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   535
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   536
   * @return A string containing the system identifier, or null
7f561c08de6b Initial load
duke
parents:
diff changeset
   537
   *         if none is available.
7f561c08de6b Initial load
duke
parents:
diff changeset
   538
   * @see #getPublicId
7f561c08de6b Initial load
duke
parents:
diff changeset
   539
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   540
  public String getSystemId()
7f561c08de6b Initial load
duke
parents:
diff changeset
   541
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   542
        if(null == m_parent)
7f561c08de6b Initial load
duke
parents:
diff changeset
   543
          return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   544
        return m_parent.getSystemId();
7f561c08de6b Initial load
duke
parents:
diff changeset
   545
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   546
7f561c08de6b Initial load
duke
parents:
diff changeset
   547
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   548
   * Return the line number where the current document event ends.
7f561c08de6b Initial load
duke
parents:
diff changeset
   549
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   550
   * <p><strong>Warning:</strong> The return value from the method
7f561c08de6b Initial load
duke
parents:
diff changeset
   551
   * is intended only as an approximation for the sake of error
7f561c08de6b Initial load
duke
parents:
diff changeset
   552
   * reporting; it is not intended to provide sufficient information
7f561c08de6b Initial load
duke
parents:
diff changeset
   553
   * to edit the character content of the original XML document.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   554
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   555
   * <p>The return value is an approximation of the line number
7f561c08de6b Initial load
duke
parents:
diff changeset
   556
   * in the document entity or external parsed entity where the
7f561c08de6b Initial load
duke
parents:
diff changeset
   557
   * markup that triggered the event appears.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   558
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   559
   * @return The line number, or -1 if none is available.
7f561c08de6b Initial load
duke
parents:
diff changeset
   560
   * @see #getColumnNumber
7f561c08de6b Initial load
duke
parents:
diff changeset
   561
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   562
  public int getLineNumber()
7f561c08de6b Initial load
duke
parents:
diff changeset
   563
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   564
        if(null == m_parent)
7f561c08de6b Initial load
duke
parents:
diff changeset
   565
          return 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
   566
        return m_parent.getLineNumber();
7f561c08de6b Initial load
duke
parents:
diff changeset
   567
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   568
7f561c08de6b Initial load
duke
parents:
diff changeset
   569
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   570
   * Return the character position where the current document event ends.
7f561c08de6b Initial load
duke
parents:
diff changeset
   571
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   572
   * <p><strong>Warning:</strong> The return value from the method
7f561c08de6b Initial load
duke
parents:
diff changeset
   573
   * is intended only as an approximation for the sake of error
7f561c08de6b Initial load
duke
parents:
diff changeset
   574
   * reporting; it is not intended to provide sufficient information
7f561c08de6b Initial load
duke
parents:
diff changeset
   575
   * to edit the character content of the original XML document.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   576
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   577
   * <p>The return value is an approximation of the column number
7f561c08de6b Initial load
duke
parents:
diff changeset
   578
   * in the document entity or external parsed entity where the
7f561c08de6b Initial load
duke
parents:
diff changeset
   579
   * markup that triggered the event appears.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   580
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   581
   * @return The column number, or -1 if none is available.
7f561c08de6b Initial load
duke
parents:
diff changeset
   582
   * @see #getLineNumber
7f561c08de6b Initial load
duke
parents:
diff changeset
   583
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   584
  public int getColumnNumber()
7f561c08de6b Initial load
duke
parents:
diff changeset
   585
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   586
        if(null == m_parent)
7f561c08de6b Initial load
duke
parents:
diff changeset
   587
          return 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
   588
        return m_parent.getColumnNumber();
7f561c08de6b Initial load
duke
parents:
diff changeset
   589
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   590
}