org.w3c.dom.xpath.XPathResult#com.sun.org.apache.xpath.internal.res.XPATHErrorResources源码实例Demo

下面列出了org.w3c.dom.xpath.XPathResult#com.sun.org.apache.xpath.internal.res.XPATHErrorResources 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk1.8-source-analysis   文件: XPathParser.java
/**
 *
 * Basis    ::=    AxisName '::' NodeTest
 * | AbbreviatedBasis
 *
 * @return FROM_XXX axes type, found in {@link com.sun.org.apache.xpath.internal.compiler.Keywords}.
 *
 * @throws javax.xml.transform.TransformerException
 */
protected int AxisName() throws javax.xml.transform.TransformerException
{

  Object val = Keywords.getAxisName(m_token);

  if (null == val)
  {
    error(XPATHErrorResources.ER_ILLEGAL_AXIS_NAME,
          new Object[]{ m_token });  //"illegal axis name: "+m_token);
  }

  int axesType = ((Integer) val).intValue();

  appendOp(2, axesType);

  return axesType;
}
 
源代码2 项目: jdk1.8-source-analysis   文件: VariableStack.java
/**
 * Get a local variable or parameter in the current stack frame.
 *
 *
 * @param xctxt The XPath context, which must be passed in order to
 * lazy evaluate variables.
 *
 * @param index Local variable index relative to the current stack
 * frame bottom.
 *
 * @return The value of the variable.
 *
 * @throws TransformerException
 */
public XObject getLocalVariable(XPathContext xctxt, int index)
        throws TransformerException
{

  index += _currentFrameBottom;

  XObject val = _stackFrames[index];

  if(null == val)
    throw new TransformerException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_VARIABLE_ACCESSED_BEFORE_BIND, null),
                   xctxt.getSAXLocator());
    // "Variable accessed before it is bound!", xctxt.getSAXLocator());

  // Lazy execution of variables.
  if (val.getType() == XObject.CLASS_UNRESOLVEDVARIABLE)
    return (_stackFrames[index] = val.execute(xctxt));

  return val;
}
 
源代码3 项目: TencentKona-8   文件: XPathParser.java
/**
 *
 * RelativeLocationPath ::= Step
 * | RelativeLocationPath '/' Step
 * | AbbreviatedRelativeLocationPath
 *
 * @returns true if, and only if, a RelativeLocationPath was matched
 *
 * @throws javax.xml.transform.TransformerException
 */
protected boolean RelativeLocationPath()
             throws javax.xml.transform.TransformerException
{
  if (!Step())
  {
    return false;
  }

  while (tokenIs('/'))
  {
    nextToken();

    if (!Step())
    {
      // RelativeLocationPath can't end with a trailing '/'
      // "Location step expected following '/' or '//'"
      error(XPATHErrorResources.ER_EXPECTED_LOC_STEP, null);
    }
  }

  return true;
}
 
源代码4 项目: TencentKona-8   文件: JAXPExtensionsProvider.java
/**
 * Is the extension function available?
 */

public boolean functionAvailable(String ns, String funcName)
      throws javax.xml.transform.TransformerException {
  try {
    if ( funcName == null ) {
        String fmsg = XSLMessages.createXPATHMessage(
            XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
            new Object[] {"Function Name"} );
        throw new NullPointerException ( fmsg );
    }
    //Find the XPathFunction corresponding to namespace and funcName
    javax.xml.namespace.QName myQName = new QName( ns, funcName );
    javax.xml.xpath.XPathFunction xpathFunction =
        resolver.resolveFunction ( myQName, 0 );
    if (  xpathFunction == null ) {
        return false;
    }
    return true;
  } catch ( Exception e ) {
    return false;
  }


}
 
源代码5 项目: TencentKona-8   文件: AxesWalker.java
/**
 * Set the root node of the TreeWalker.
 * (Not part of the DOM2 TreeWalker interface).
 *
 * @param root The context node of this step.
 */
public void setRoot(int root)
{
  // %OPT% Get this directly from the lpi.
  XPathContext xctxt = wi().getXPathContext();
  m_dtm = xctxt.getDTM(root);
  m_traverser = m_dtm.getAxisTraverser(m_axis);
  m_isFresh = true;
  m_foundLast = false;
  m_root = root;
  m_currentNode = root;

  if (DTM.NULL == root)
  {
    throw new RuntimeException(
      XSLMessages.createXPATHMessage(XPATHErrorResources.ER_SETTING_WALKER_ROOT_TO_NULL, null)); //"\n !!!! Error! Setting the root of a walker to null!!!");
  }

  resetProximityPositions();
}
 
源代码6 项目: jdk1.8-source-analysis   文件: XPathResultImpl.java
/**
     * Returns the <code>index</code>th item in the snapshot collection. If
     * <code>index</code> is greater than or equal to the number of nodes in
     * the list, this method returns <code>null</code>. Unlike the iterator
     * result, the snapshot does not become invalid, but may not correspond
     * to the current document if it is mutated.
     * @param index Index into the snapshot collection.
     * @return The node at the <code>index</code>th position in the
     *   <code>NodeList</code>, or <code>null</code> if that is not a valid
     *   index.
     * @exception XPathException
     *   TYPE_ERR: raised if <code>resultType</code> is not
     *   <code>UNORDERED_NODE_SNAPSHOT_TYPE</code> or
     *   <code>ORDERED_NODE_SNAPSHOT_TYPE</code>.
     *
         * @see org.w3c.dom.xpath.XPathResult#snapshotItem(int)
         */
        public Node snapshotItem(int index) throws XPathException {

                if ((m_resultType != UNORDERED_NODE_SNAPSHOT_TYPE) &&
                    (m_resultType != ORDERED_NODE_SNAPSHOT_TYPE)) {
           String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_NON_SNAPSHOT_TYPE, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});
           throw new XPathException(XPathException.TYPE_ERR, fmsg);
//              "The method snapshotItem cannot be called on the XPathResult of XPath expression {0} because its XPathResultType is {1}.
//              This method applies only to types UNORDERED_NODE_SNAPSHOT_TYPE and ORDERED_NODE_SNAPSHOT_TYPE."},
            }

        Node node = m_list.item(index);

        // Wrap "namespace node" in an XPathNamespace
        if (isNamespaceNode(node)) {
            return new XPathNamespaceImpl(node);
        } else {
            return node;
        }
        }
 
源代码7 项目: jdk1.8-source-analysis   文件: NodeSet.java
/**
 *  Returns the previous node in the set and moves the position of the
 * iterator backwards in the set.
 * @return  The previous <code>Node</code> in the set being iterated over,
 *   or<code>null</code> if there are no more members in that set.
 * @throws DOMException
 *    INVALID_STATE_ERR: Raised if this method is called after the
 *   <code>detach</code> method was invoked.
 * @throws RuntimeException thrown if this NodeSet is not of
 * a cached type, and hence doesn't know what the previous node was.
 */
public Node previousNode() throws DOMException
{

  if (!m_cacheNodes)
    throw new RuntimeException(
      XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_CANNOT_ITERATE, null)); //"This NodeSet can not iterate to a previous node!");

  if ((m_next - 1) > 0)
  {
    m_next--;

    return this.elementAt(m_next);
  }
  else
    return null;
}
 
源代码8 项目: TencentKona-8   文件: XPathParser.java
/**
 *
 *
 * StringExpr  ::=  Expr
 *
 *
 * @throws javax.xml.transform.TransformerException
 */
protected void BooleanExpr() throws javax.xml.transform.TransformerException
{

  int opPos = m_ops.getOp(OpMap.MAPINDEX_LENGTH);

  appendOp(2, OpCodes.OP_BOOL);
  Expr();

  int opLen = m_ops.getOp(OpMap.MAPINDEX_LENGTH) - opPos;

  if (opLen == 2)
  {
    error(XPATHErrorResources.ER_BOOLEAN_ARG_NO_LONGER_OPTIONAL, null);  //"boolean(...) argument is no longer optional with 19990709 XPath draft.");
  }

  m_ops.setOp(opPos + OpMap.MAPINDEX_LENGTH, opLen);
}
 
源代码9 项目: TencentKona-8   文件: XPathResultImpl.java
/**
     * Returns the <code>index</code>th item in the snapshot collection. If
     * <code>index</code> is greater than or equal to the number of nodes in
     * the list, this method returns <code>null</code>. Unlike the iterator
     * result, the snapshot does not become invalid, but may not correspond
     * to the current document if it is mutated.
     * @param index Index into the snapshot collection.
     * @return The node at the <code>index</code>th position in the
     *   <code>NodeList</code>, or <code>null</code> if that is not a valid
     *   index.
     * @exception XPathException
     *   TYPE_ERR: raised if <code>resultType</code> is not
     *   <code>UNORDERED_NODE_SNAPSHOT_TYPE</code> or
     *   <code>ORDERED_NODE_SNAPSHOT_TYPE</code>.
     *
         * @see org.w3c.dom.xpath.XPathResult#snapshotItem(int)
         */
        public Node snapshotItem(int index) throws XPathException {

                if ((m_resultType != UNORDERED_NODE_SNAPSHOT_TYPE) &&
                    (m_resultType != ORDERED_NODE_SNAPSHOT_TYPE)) {
           String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_NON_SNAPSHOT_TYPE, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});
           throw new XPathException(XPathException.TYPE_ERR, fmsg);
//              "The method snapshotItem cannot be called on the XPathResult of XPath expression {0} because its XPathResultType is {1}.
//              This method applies only to types UNORDERED_NODE_SNAPSHOT_TYPE and ORDERED_NODE_SNAPSHOT_TYPE."},
            }

        Node node = m_list.item(index);

        // Wrap "namespace node" in an XPathNamespace
        if (isNamespaceNode(node)) {
            return new XPathNamespaceImpl(node);
        } else {
            return node;
        }
        }
 
源代码10 项目: TencentKona-8   文件: VariableStack.java
/**
 * Get a local variable or parameter in the current stack frame.
 *
 *
 * @param xctxt The XPath context, which must be passed in order to
 * lazy evaluate variables.
 *
 * @param index Local variable index relative to the current stack
 * frame bottom.
 *
 * @return The value of the variable.
 *
 * @throws TransformerException
 */
public XObject getLocalVariable(XPathContext xctxt, int index)
        throws TransformerException
{

  index += _currentFrameBottom;

  XObject val = _stackFrames[index];

  if(null == val)
    throw new TransformerException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_VARIABLE_ACCESSED_BEFORE_BIND, null),
                   xctxt.getSAXLocator());
    // "Variable accessed before it is bound!", xctxt.getSAXLocator());

  // Lazy execution of variables.
  if (val.getType() == XObject.CLASS_UNRESOLVEDVARIABLE)
    return (_stackFrames[index] = val.execute(xctxt));

  return val;
}
 
源代码11 项目: TencentKona-8   文件: NodeSet.java
/**
 *  Returns the previous node in the set and moves the position of the
 * iterator backwards in the set.
 * @return  The previous <code>Node</code> in the set being iterated over,
 *   or<code>null</code> if there are no more members in that set.
 * @throws DOMException
 *    INVALID_STATE_ERR: Raised if this method is called after the
 *   <code>detach</code> method was invoked.
 * @throws RuntimeException thrown if this NodeSet is not of
 * a cached type, and hence doesn't know what the previous node was.
 */
public Node previousNode() throws DOMException
{

  if (!m_cacheNodes)
    throw new RuntimeException(
      XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_CANNOT_ITERATE, null)); //"This NodeSet can not iterate to a previous node!");

  if ((m_next - 1) > 0)
  {
    m_next--;

    return this.elementAt(m_next);
  }
  else
    return null;
}
 
源代码12 项目: jdk1.8-source-analysis   文件: XPathImpl.java
/**
 * <p>Compile an XPath expression for later evaluation.</p>
 *
 * <p>If <code>expression</code> contains any {@link XPathFunction}s,
 * they must be available via the {@link XPathFunctionResolver}.
 * An {@link XPathExpressionException} will be thrown if the <code>XPathFunction</code>
 * cannot be resovled with the <code>XPathFunctionResolver</code>.</p>
 *
 * <p>If <code>expression</code> is <code>null</code>, a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 *
 * @return Compiled XPath expression.

 * @throws XPathExpressionException If <code>expression</code> cannot be compiled.
 * @throws NullPointerException If <code>expression</code> is <code>null</code>.
 */
public XPathExpression compile(String expression)
    throws XPathExpressionException {
    if ( expression == null ) {
        String fmsg = XSLMessages.createXPATHMessage(
                XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
                new Object[] {"XPath expression"} );
        throw new NullPointerException ( fmsg );
    }
    try {
        com.sun.org.apache.xpath.internal.XPath xpath = new XPath (expression, null,
                prefixResolver, com.sun.org.apache.xpath.internal.XPath.SELECT );
        // Can have errorListener
        XPathExpressionImpl ximpl = new XPathExpressionImpl (xpath,
                prefixResolver, functionResolver, variableResolver,
                featureSecureProcessing, useServiceMechanism, featureManager );
        return ximpl;
    } catch ( javax.xml.transform.TransformerException te ) {
        throw new XPathExpressionException ( te ) ;
    }
}
 
源代码13 项目: TencentKona-8   文件: NodeSetDTM.java
/**
 *  Returns the previous node in the set and moves the position of the
 * iterator backwards in the set.
 * @return  The previous <code>Node</code> in the set being iterated over,
 *   or<code>DTM.NULL</code> if there are no more members in that set.
 * @throws DOMException
 *    INVALID_STATE_ERR: Raised if this method is called after the
 *   <code>detach</code> method was invoked.
 * @throws RuntimeException thrown if this NodeSetDTM is not of
 * a cached type, and hence doesn't know what the previous node was.
 */
public int previousNode()
{

  if (!m_cacheNodes)
    throw new RuntimeException(
      XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_CANNOT_ITERATE, null)); //"This NodeSetDTM can not iterate to a previous node!");

  if ((m_next - 1) > 0)
  {
    m_next--;

    return this.elementAt(m_next);
  }
  else
    return DTM.NULL;
}
 
源代码14 项目: TencentKona-8   文件: XPathImpl.java
/**
 * <p>Establishes a variable resolver.</p>
 *
 * @param resolver Variable Resolver
 */
public void setXPathVariableResolver(XPathVariableResolver resolver) {
    if ( resolver == null ) {
        String fmsg = XSLMessages.createXPATHMessage(
                XPATHErrorResources.ER_ARG_CANNOT_BE_NULL,
                new Object[] {"XPathVariableResolver"} );
        throw new NullPointerException( fmsg );
    }
    this.variableResolver = resolver;
}
 
源代码15 项目: jdk1.8-source-analysis   文件: XObject.java
/**
 * Cast result object to a boolean. Always issues an error.
 *
 * @return false
 *
 * @throws javax.xml.transform.TransformerException
 */
public boolean bool() throws javax.xml.transform.TransformerException
{

  error(XPATHErrorResources.ER_CANT_CONVERT_TO_NUMBER,
        new Object[]{ getTypeString() });  //"Can not convert "+getTypeString()+" to a number");

  return false;
}
 
源代码16 项目: TencentKona-8   文件: XPathResultImpl.java
/**
         *  The value of this number result.
     * @exception XPathException
     *   TYPE_ERR: raised if <code>resultType</code> is not
     *   <code>NUMBER_TYPE</code>.
         * @see org.w3c.dom.xpath.XPathResult#getNumberValue()
         */
        public double getNumberValue() throws XPathException {
                if (getResultType() != NUMBER_TYPE) {
                        String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_XPATHRESULTTYPE_TO_NUMBER, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});
                        throw new XPathException(XPathException.TYPE_ERR,fmsg);
//              "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be converted to a number"
                } else {
                        try {
                           return m_resultObj.num();
                        } catch (Exception e) {
                                // Type check above should prevent this exception from occurring.
                                throw new XPathException(XPathException.TYPE_ERR,e.getMessage());
                        }
                }
        }
 
源代码17 项目: TencentKona-8   文件: NodeSet.java
/**
 * Append a Node onto the vector.
 *
 * @param value Node to add to the vector
 */
public void addElement(Node value)
{
  if (!m_mutable)
    throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");

  if ((m_firstFree + 1) >= m_mapSize)
  {
    if (null == m_map)
    {
      m_map = new Node[m_blocksize];
      m_mapSize = m_blocksize;
    }
    else
    {
      m_mapSize += m_blocksize;

      Node newMap[] = new Node[m_mapSize];

      System.arraycopy(m_map, 0, newMap, 0, m_firstFree + 1);

      m_map = newMap;
    }
  }

  m_map[m_firstFree] = value;

  m_firstFree++;
}
 
源代码18 项目: TencentKona-8   文件: NodeSet.java
/**
 * Remove a node.
 *
 * @param n Node to be added
 * @throws RuntimeException thrown if this NodeSet is not of
 * a mutable type.
 */
public void removeNode(Node n)
{

  if (!m_mutable)
    throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");

  this.removeElement(n);
}
 
源代码19 项目: jdk1.8-source-analysis   文件: XObject.java
/**
 * Cast object to type t.
 *
 * @param t Type of object to cast this to
 * @param support XPath context to use for the conversion
 *
 * @return This object as the given type t
 *
 * @throws javax.xml.transform.TransformerException
 */
public Object castToType(int t, XPathContext support)
        throws javax.xml.transform.TransformerException
{

  Object result;

  switch (t)
  {
  case CLASS_STRING :
    result = str();
    break;
  case CLASS_NUMBER :
    result = new Double(num());
    break;
  case CLASS_NODESET :
    result = iter();
    break;
  case CLASS_BOOLEAN :
    result = new Boolean(bool());
    break;
  case CLASS_UNKNOWN :
    result = m_obj;
    break;

  // %TBD%  What to do here?
  //    case CLASS_RTREEFRAG :
  //      result = rtree(support);
  //      break;
  default :
    error(XPATHErrorResources.ER_CANT_CONVERT_TO_TYPE,
          new Object[]{ getTypeString(),
                        Integer.toString(t) });  //"Can not convert "+getTypeString()+" to a type#"+t);

    result = null;
  }

  return result;
}
 
源代码20 项目: jdk1.8-source-analysis   文件: XStringForChars.java
/**
 * Construct a XNodeSet object.
 *
 * @param val String object this will wrap.
 */
private XStringForChars(String val)
{
  super(val);
  throw new IllegalArgumentException(
                    XSLMessages.createXPATHMessage(XPATHErrorResources.ER_XSTRINGFORCHARS_CANNOT_TAKE_STRING, null)); //"XStringForChars can not take a string for an argument!");
}
 
源代码21 项目: jdk1.8-source-analysis   文件: OpMap.java
/**
 * Given an FROM_stepType position, return the position of the
 * first predicate, if there is one, or else this will point
 * to the end of the FROM_stepType.
 * Example:
 *  int posOfPredicate = xpath.getNextOpPos(stepPos);
 *  boolean hasPredicates =
 *            OpCodes.OP_PREDICATE == xpath.getOp(posOfPredicate);
 *
 * @param opPos position of FROM_stepType op.
 * @return position of predicate in FROM_stepType structure.
 */
public int getFirstPredicateOpPos(int opPos)
   throws javax.xml.transform.TransformerException
{

  int stepType = m_opMap.elementAt(opPos);

  if ((stepType >= OpCodes.AXES_START_TYPES)
          && (stepType <= OpCodes.AXES_END_TYPES))
  {
    return opPos + m_opMap.elementAt(opPos + 2);
  }
  else if ((stepType >= OpCodes.FIRST_NODESET_OP)
           && (stepType <= OpCodes.LAST_NODESET_OP))
  {
    return opPos + m_opMap.elementAt(opPos + 1);
  }
  else if(-2 == stepType)
  {
    return -2;
  }
  else
  {
    error(com.sun.org.apache.xpath.internal.res.XPATHErrorResources.ER_UNKNOWN_OPCODE,
          new Object[]{ String.valueOf(stepType) });  //"ERROR! Unknown op code: "+m_opMap[opPos]);
    return -1;
  }
}
 
源代码22 项目: TencentKona-8   文件: NodeSet.java
/**
 * Add a node to the NodeSet. Not all types of NodeSets support this
 * operation
 *
 * @param n Node to be added
 * @throws RuntimeException thrown if this NodeSet is not of
 * a mutable type.
 */
public void addNode(Node n)
{

  if (!m_mutable)
    throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");

  this.addElement(n);
}
 
源代码23 项目: TencentKona-8   文件: NodeSetDTM.java
/**
 * Same as setElementAt.
 *
 * @param node  The node to be set.
 * @param index The index of the node to be replaced.
 * @throws RuntimeException thrown if this NodeSetDTM is not of
 * a mutable type.
 */
public void setItem(int node, int index)
{

  if (!m_mutable)
    throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");

  super.setElementAt(node, index);
}
 
源代码24 项目: jdk1.8-source-analysis   文件: Variable.java
/**
 * This function is used to fixup variables from QNames to stack frame
 * indexes at stylesheet build time.
 * @param vars List of QNames that correspond to variables.  This list
 * should be searched backwards for the first qualified name that
 * corresponds to the variable reference qname.  The position of the
 * QName in the vector from the start of the vector will be its position
 * in the stack frame (but variables above the globalsTop value will need
 * to be offset to the current stack frame).
 */
public void fixupVariables(java.util.Vector vars, int globalsSize)
{
  m_fixUpWasCalled = true;
  int sz = vars.size();

  for (int i = vars.size()-1; i >= 0; i--)
  {
    QName qn = (QName)vars.elementAt(i);
    // System.out.println("qn: "+qn);
    if(qn.equals(m_qname))
    {

      if(i < globalsSize)
      {
        m_isGlobal = true;
        m_index = i;
      }
      else
      {
        m_index = i-globalsSize;
      }

      return;
    }
  }

  java.lang.String msg = XSLMessages.createXPATHMessage(XPATHErrorResources.ER_COULD_NOT_FIND_VAR,
                                           new Object[]{m_qname.toString()});

  TransformerException te = new TransformerException(msg, this);

  throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(te);

}
 
源代码25 项目: jdk1.8-source-analysis   文件: Expression.java
/**
 * Tell the user of an assertion error, and probably throw an
 * exception.
 *
 * @param b  If false, a runtime exception will be thrown.
 * @param msg The assertion message, which should be informative.
 *
 * @throws RuntimeException if the b argument is false.
 *
 * @throws javax.xml.transform.TransformerException
 */
public void assertion(boolean b, java.lang.String msg)
{

  if (!b)
  {
    java.lang.String fMsg = XSLMessages.createXPATHMessage(
      XPATHErrorResources.ER_INCORRECT_PROGRAMMER_ASSERTION,
      new Object[]{ msg });

    throw new RuntimeException(fMsg);
  }
}
 
源代码26 项目: TencentKona-8   文件: XPathExpressionImpl.java
private Object getResultAsType( XObject resultObject, QName returnType )
    throws javax.xml.transform.TransformerException {
    // XPathConstants.STRING
    if ( returnType.equals( XPathConstants.STRING ) ) {
        return resultObject.str();
    }
    // XPathConstants.NUMBER
    if ( returnType.equals( XPathConstants.NUMBER ) ) {
        return new Double ( resultObject.num());
    }
    // XPathConstants.BOOLEAN
    if ( returnType.equals( XPathConstants.BOOLEAN ) ) {
        return new Boolean( resultObject.bool());
    }
    // XPathConstants.NODESET ---ORdered, UNOrdered???
    if ( returnType.equals( XPathConstants.NODESET ) ) {
        return resultObject.nodelist();
    }
    // XPathConstants.NODE
    if ( returnType.equals( XPathConstants.NODE ) ) {
        NodeIterator ni = resultObject.nodeset();
        //Return the first node, or null
        return ni.nextNode();
    }
    // If isSupported check is already done then the execution path
    // shouldn't come here. Being defensive
    String fmsg = XSLMessages.createXPATHMessage(
            XPATHErrorResources.ER_UNSUPPORTED_RETURN_TYPE,
            new Object[] { returnType.toString()});
    throw new IllegalArgumentException ( fmsg );
}
 
源代码27 项目: TencentKona-8   文件: XStringForFSB.java
/**
 * Construct a XNodeSet object.
 *
 * @param val String object this will wrap.
 */
private XStringForFSB(String val)
{

  super(val);

  throw new IllegalArgumentException(
    XSLMessages.createXPATHMessage(XPATHErrorResources.ER_FSB_CANNOT_TAKE_STRING, null)); // "XStringForFSB can not take a string for an argument!");
}
 
源代码28 项目: TencentKona-8   文件: NodeSet.java
/**
 * Set the current position in the node set.
 * @param i Must be a valid index.
 * @throws RuntimeException thrown if this NodeSet is not of
 * a cached type, and thus doesn't permit indexed access.
 */
public void setCurrentPos(int i)
{

  if (!m_cacheNodes)
    throw new RuntimeException(
      XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_CANNOT_INDEX, null)); //"This NodeSet can not do indexing or counting functions!");

  m_next = i;
}
 
源代码29 项目: TencentKona-8   文件: FunctionMultiArgs.java
/**
 * Constructs and throws a WrongNumberArgException with the appropriate
 * message for this function object.  This class supports an arbitrary
 * number of arguments, so this method must never be called.
 *
 * @throws WrongNumberArgsException
 */
protected void reportWrongNumberArgs() throws WrongNumberArgsException {
  String fMsg = XSLMessages.createXPATHMessage(
      XPATHErrorResources.ER_INCORRECT_PROGRAMMER_ASSERTION,
      new Object[]{ "Programmer's assertion:  the method FunctionMultiArgs.reportWrongNumberArgs() should never be called." });

  throw new RuntimeException(fMsg);
}
 
源代码30 项目: TencentKona-8   文件: XStringForChars.java
/**
 * Construct a XNodeSet object.
 *
 * @param val String object this will wrap.
 */
private XStringForChars(String val)
{
  super(val);
  throw new IllegalArgumentException(
                    XSLMessages.createXPATHMessage(XPATHErrorResources.ER_XSTRINGFORCHARS_CANNOT_TAKE_STRING, null)); //"XStringForChars can not take a string for an argument!");
}