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

📄 domnode.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            if (child == ref)              {                if (reportMutations)                  {                    removalEvent(null, child);                  }                length--;                if (ref.previous != null)                  {                    ref.previous.next = ref.next;                  }                if (ref.next != null)                  {                    ref.next.previous = ref.previous;                  }                if (first == ref)                  {                    first = ref.next;                  }                if (last == ref)                  {                    last = ref.previous;                  }                // renumber indices                int i = 0;                for (DomNode ctx = first; ctx != null; ctx = ctx.next)                  {                    ctx.index = i++;                  }                ref.parent = null;                ref.setDepth(0);                ref.index = 0;                ref.previous = null;                ref.next = null;                                return ref;              }          }        throw new DomDOMException(DOMException.NOT_FOUND_ERR,                                  "that's no child of mine", refChild, 0);      }    catch (ClassCastException e)      {        throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR,                                  null, refChild, 0);      }  }  /**   * <b>DOM L1 (NodeList)</b>   * Returns the item with the specified index in this NodeList,   * else null.   */  public Node item(int index)  {    DomNode child = first;    int count = 0;    while (child != null && count < index)      {        child = child.next;        count++;      }    return child;  }  /**   * <b>DOM L1 (NodeList)</b>   * Returns the number of elements in this NodeList.   * (Note that many interfaces have a "Length" property, not just   * NodeList, and if a node subtype must implement one of those,   * it will also need to override getChildNodes.)   */  public int getLength()  {    return length;  }  /**   * Minimize extra space consumed by this node to hold children and event   * listeners.   */  public void trimToSize()  {    if (listeners != null && listeners.length != nListeners)      {        ListenerRecord[] newKids = new ListenerRecord[length];        System.arraycopy(listeners, 0, newKids, 0, nListeners);        listeners = newKids;      }  }  /**   * <b>DOM L1</b>   * Returns the previous sibling, if one is known.   */  public Node getNextSibling()  {    return next;  }  /**   * <b>DOM L1</b>   * Returns the previous sibling, if one is known.   */  public Node getPreviousSibling()  {    return previous;  }  /**   * <b>DOM L1</b>   * Returns the parent node, if one is known.   */  public Node getParentNode()  {    return parent;  }  /**   * <b>DOM L2</b>   * Consults the DOM implementation to determine if the requested   * feature is supported.  DocumentType subclasses must override   * this method, and associate themselves directly with the   * DOMImplementation node used.  (This method relies on being able   * to access the DOMImplementation from the owner document, but   * DocumentType nodes can be created without an owner.)   */  public boolean isSupported(String feature, String version)  {    Document		doc = owner;    DOMImplementation	impl = null;        if (doc == null && nodeType == DOCUMENT_NODE)      {        doc = (Document) this;      }    if (doc == null)      {        // possible for DocumentType        throw new IllegalStateException ("unbound ownerDocument");      }    impl = doc.getImplementation();    return impl.hasFeature(feature, version);  }  /**   * <b>DOM L1 (modified in L2)</b>   * Returns the owner document.  This is only null for Document nodes,   * and (new in L2) for DocumentType nodes which have not yet been   * associated with the rest of their document.   */  final public Document getOwnerDocument()  {    return owner;  }  /**   * <b>DOM L1</b>   * Does nothing; this must be overridden (along with the   * getNodeValue method) for nodes with a non-null defined value.   */  public void setNodeValue(String value)  {  }  /**   * <b>DOM L1</b>   * Returns null; this must be overridden for nodes types with   * a defined value, along with the setNodeValue method.   */  public String getNodeValue()  {    return null;  }  /** This forces GCJ compatibility.   * Without this method GCJ is unable to compile to byte code.   */  public final short getNodeType()  {    return nodeType;  }  /** This forces GCJ compatibility.   * Without this method GCJ seems unable to natively compile GNUJAXP.   */  public abstract String getNodeName();  /**   * <b>DOM L2</b>   * Does nothing; this must be overridden (along with the   * getPrefix method) for element and attribute nodes.   */  public void setPrefix(String prefix)  {  }  /**   * <b>DOM L2</b>   * Returns null; this must be overridden for element and   * attribute nodes.   */  public String getPrefix()  {    return null;  }  /**   * <b>DOM L2</b>   * Returns null; this must be overridden for element and   * attribute nodes.   */  public String getNamespaceURI()  {    return null;  }  /**   * <b>DOM L2</b>   * Returns the node name; this must be overridden for element and   * attribute nodes.   */  public String getLocalName()  {    return null;  }  /**   * <b>DOM L1</b>   * Returns a clone of this node which optionally includes cloned   * versions of child nodes.  Clones are always mutable, except for   * entity reference nodes.   */  public Node cloneNode(boolean deep)  {    DomNode node = (DomNode) clone();        if (deep)      {        DomDocument doc = (nodeType == DOCUMENT_NODE) ?          (DomDocument) node : node.owner;        for (DomNode ctx = first; ctx != null; ctx = ctx.next)          {            DomNode newChild = (DomNode) ctx.cloneNode(deep);            newChild.setOwner(doc);            node.appendChild(newChild);          }      }        if (nodeType == ENTITY_REFERENCE_NODE)      {        node.makeReadonly();      }    notifyUserDataHandlers(UserDataHandler.NODE_CLONED, this, node);    return node;  }  void notifyUserDataHandlers(short op, Node src, Node dst)  {    if (userDataHandlers != null)      {        for (Iterator i = userDataHandlers.entrySet().iterator(); i.hasNext(); )          {            Map.Entry entry = (Map.Entry) i.next();            String key = (String) entry.getKey();            UserDataHandler handler = (UserDataHandler) entry.getValue();            Object data = userData.get(key);            handler.handle(op, key, data, src, dst);          }      }  }  /**   * Clones this node; roughly equivalent to cloneNode(false).   * Element subclasses must provide a new implementation which   * invokes this method to handle the basics, and then arranges   * to clone any element attributes directly.  Attribute subclasses   * must make similar arrangements, ensuring that existing ties to   * elements are broken by cloning.   */  public Object clone()  {    try      {        DomNode node = (DomNode) super.clone();                node.parent = null;        node.depth = 0;        node.index = 0;        node.length = 0;        node.first = null;        node.last = null;        node.previous = null;        node.next = null;                node.readonly = false;        node.listeners = null;        node.nListeners = 0;        return node;      }    catch (CloneNotSupportedException x)      {        throw new Error("clone didn't work");      }  }  // the elements-by-tagname stuff is needed for both  // elements and documents ... this is in lieu of a  // common base class between Node and NodeNS.  /**   * <b>DOM L1</b>   * Creates a NodeList giving array-style access to elements with   * the specified name.  Access is fastest if indices change by   * small values, and the DOM is not modified.   */  public NodeList getElementsByTagName(String tag)  {    return new ShadowList(null, tag);  }  /**   * <b>DOM L2</b>   * Creates a NodeList giving array-style access to elements with   * the specified namespace and local name.  Access is fastest if   * indices change by small values, and the DOM is not modified.   */  public NodeList getElementsByTagNameNS(String namespace, String local)  {    return new ShadowList(namespace, local);  }  //  // This shadow class is GC-able even when the live list it shadows  // can't be, because of event registration hookups.  Its finalizer  // makes that live list become GC-able.  //  final class ShadowList    implements NodeList  {    private LiveNodeList liveList;        ShadowList(String ns, String local)    {      liveList = new LiveNodeList(ns, local);    }    public void finalize()    {      liveList.detach();      liveList = null;    }    public Node item(int index)    {      return liveList.item(index);    }    public int getLength()    {      return liveList.getLength();    }  }  final class LiveNodeList    implements NodeList, EventListener, NodeFilter  {     private final boolean matchAnyURI;    private final boolean matchAnyName;     private final String elementURI;    private final String elementName;        private DomIterator current;    private int lastIndex;        LiveNodeList(String uri, String name)    {      elementURI = uri;      elementName = name;      matchAnyURI = "*".equals(uri);      matchAnyName = "*".equals(name);            DomNode.this.addEventListener("DOMNodeInserted", this, true);      DomNode.this.addEventListener("DOMNodeRemoved", this, true);    }    void detach()    {      if (current != null)        current.detach();      current = null;            DomNode.this.removeEventListener("DOMNodeInserted", this, true);      DomNode.this.removeEventListener("DOMNodeRemoved", this, true);    }    public short acceptNode(Node element)    {      if (element == DomNode.this)        {          return FILTER_SKIP;        }      // use namespace-aware matching ...      if (elementURI != null)        {          if (!(matchAnyURI                || elementURI.equals(element.getNamespaceURI())))            {              return FILTER_SKIP;            }          if (!(matchAnyName                || elementName.equals(element.getLocalName())))            {              return FILTER_SKIP;            }          // ... or qName-based kind.        }      else        {          if (!(matchAnyName                || elementName.equals(element.getNodeName())))            {              return FILTER_SKIP;            }        }      return FILTER_ACCEPT;    }    private DomIterator createIterator()    {

⌨️ 快捷键说明

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