elemtemplateelement.java

来自「java jdk 1.4的源码」· Java 代码 · 共 1,705 行 · 第 1/4 页

JAVA
1,705
字号
          XMLNSDecl decl = (XMLNSDecl) m_prefixTable.elementAt(i);          if (!decl.getIsExcluded() && !(null != ignorePrefix && decl.getPrefix().equals(ignorePrefix)))          {            rhandler.endPrefixMapping(decl.getPrefix());          }        }      }    }    catch(org.xml.sax.SAXException se)    {      throw new TransformerException(se);    }  }    /** The *relative* document order number of this element.   *  @serial */  protected int m_docOrderNumber = -1;    /**   * Set the UID (document order index).   *   * @param kIndex Index of this child.   */  public void setUid(int i)  {    m_docOrderNumber = i;  }  /**   * Get the UID (document order index).   *   * @return Index of this child   */  public int getUid()  {    return m_docOrderNumber;  }  /**   * Parent node.   * @serial   */  protected ElemTemplateElement m_parentNode;  /**   * Get the parent as a Node.   *   * @return This node's parent node   */  public Node getParentNode()  {    return m_parentNode;  }  /**   * Get the parent as an ElemTemplateElement.   *   * @return This node's parent as an ElemTemplateElement   */  public ElemTemplateElement getParentElem()  {    return m_parentNode;  }  /**   * Set the parent as an ElemTemplateElement.   *   * @param parent This node's parent as an ElemTemplateElement   */  public void setParentElem(ElemTemplateElement p)  {    m_parentNode = p;  }  /**   * Next sibling.   * @serial   */  ElemTemplateElement m_nextSibling;  /**   * Get the next sibling (as a Node) or return null.   *   * @return this node's next sibling or null   */  public Node getNextSibling()  {    return m_nextSibling;  }  /**   * Get the previous sibling (as a Node) or return null.   * Note that this may be expensive if the parent has many kids;   * we accept that price in exchange for avoiding the prev pointer   * TODO: If we were sure parents and sibs are always ElemTemplateElements,   * we could hit the fields directly rather than thru accessors.   *   * @return This node's previous sibling or null   */  public Node getPreviousSibling()  {    Node walker = getParentNode(), prev = null;    if (walker != null)      for (walker = walker.getFirstChild(); walker != null;              prev = walker, walker = walker.getNextSibling())      {        if (walker == this)          return prev;      }    return null;  }  /**   * Get the previous sibling (as a Node) or return null.   * Note that this may be expensive if the parent has many kids;   * we accept that price in exchange for avoiding the prev pointer   * TODO: If we were sure parents and sibs are always ElemTemplateElements,   * we could hit the fields directly rather than thru accessors.   *   * @return This node's previous sibling or null   */  public ElemTemplateElement getPreviousSiblingElem()  {    ElemTemplateElement walker = getParentNodeElem();    ElemTemplateElement prev = null;    if (walker != null)      for (walker = walker.getFirstChildElem(); walker != null;              prev = walker, walker = walker.getNextSiblingElem())      {        if (walker == this)          return prev;      }    return null;  }  /**   * Get the next sibling (as a ElemTemplateElement) or return null.   *   * @return This node's next sibling (as a ElemTemplateElement) or null    */  public ElemTemplateElement getNextSiblingElem()  {    return m_nextSibling;  }    /**   * Get the parent element.   *   * @return This node's next parent (as a ElemTemplateElement) or null    */  public ElemTemplateElement getParentNodeElem()  {    return m_parentNode;  }  /**   * First child.   * @serial   */  ElemTemplateElement m_firstChild;  /**   * Get the first child as a Node.   *   * @return This node's first child or null   */  public Node getFirstChild()  {    return m_firstChild;  }  /**   * Get the first child as a ElemTemplateElement.   *   * @return This node's first child (as a ElemTemplateElement) or null   */  public ElemTemplateElement getFirstChildElem()  {    return m_firstChild;  }  /**   * Get the last child.   *   * @return This node's last child   */  public Node getLastChild()  {    ElemTemplateElement lastChild = null;    for (ElemTemplateElement node = m_firstChild; node != null;            node = node.m_nextSibling)    {      lastChild = node;    }    return lastChild;  }  /**   * Get the last child.   *   * @return This node's last child   */  public ElemTemplateElement getLastChildElem()  {    ElemTemplateElement lastChild = null;    for (ElemTemplateElement node = m_firstChild; node != null;            node = node.m_nextSibling)    {      lastChild = node;    }    return lastChild;  }  /** DOM backpointer that this element originated from.          */  transient private org.w3c.dom.Node m_DOMBackPointer;  /**   * If this stylesheet was created from a DOM, get the   * DOM backpointer that this element originated from.   * For tooling use.   *   * @return DOM backpointer that this element originated from or null.   */  public org.w3c.dom.Node getDOMBackPointer()  {    return m_DOMBackPointer;  }  /**   * If this stylesheet was created from a DOM, set the   * DOM backpointer that this element originated from.   * For tooling use.   *   * @param n DOM backpointer that this element originated from.   */  public void setDOMBackPointer(org.w3c.dom.Node n)  {    m_DOMBackPointer = n;  }  /**   * Compares this object with the specified object for precedence order.   * The order is determined by the getImportCountComposed() of the containing   * composed stylesheet and the getUid() of this element.   * Returns a negative integer, zero, or a positive integer as this   * object is less than, equal to, or greater than the specified object.   *    * @param o The object to be compared to this object   * @returns a negative integer, zero, or a positive integer as this object is   *          less than, equal to, or greater than the specified object.   * @throws ClassCastException if the specified object's   *         type prevents it from being compared to this Object.   */  public int compareTo(Object o) throws ClassCastException {        ElemTemplateElement ro = (ElemTemplateElement) o;    int roPrecedence = ro.getStylesheetComposed().getImportCountComposed();    int myPrecedence = this.getStylesheetComposed().getImportCountComposed();    if (myPrecedence < roPrecedence)      return -1;    else if (myPrecedence > roPrecedence)      return 1;    else      return this.getUid() - ro.getUid();  }    /**   * Get information about whether or not an element should strip whitespace.   * @see <a href="http://www.w3.org/TR/xslt#strip">strip in XSLT Specification</a>   *   * @param support The XPath runtime state.   * @param targetElement Element to check   *   * @return true if the whitespace should be stripped.   *   * @throws TransformerException   */  public boolean shouldStripWhiteSpace(          org.apache.xpath.XPathContext support,           org.w3c.dom.Element targetElement) throws TransformerException  {    StylesheetRoot sroot = this.getStylesheetRoot();    return (null != sroot) ? sroot.shouldStripWhiteSpace(support, targetElement) :false;  }    /**   * Get information about whether or not whitespace can be stripped.   * @see <a href="http://www.w3.org/TR/xslt#strip">strip in XSLT Specification</a>   *   * @return true if the whitespace can be stripped.   */  public boolean canStripWhiteSpace()  {    StylesheetRoot sroot = this.getStylesheetRoot();    return (null != sroot) ? sroot.canStripWhiteSpace() : false;  }    /**   * Tell if this element can accept variable declarations.   * @return true if the element can accept and process variable declarations.   */  public boolean canAcceptVariables()  {  	return true;  }    //=============== ExpressionNode methods ================    /**    * Set the parent of this node.   * @param n Must be a ElemTemplateElement.   */  public void exprSetParent(ExpressionNode n)  {  	// This obviously requires that only a ElemTemplateElement can   	// parent a node of this type.  	setParentElem((ElemTemplateElement)n);  }    /**   * Get the ExpressionNode parent of this node.   */  public ExpressionNode exprGetParent()  {  	return getParentElem();  }  /**    * This method tells the node to add its argument to the node's   * list of children.    * @param n Must be a ElemTemplateElement.    */  public void exprAddChild(ExpressionNode n, int i)  {  	appendChild((ElemTemplateElement)n);  }  /** This method returns a child node.  The children are numbered     from zero, left to right. */  public ExpressionNode exprGetChild(int i)  {  	return (ExpressionNode)item(i);  }  /** Return the number of children the node has. */  public int exprGetNumChildren()  {  	return getLength();  }    /**   * Accept a visitor and call the appropriate method    * for this class.   *    * @param visitor The visitor whose appropriate method will be called.   * @return true if the children of the object should be visited.   */  protected boolean accept(XSLTVisitor visitor)  {  	return visitor.visitInstruction(this);  }  /**   * @see XSLTVisitable#callVisitors(XSLTVisitor)   */  public void callVisitors(XSLTVisitor visitor)  {  	if(accept(visitor))  	{		callChildVisitors(visitor);  	}  }  /**   * Call the children visitors.   * @param visitor The visitor whose appropriate method will be called.   */  protected void callChildVisitors(XSLTVisitor visitor, boolean callAttributes)  {    for (ElemTemplateElement node = m_firstChild;      node != null;      node = node.m_nextSibling)      {      node.callVisitors(visitor);    }  }    /**   * Call the children visitors.   * @param visitor The visitor whose appropriate method will be called.   */  protected void callChildVisitors(XSLTVisitor visitor)  {  	callChildVisitors(visitor, true);  }	/**	 * @see PrefixResolver#handlesNullPrefixes()	 */	public boolean handlesNullPrefixes() {		return false;	}}

⌨️ 快捷键说明

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