You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by Arnaud Le Hors <le...@locus.apache.org> on 2000/07/07 01:14:31 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/dom CharacterDataImpl.java ChildAndParentNode.java DocumentImpl.java NodeImpl.java ParentNode.java RangeImpl.java

lehors      00/07/06 16:14:30

  Modified:    java/src/org/apache/xerces/dom CharacterDataImpl.java
                        ChildAndParentNode.java DocumentImpl.java
                        NodeImpl.java ParentNode.java RangeImpl.java
  Log:
  minor reorg to make the code more modular:
  updates of Range and NodeIterator objects is now done via notification to
  the document.
  
  Revision  Changes    Path
  1.8       +9 -24     xml-xerces/java/src/org/apache/xerces/dom/CharacterDataImpl.java
  
  Index: CharacterDataImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/CharacterDataImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CharacterDataImpl.java	2000/04/10 22:08:09	1.7
  +++ CharacterDataImpl.java	2000/07/06 23:14:27	1.8
  @@ -58,7 +58,6 @@
   package org.apache.xerces.dom;
   
   import org.w3c.dom.*;
  -import java.util.Enumeration;
   
   import org.apache.xerces.dom.events.MutationEventImpl;
   import org.w3c.dom.events.*;
  @@ -147,7 +146,8 @@
       }
       
       /**
  -     * Sets the content, possibly firing related events, and updating ranges
  +     * Sets the content, possibly firing related events,
  +     * and updating ranges (via notification to the document)
        */
       public void setNodeValue(String value) {
       	if (readOnly())
  @@ -178,13 +178,8 @@
               
       	this.data = value;
       	if (!setValue()) {
  -            // call out to any Ranges to set any boundary index to zero.
  -            Enumeration ranges = ownerDocument().getRanges();
  -            if (ranges != null) {
  -                while ( ranges.hasMoreElements()) {
  -                   ((RangeImpl)ranges.nextElement()).receiveReplacedText(this);
  -                }
  -            }
  +            // notify document
  +            ownerDocument().replacedText(this);
           }
       	
           if(MUTATIONEVENTS)
  @@ -300,13 +295,8 @@
                                    (tailLength > 0 
   		? data.substring(offset + count, offset + count + tailLength) 
                                     : "") );
  -            Enumeration ranges = ownerDocument().getRanges();
  -            if (ranges != null) {
  -                while ( ranges.hasMoreElements()) {
  -                    RangeImpl r = ((RangeImpl)ranges.nextElement());
  -                    r.receiveDeletedText( this,  offset,  count);
  -                }
  -            }
  +            // notify document
  +            ownerDocument().deletedText(this, offset, count);
           }
           catch (StringIndexOutOfBoundsException e) {
           	throw new DOMExceptionImpl(DOMException.INDEX_SIZE_ERR, 
  @@ -337,17 +327,12 @@
               synchronizeData();
           }
           try {
  -       		// Handles mutation event generation, if any
  +            // Handles mutation event generation, if any
               setNodeValueInternal(
                   new StringBuffer(this.data).insert(offset, data).toString()
                   );
  -            Enumeration ranges = ownerDocument().getRanges();
  -            if (ranges != null) {
  -                while ( ranges.hasMoreElements()) {
  -                    RangeImpl r = ((RangeImpl)ranges.nextElement());
  -                    r.receiveInsertedText( this,  offset,  data.length());
  -                }
  -            }
  +            // notify document
  +            ownerDocument().insertedText(this, offset, data.length());
           }
           catch (StringIndexOutOfBoundsException e) {
           	throw new DOMExceptionImpl(DOMException.INDEX_SIZE_ERR, 
  
  
  
  1.7       +3 -18     xml-xerces/java/src/org/apache/xerces/dom/ChildAndParentNode.java
  
  Index: ChildAndParentNode.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/ChildAndParentNode.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ChildAndParentNode.java	2000/06/27 02:25:55	1.6
  +++ ChildAndParentNode.java	2000/07/06 23:14:28	1.7
  @@ -1,4 +1,4 @@
  -/* $Id: ChildAndParentNode.java,v 1.6 2000/06/27 02:25:55 jeffreyr Exp $ */
  +/* $Id: ChildAndParentNode.java,v 1.7 2000/07/06 23:14:28 lehors Exp $ */
   /*
    * The Apache Software License, Version 1.1
    *
  @@ -59,7 +59,6 @@
   package org.apache.xerces.dom;
   
   import java.io.*;
  -import java.util.Enumeration;
   
   import org.w3c.dom.*;
   import org.w3c.dom.events.*;
  @@ -569,22 +568,8 @@
                                          "DOM008 Not found");
           }
   
  -        // call out to any NodeIterators to remove the Node and fix them up
  -        Enumeration iterators = ownerDocument.getNodeIterators();
  -        if (iterators != null) {
  -            while ( iterators.hasMoreElements()) {
  -                ((NodeIteratorImpl)iterators.nextElement())
  -                    .removeNode(oldChild);
  -            }
  -        }
  -        
  -        // call out to any Ranges to remove the Node and fix-up the Range.
  -        Enumeration ranges = ownerDocument.getRanges();
  -        if (ranges != null) {
  -            while (ranges.hasMoreElements()) {
  -                ((RangeImpl)ranges.nextElement()).removeNode(oldChild);
  -            }
  -        }
  +        // notify document
  +        ownerDocument.removedChildNode(oldChild);
   
           ChildNode oldInternal = (ChildNode) oldChild;
   
  
  
  
  1.31      +86 -17    xml-xerces/java/src/org/apache/xerces/dom/DocumentImpl.java
  
  Index: DocumentImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DocumentImpl.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- DocumentImpl.java	2000/06/13 17:28:20	1.30
  +++ DocumentImpl.java	2000/07/06 23:14:28	1.31
  @@ -1079,7 +1079,6 @@
        * removed to free up the DOM Nodes it references.
        * @see #removeNodeIterator
        * @see #removeNodeIterators
  -     * @see #getNodeIterators
        *
        * @param root The root of the iterator.
        * @param whatToShow The whatToShow mask.
  @@ -1098,7 +1097,6 @@
        * removed to free up the DOM Nodes it references.
        * @see #removeNodeIterator
        * @see #removeNodeIterators
  -     * @see #getNodeIterators
        *
        * @param root The root of the iterator.
        * @param whatToShow The whatToShow mask.
  @@ -1185,13 +1183,6 @@
           iterators.removeElement(nodeIterator);
       }
   
  -    /** Return an Enumeration of all NodeIterators. */
  -    public Enumeration getNodeIterators() {
  -        if (iterators == null) return null;
  -
  -        return iterators.elements();
  -    }
  -
       //
       // DocumentRange methods
       //
  @@ -1211,13 +1202,6 @@
           
       }
       
  -    /** Return an Enumeration of all Ranges. */
  -    public Enumeration getRanges() {
  -        if (ranges == null) return null;
  -
  -        return ranges.elements();
  -    }
  -    
       /** Not a client function. Called by Range.detach(),
        *  so a Range can remove itself from the list of
        *  Ranges.
  @@ -1229,8 +1213,93 @@
   
           ranges.removeElement(range);
       }
  -    
       
  +    /**
  +     * A method to be called when some text was changed in a text node,
  +     * so that live objects can be notified.
  +     */
  +    void replacedText(Node node) {
  +        // notify ranges
  +        if (ranges != null) {
  +            Enumeration enum = ranges.elements();
  +            while (enum.hasMoreElements()) {
  +                ((RangeImpl)enum.nextElement()).receiveReplacedText(node);
  +            }
  +        }
  +    }
  +
  +    /**
  +     * A method to be called when some text was deleted from a text node,
  +     * so that live objects can be notified.
  +     */
  +    void deletedText(Node node, int offset, int count) {
  +        // notify ranges
  +        if (ranges != null) {
  +            Enumeration enum = ranges.elements();
  +            while (enum.hasMoreElements()) {
  +                ((RangeImpl)enum.nextElement()).receiveDeletedText(node,
  +                                                                   offset,
  +                                                                   count);
  +            }
  +        }
  +    }
  +
  +    /**
  +     * A method to be called when some text was inserted into a text node,
  +     * so that live objects can be notified.
  +     */
  +    void insertedText(Node node, int offset, int count) {
  +        // notify ranges
  +        if (ranges != null) {
  +            Enumeration enum = ranges.elements();
  +            while (enum.hasMoreElements()) {
  +                ((RangeImpl)enum.nextElement()).receiveInsertedText(node,
  +                                                                    offset,
  +                                                                    count);
  +            }
  +        }
  +    }
  +
  +    /**
  +     * A method to be called when a text node has been split,
  +     * so that live objects can be notified.
  +     */
  +    void splitData(Node node, Node newNode, int offset) {
  +        // notify ranges
  +        if (ranges != null) {
  +            Enumeration enum = ranges.elements();
  +            while (enum.hasMoreElements()) {
  +                ((RangeImpl)enum.nextElement()).receiveSplitData(node,
  +                                                                 newNode,
  +                                                                 offset);
  +            }
  +        }
  +    }
  +
  +    /**
  +     * A method to be called when a node is removed from the tree so that live
  +     * objects can be notified.
  +     */
  +    void removedChildNode(Node oldChild) {
  +
  +        // notify iterators
  +        if (iterators != null) {
  +            Enumeration enum = iterators.elements();
  +            while (enum.hasMoreElements()) {
  +                ((NodeIteratorImpl)enum.nextElement()).removeNode(oldChild);
  +            }
  +        }
  +        
  +        // notify ranges
  +        if (ranges != null) {
  +            Enumeration enum = ranges.elements();
  +            while (enum.hasMoreElements()) {
  +                ((RangeImpl)enum.nextElement()).removeNode(oldChild);
  +            }
  +        }
  +    }
  +
  +
       //
       // DocumentEvent methods
       //
  
  
  
  1.25      +0 -1      xml-xerces/java/src/org/apache/xerces/dom/NodeImpl.java
  
  Index: NodeImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/NodeImpl.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- NodeImpl.java	2000/06/05 16:34:16	1.24
  +++ NodeImpl.java	2000/07/06 23:14:28	1.25
  @@ -58,7 +58,6 @@
   package org.apache.xerces.dom;
   
   import java.io.*;
  -import java.util.Enumeration;
   import java.util.Vector;
   
   import org.w3c.dom.*;
  
  
  
  1.7       +3 -19     xml-xerces/java/src/org/apache/xerces/dom/ParentNode.java
  
  Index: ParentNode.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/ParentNode.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ParentNode.java	2000/06/27 02:25:55	1.6
  +++ ParentNode.java	2000/07/06 23:14:28	1.7
  @@ -1,4 +1,4 @@
  -/* $Id: ParentNode.java,v 1.6 2000/06/27 02:25:55 jeffreyr Exp $ */
  +/* $Id: ParentNode.java,v 1.7 2000/07/06 23:14:28 lehors Exp $ */
   /*
    * The Apache Software License, Version 1.1
    *
  @@ -59,7 +59,6 @@
   package org.apache.xerces.dom;
   
   import java.io.*;
  -import java.util.Enumeration;
   
   import org.w3c.dom.*;
   import org.w3c.dom.events.*;
  @@ -286,7 +285,6 @@
   
       } // getLastChild():Node
   
  -
       final ChildNode lastChild() {
           // last child is stored as the previous sibling of first child
           return firstChild != null ? firstChild.previousSibling : null;
  @@ -580,22 +578,8 @@
                                          "DOM008 Not found");
           }
   
  -        // call out to any NodeIterators to remove the Node and fix them up
  -        Enumeration iterators = ownerDocument.getNodeIterators();
  -        if (iterators != null) {
  -            while ( iterators.hasMoreElements()) {
  -                ((NodeIteratorImpl)iterators.nextElement())
  -                    .removeNode(oldChild);
  -            }
  -        }
  -        
  -        // call out to any Ranges to remove the Node and fix-up the Range.
  -        Enumeration ranges = ownerDocument.getRanges();
  -        if (ranges != null) {
  -            while (ranges.hasMoreElements()) {
  -                ((RangeImpl)ranges.nextElement()).removeNode(oldChild);
  -            }
  -        }
  +        // notify document
  +        ownerDocument.removedChildNode(oldChild);
   
           ChildNode oldInternal = (ChildNode) oldChild;
   
  
  
  
  1.6       +3 -9      xml-xerces/java/src/org/apache/xerces/dom/RangeImpl.java
  
  Index: RangeImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/RangeImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RangeImpl.java	2000/04/07 23:21:15	1.5
  +++ RangeImpl.java	2000/07/06 23:14:29	1.6
  @@ -64,7 +64,6 @@
   import org.apache.xerces.dom.DocumentImpl;
   import org.w3c.dom.range.*;
   import java.util.Vector;
  -import java.util.Enumeration;
   
   /** The RangeImpl class implements the org.w3c.dom.range.Range interface.
    *  <p> Please see the API documentation for the interface classes  
  @@ -794,18 +793,13 @@
       //
       
       /** Signal other Ranges to update their start/end 
  -     *  containers/offsets. The data has already been
  +     *  containers/offsets. The data has already been split
        *  into the two Nodes.
        */
       void signalSplitData(Node node, Node newNode, int offset) {
           fSplitNode = node;
  -        // fix-up other Ranges
  -        Enumeration ranges = fDocument.getRanges();
  -        if (ranges != null) {
  -            while ( ranges.hasMoreElements()) {
  -                ((RangeImpl)ranges.nextElement()).receiveSplitData(node, newNode, offset);
  -            }
  -        }
  +        // notify document
  +        fDocument.splitData(node, newNode, offset);
           fSplitNode = null;
       }