xrtreefragselectwrapper.java

来自「java jdk 1.4的源码」· Java 代码 · 共 142 行

JAVA
142
字号
package org.apache.xpath.objects;import org.apache.xml.dtm.DTM;import org.apache.xml.dtm.DTMIterator;import org.apache.xml.dtm.DTMFilter;import org.apache.xml.utils.XMLString;import org.apache.xpath.DOMHelper;import org.apache.xpath.XPathContext;import org.apache.xpath.Expression;import org.apache.xalan.res.XSLMessages;import org.apache.xpath.res.XPATHErrorResources;/** * This class makes an select statement act like an result tree fragment. */public class XRTreeFragSelectWrapper extends XRTreeFrag implements Cloneable{  XObject m_selected;  public XRTreeFragSelectWrapper(Expression expr)  {    super(expr);  }    /**   * 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)  {    ((Expression)m_obj).fixupVariables(vars, globalsSize);  }    /**   * For support of literal objects in xpaths.   *   * @param xctxt The XPath execution context.   *   * @return the result of executing the select expression   *   * @throws javax.xml.transform.TransformerException   */  public XObject execute(XPathContext xctxt)          throws javax.xml.transform.TransformerException  {     m_selected = ((Expression)m_obj).execute(xctxt);     m_selected.allowDetachToRelease(m_allowRelease);     return m_selected;  }      /**   * Detaches the <code>DTMIterator</code> from the set which it iterated   * over, releasing any computational resources and placing the iterator   * in the INVALID state. After <code>detach</code> has been invoked,   * calls to <code>nextNode</code> or <code>previousNode</code> will   * raise a runtime exception.   *    * In general, detach should only be called once on the object.   */  public void detach()  {    if(m_allowRelease)    {      m_selected.detach();      m_selected = null;    }        super.detach();  }    /**   * Cast result object to a number.   *   * @return The result tree fragment as a number or NaN   */  public double num()    throws javax.xml.transform.TransformerException  {    return m_selected.num();  }    /**   * Cast result object to an XMLString.   *   * @return The document fragment node data or the empty string.    */  public XMLString xstr()  {    return m_selected.xstr();  }  /**   * Cast result object to a string.   *   * @return The document fragment node data or the empty string.    */  public String str()  {    return m_selected.str();  }    /**   * Tell what kind of class this is.   *   * @return the type of the select expression   */  public int getType()  {    return m_selected.getType();  }  /**   * Cast result object to a result tree fragment.   *   * @return The document fragment this wraps   */  public int rtf()  {    throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_RTF_NOT_SUPPORTED_XRTREEFRAGSELECTWRAPPER, null)); //"rtf() not supported by XRTreeFragSelectWrapper!");  }  /**   * Cast result object to a DTMIterator.   *   * @return The document fragment as a DTMIterator   */  public DTMIterator asNodeIterator()  {    throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_RTF_NOT_SUPPORTED_XRTREEFRAGSELECTWRAPPER, null)); //"asNodeIterator() not supported by XRTreeFragSelectWrapper!");  }}

⌨️ 快捷键说明

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