⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compiler.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
   *    * @param opPos The current position in the m_opMap array.   *   * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Quo} instance.   *   * @throws TransformerException if a error occurs creating the Expression.   *///  protected Expression quo(int opPos) throws TransformerException//  {//    return compileOperation(new Quo(), opPos);//  }  /**   * Compile a unary '-' operation.   *    * @param opPos The current position in the m_opMap array.   *   * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Neg} instance.   *   * @throws TransformerException if a error occurs creating the Expression.   */  protected Expression neg(int opPos) throws TransformerException  {    return compileUnary(new Neg(), opPos);  }  /**   * Compile a 'string(...)' operation.   *    * @param opPos The current position in the m_opMap array.   *   * @return reference to {@link com.sun.org.apache.xpath.internal.operations.String} instance.   *   * @throws TransformerException if a error occurs creating the Expression.   */  protected Expression string(int opPos) throws TransformerException  {    return compileUnary(new com.sun.org.apache.xpath.internal.operations.String(), opPos);  }  /**   * Compile a 'boolean(...)' operation.   *    * @param opPos The current position in the m_opMap array.   *   * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Bool} instance.   *   * @throws TransformerException if a error occurs creating the Expression.   */  protected Expression bool(int opPos) throws TransformerException  {    return compileUnary(new com.sun.org.apache.xpath.internal.operations.Bool(), opPos);  }  /**   * Compile a 'number(...)' operation.   *    * @param opPos The current position in the m_opMap array.   *   * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Number} instance.   *   * @throws TransformerException if a error occurs creating the Expression.   */  protected Expression number(int opPos) throws TransformerException  {    return compileUnary(new com.sun.org.apache.xpath.internal.operations.Number(), opPos);  }  /**   * Compile a literal string value.   *    * @param opPos The current position in the m_opMap array.   *   * @return reference to {@link com.sun.org.apache.xpath.internal.objects.XString} instance.   *   * @throws TransformerException if a error occurs creating the Expression.   */  protected Expression literal(int opPos)  {    opPos = getFirstChildPos(opPos);    return (XString) getTokenQueue().elementAt(getOp(opPos));  }  /**   * Compile a literal number value.   *    * @param opPos The current position in the m_opMap array.   *   * @return reference to {@link com.sun.org.apache.xpath.internal.objects.XNumber} instance.   *   * @throws TransformerException if a error occurs creating the Expression.   */  protected Expression numberlit(int opPos)  {    opPos = getFirstChildPos(opPos);    return (XNumber) getTokenQueue().elementAt(getOp(opPos));  }  /**   * Compile a variable reference.   *    * @param opPos The current position in the m_opMap array.   *   * @return reference to {@link com.sun.org.apache.xpath.internal.operations.Variable} instance.   *   * @throws TransformerException if a error occurs creating the Expression.   */  protected Expression variable(int opPos) throws TransformerException  {    Variable var = new Variable();    opPos = getFirstChildPos(opPos);    int nsPos = getOp(opPos);    java.lang.String namespace       = (OpCodes.EMPTY == nsPos) ? null                                    : (java.lang.String) getTokenQueue().elementAt(nsPos);    java.lang.String localname       = (java.lang.String) getTokenQueue().elementAt(getOp(opPos+1));    QName qname = new QName(namespace, localname);    var.setQName(qname);    return var;  }  /**   * Compile an expression group.   *    * @param opPos The current position in the m_opMap array.   *   * @return reference to the contained expression.   *   * @throws TransformerException if a error occurs creating the Expression.   */  protected Expression group(int opPos) throws TransformerException  {    // no-op    return compile(opPos + 2);  }  /**   * Compile a function argument.   *    * @param opPos The current position in the m_opMap array.   *   * @return reference to the argument expression.   *   * @throws TransformerException if a error occurs creating the Expression.   */  protected Expression arg(int opPos) throws TransformerException  {    // no-op    return compile(opPos + 2);  }  /**   * Compile a location path union. The UnionPathIterator itself may create   * {@link com.sun.org.apache.xpath.internal.axes.LocPathIterator} children.   *    * @param opPos The current position in the m_opMap array.   *   * @return reference to {@link com.sun.org.apache.xpath.internal.axes.LocPathIterator} instance.   *   * @throws TransformerException if a error occurs creating the Expression.   */  protected Expression union(int opPos) throws TransformerException  {    locPathDepth++;    try    {      return UnionPathIterator.createUnionIterator(this, opPos);    }    finally    {      locPathDepth--;    }  }    private int locPathDepth = -1;    /**   * Get the level of the location path or union being constructed.     * @return 0 if it is a top-level path.   */  public int getLocationPathDepth()  {    return locPathDepth;  }  /**   * Get the function table     */  FunctionTable getFunctionTable()  {    return m_functionTable;  }  /**   * Compile a location path.  The LocPathIterator itself may create   * {@link com.sun.org.apache.xpath.internal.axes.AxesWalker} children.   *    * @param opPos The current position in the m_opMap array.   *   * @return reference to {@link com.sun.org.apache.xpath.internal.axes.LocPathIterator} instance.   *   * @throws TransformerException if a error occurs creating the Expression.   */  public Expression locationPath(int opPos) throws TransformerException  {    locPathDepth++;    try    {      DTMIterator iter = WalkerFactory.newDTMIterator(this, opPos, (locPathDepth == 0));      return (Expression)iter; // cast OK, I guess.    }    finally    {      locPathDepth--;    }  }  /**   * Compile a location step predicate expression.   *    * @param opPos The current position in the m_opMap array.   *   * @return the contained predicate expression.   *   * @throws TransformerException if a error occurs creating the Expression.   */  public Expression predicate(int opPos) throws TransformerException  {    return compile(opPos + 2);  }  /**   * Compile an entire match pattern expression.   *    * @param opPos The current position in the m_opMap array.   *   * @return reference to {@link com.sun.org.apache.xpath.internal.patterns.UnionPattern} instance.   *   * @throws TransformerException if a error occurs creating the Expression.   */  protected Expression matchPattern(int opPos) throws TransformerException  {    locPathDepth++;    try    {      // First, count...      int nextOpPos = opPos;      int i;      for (i = 0; getOp(nextOpPos) == OpCodes.OP_LOCATIONPATHPATTERN; i++)      {        nextOpPos = getNextOpPos(nextOpPos);      }      if (i == 1)        return compile(opPos);      UnionPattern up = new UnionPattern();      StepPattern[] patterns = new StepPattern[i];      for (i = 0; getOp(opPos) == OpCodes.OP_LOCATIONPATHPATTERN; i++)      {        nextOpPos = getNextOpPos(opPos);        patterns[i] = (StepPattern) compile(opPos);        opPos = nextOpPos;      }      up.setPatterns(patterns);      return up;    }    finally    {      locPathDepth--;    }  }  /**   * Compile a location match pattern unit expression.   *    * @param opPos The current position in the m_opMap array.   *   * @return reference to {@link com.sun.org.apache.xpath.internal.patterns.StepPattern} instance.   *   * @throws TransformerException if a error occurs creating the Expression.   */  public Expression locationPathPattern(int opPos)          throws TransformerException  {    opPos = getFirstChildPos(opPos);    return stepPattern(opPos, 0, null);  }  /**   * Get a {@link org.w3c.dom.traversal.NodeFilter} bit set that tells what    * to show for a given node test.   *   * @param opPos the op map position for the location step.   *   * @return {@link org.w3c.dom.traversal.NodeFilter} bit set that tells what    *         to show for a given node test.   */  public int getWhatToShow(int opPos)  {    int axesType = getOp(opPos);    int testType = getOp(opPos + 3);    // System.out.println("testType: "+testType);    switch (testType)    {    case OpCodes.NODETYPE_COMMENT :      return DTMFilter.SHOW_COMMENT;    case OpCodes.NODETYPE_TEXT ://      return DTMFilter.SHOW_TEXT | DTMFilter.SHOW_COMMENT;      return DTMFilter.SHOW_TEXT | DTMFilter.SHOW_CDATA_SECTION ;    case OpCodes.NODETYPE_PI :      return DTMFilter.SHOW_PROCESSING_INSTRUCTION;    case OpCodes.NODETYPE_NODE ://      return DTMFilter.SHOW_ALL;      switch (axesType)      {      case OpCodes.FROM_NAMESPACE:        return DTMFilter.SHOW_NAMESPACE;      case OpCodes.FROM_ATTRIBUTES :      case OpCodes.MATCH_ATTRIBUTE :        return DTMFilter.SHOW_ATTRIBUTE;      case OpCodes.FROM_SELF:      case OpCodes.FROM_ANCESTORS_OR_SELF:      case OpCodes.FROM_DESCENDANTS_OR_SELF:        return DTMFilter.SHOW_ALL;      default:        if (getOp(0) == OpCodes.OP_MATCHPATTERN)          return ~DTMFilter.SHOW_ATTRIBUTE                  & ~DTMFilter.SHOW_DOCUMENT                  & ~DTMFilter.SHOW_DOCUMENT_FRAGMENT;        else          return ~DTMFilter.SHOW_ATTRIBUTE;      }    case OpCodes.NODETYPE_ROOT :      return DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT;    case OpCodes.NODETYPE_FUNCTEST :      return NodeTest.SHOW_BYFUNCTION;    case OpCodes.NODENAME :      switch (axesType)      {      case OpCodes.FROM_NAMESPACE :        return DTMFilter.SHOW_NAMESPACE;      case OpCodes.FROM_ATTRIBUTES :      case OpCodes.MATCH_ATTRIBUTE :        return DTMFilter.SHOW_ATTRIBUTE;      // break;      case OpCodes.MATCH_ANY_ANCESTOR :      case OpCodes.MATCH_IMMEDIATE_ANCESTOR :        return DTMFilter.SHOW_ELEMENT;      // break;      default :        return DTMFilter.SHOW_ELEMENT;      }    default :      // System.err.println("We should never reach here.");      return DTMFilter.SHOW_ALL;    }  }  private static final boolean DEBUG = false;  /**   * Compile a step pattern unit expression, used for both location paths    * and match patterns.   *    * @param opPos The current position in the m_opMap array.   * @param stepCount The number of steps to expect.   * @param ancestorPattern The owning StepPattern, which may be null.   *   * @return reference to {@link com.sun.org.apache.xpath.internal.patterns.StepPattern} instance.   *   * @throws TransformerException if a error occurs creating the Expression.   */  protected StepPattern stepPattern(          int opPos, int stepCount, StepPattern ancestorPattern)            throws TransformerException  {    int startOpPos = opPos;    int stepType = getOp(opPos);    if (OpCodes.ENDOP == stepType)    {      return null;    }        boolean addMagicSelf = true;    int endStep = getNextOpPos(opPos);    // int nextStepType = getOpMap()[endStep];    StepPattern pattern;        // boolean isSimple = ((OpCodes.ENDOP == nextStepType) && (stepCount == 0));    int argLen;    switch (stepType)    {    case OpCodes.OP_FUNCTION :      if(DEBUG)        System.out.println("MATCH_FUNCTION: "+m_currentPattern); 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -