cvs commit: xml-fop/src/java/org/apache/fop/datastructs Node.java

2004-02-27 Thread pbwest
pbwest  2004/02/27 18:10:06

  Modified:src/java/org/apache/fop/datastructs Tag:
FOP_0-20-0_Alt-Design Node.java
  Log:
  Removed 'throws IndexOutOfBoundsException' clause from Node(Node) constructor.
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.1.2.8   +3 -4  xml-fop/src/java/org/apache/fop/datastructs/Attic/Node.java
  
  Index: Node.java
  ===
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/datastructs/Attic/Node.java,v
  retrieving revision 1.1.2.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- Node.java 4 Feb 2004 12:17:51 -   1.1.2.7
  +++ Node.java 28 Feb 2004 02:10:06 -  1.1.2.8
  @@ -108,8 +108,7 @@
*   node. 
*/
   
  -public Node(Node parent)
  -throws IndexOutOfBoundsException {
  +public Node(Node parent) {
   this.parent = parent;
   if (parent != null) {
   parent.addChild(this);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: xml-fop/src/java/org/apache/fop/datastructs Node.java

2004-02-04 Thread pbwest
pbwest  2004/02/04 04:17:51

  Modified:src/java/org/apache/fop/datastructs Tag:
FOP_0-20-0_Alt-Design Node.java
  Log:
  Added private method hasNextNode() as the implementation
  of hasNode().  Made constructors refer to this method to
  bypass scope problems in the superclass constructor for
  SyncedNode.PreOrder, etc.
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.1.2.7   +17 -9 xml-fop/src/java/org/apache/fop/datastructs/Attic/Node.java
  
  Index: Node.java
  ===
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/datastructs/Attic/Node.java,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- Node.java 1 Feb 2004 08:12:00 -   1.1.2.6
  +++ Node.java 4 Feb 2004 12:17:51 -   1.1.2.7
  @@ -528,7 +528,7 @@
* Constructor for pre-order iterator.
*/
   public PreOrder() {
  -hasNext();  // A call to set up the initial iterators
  +hasNextNode();  // A call to set up the initial iterators
   // so that a call to next() without a preceding call to
   // hasNext() will behave sanely
   }
  @@ -538,19 +538,23 @@
*/
   public PreOrder(Object sync) {
   synchronized (sync) {
  -hasNext();  // A call to set up the initial iterators
  +hasNextNode();  // A call to set up the initial iterators
   // so that a call to next() without a preceding call to
   // hasNext() will behave sanely
   }
   }
   
   public boolean hasNext() {
  +return hasNextNode();
  +}
  +
  +private boolean hasNextNode() {
   if (selfNotReturned) {
   return true;
   }
   // self has been returned - are there any children?
   // if so, we must always have an iterator available
  -// even unless it is exhausted.  Assume it is set up this 
  +// even if it is exhausted.  Assume it is set up this 
   // way by next().  The iterator has a chance to do this 
   // because self will always be returned first.
   // The test of nextChildIndex must always be made because
  @@ -566,7 +570,7 @@
   }
   
   public Object next() {
  -if (! hasNext()) {
  +if (! hasNextNode()) {
   throw new NoSuchElementException();
   }
   if (selfNotReturned) {
  @@ -640,7 +644,7 @@
* Constructor for post-order iterator.
*/
   public PostOrder() {
  -hasNext();  // A call to set up the initial iterators
  +hasNextNode();  // A call to set up the initial iterators
   // so that a call to next() without a preceding call to
   // hasNext() will behave sanely
   }
  @@ -651,13 +655,17 @@
*/
   public PostOrder(Object sync) {
   synchronized (sync) {
  -hasNext();  // A call to set up the initial iterators
  +hasNextNode();  // A call to set up the initial iterators
   // so that a call to next() without a preceding call to
   // hasNext() will behave sanely
   }
   }
   
   public boolean hasNext() {
  +return hasNextNode();
  +}
  +
  +private boolean hasNextNode() {
   // self is always the last to go
   if (selfReturned) { // nothing left
   return false;
  @@ -677,7 +685,7 @@
   }
   
   public Object next() throws NoSuchElementException {
  -if (! hasNext()) {
  +if (! hasNextNode()) {
   throw new NoSuchElementException();
   }
   // Are there any children?
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: xml-fop/src/java/org/apache/fop/datastructs Node.java

2004-01-28 Thread pbwest
pbwest  2004/01/28 18:53:37

  Modified:src/java/org/apache/fop/datastructs Tag:
FOP_0-20-0_Alt-Design Node.java
  Log:
  Added:
  getPrecedingSibling
  getFollowingSibling
  precedingLeaf
  followingLeaf
  to support resolution of keeps and space-specifiers.
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.1.2.5   +153 -12   xml-fop/src/java/org/apache/fop/datastructs/Attic/Node.java
  
  Index: Node.java
  ===
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/datastructs/Attic/Node.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- Node.java 28 Jan 2004 06:19:56 -  1.1.2.4
  +++ Node.java 29 Jan 2004 02:53:37 -  1.1.2.5
  @@ -181,7 +181,7 @@
   }
   
   /**
  - * Insert a subtree at a specified index position in the child list.
  + * Inserts a subtree at a specified index position in the child list.
* @param index position of subtree within children
* @param subtree to insert
* @throws IndexOutOfBoundsException
  @@ -194,7 +194,7 @@
   }
   
   /**
  - * Add a subtree to the child list.
  + * Adds a subtree to the child list.
* @param subtree to insert
* @throws IndexOutOfBoundsException
*/
  @@ -382,7 +382,7 @@
   }
   
   /**
  - * Delete codethis/code subtree and return a count of the deleted
  + * Deletes codethis/code subtree and returns a count of the deleted
* nodes.  The deletion is effected by cutting the references between
* codethis/code and its parent (if any).  All other relationships
* within the subtree are maintained.
  @@ -430,7 +430,7 @@
   }
   
   /**
  - * Get the parent of this ttNode/tt.
  + * Gets the parent of this ttNode/tt.
* @return the parent ttNode/tt.
*/
   public Node getParent() {
  @@ -443,7 +443,7 @@
   }
   
   /**
  - * Set the iparent/i field of this node.
  + * Sets the iparent/i field of this node.
* @param parent the reference to set
*/
   public void setParent(Node parent) {
  @@ -457,7 +457,7 @@
   }
   
   /**
  - * Nullify the parent ttNode/tt of this node.
  + * Nullifies the parent ttNode/tt of this node.
*/
   public void unsetParent() {
   if (synchronize) {
  @@ -469,7 +469,7 @@
   }
   
   /**
  - * Get the n'th child of this node.
  + * Gets the n'th child of this node.
* @param n - the ttint/tt index of the child to return.
* @return the ttNode/tt reference to the n'th child.
*/
  @@ -485,7 +485,7 @@
   }
   
   /**
  - * Get an ttIterator/tt over the children of this node.
  + * Gets an ttIterator/tt over the children of this node.
* @return the ttIterator/tt.
*/
   public Iterator nodeChildren() {
  @@ -500,7 +500,7 @@
   }
   
   /**
  - * Get the number of children of this node.
  + * Gets the number of children of this node.
* @return the ttint/tt number of children.
*/
   public int numChildren() {
  @@ -513,7 +513,148 @@
   if (children == null) return 0;
   return children.size();
   }
  -
  +
  +/**
  + * Gets the preceding sibling of this codeNode/code,
  + * or codenull/code if none.
  + * @return the sibling node
  + */
  +public Node getPrecedingSibling() {
  +if (synchronize) {
  +synchronized (this) {
  +if (this.parent == null) return null;
  +int thisChild = parent.children.indexOf(this);
  +if (thisChild == 0) return null;
  +return parent.getChild(--thisChild);
  +}
  +}
  +if (this.parent == null) return null;
  +int thisChild = parent.children.indexOf(this);
  +if (thisChild == 0) return null;
  +return parent.getChild(--thisChild);
  +}
  +
  +/**
  + * Gets the following sibling of this codeNode/code,
  + * or codenull/code if none.
  + * @return the sibling node
  + */
  +public Node getFollowingSibling() {
  +if (synchronize) {
  +synchronized (this) {
  +if (this.parent == null) return null;
  +int thisChild = parent.children.indexOf(this);
  +if (++thisChild = parent.numChildren()) return null;
  +return parent.getChild(thisChild);
  +}
  +}
  +if (this.parent == null) return null;
  +int thisChild = parent.children.indexOf(this);
  +if (++thisChild = parent.numChildren()) return null;
  +return parent.getChild(thisChild);
  +}
  +
  +/**
  + * Gets the leaf codeNode/code immediately preceding this node in the
  +

cvs commit: xml-fop/src/java/org/apache/fop/datastructs Node.java

2004-01-27 Thread pbwest
pbwest  2004/01/26 15:03:53

  Modified:src/java/org/apache/fop/datastructs Tag:
FOP_0-20-0_Alt-Design Node.java
  Log:
  Removed Tree reference from Node.  The intention is to
  allow floating subtrees during Area tree construction.
  Previously, the containing Tree reference was used as the
  synchronization object.  Now synchronization is effected on
  methods (instance sync).  However, this leaves some
  constructors with dubvious synchronization.
  Updated license to 2.0.
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.1.2.3   +239 -512  xml-fop/src/java/org/apache/fop/datastructs/Attic/Node.java
  
  Index: Node.java
  ===
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/datastructs/Attic/Node.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Node.java 5 Jan 2004 01:45:32 -   1.1.2.2
  +++ Node.java 26 Jan 2004 23:03:53 -  1.1.2.3
  @@ -1,68 +1,29 @@
   /*
  +   Copyright 2004 The Apache Software Foundation.
  +
  +   Licensed under the Apache License, Version 2.0 (the License);
  +   you may not use this file except in compliance with the License.
  +   You may obtain a copy of the License at
  +
  +   http://www.apache.org/licenses/LICENSE-2.0
  +
  +   Unless required by applicable law or agreed to in writing, software
  +   distributed under the License is distributed on an AS IS BASIS,
  +   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  +   See the License for the specific language governing permissions and
  +   limitations under the License.
  +
* $Id$
  - *
  - * 
  - * 
  - *   The Apache Software License, Version 1.1
  - * 
  - * 
  - * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  - * 
  - * Redistribution and use in source and binary forms, with or without modifica-
  - * tion, are permitted provided that the following conditions are met:
  - * 
  - * 1. Redistributions of  source code must  retain the above copyright  notice,
  - *this list of conditions and the following disclaimer.
  - * 
  - * 2. Redistributions in binary form must reproduce the above copyright notice,
  - *this list of conditions and the following disclaimer in the documentation
  - *and/or other materials provided with the distribution.
  - * 
  - * 3. The end-user documentation included with the redistribution, if any, must
  - *include  the following  acknowledgment:  This product includes  software
  - *developed  by the  Apache Software Foundation  (http://www.apache.org/).
  - *Alternately, this  acknowledgment may  appear in the software itself,  if
  - *and wherever such third-party acknowledgments normally appear.
  - * 
  - * 4. The names FOP and  Apache Software Foundation  must not be used to
  - *endorse  or promote  products derived  from this  software without  prior
  - *written permission. For written permission, please contact
  - *[EMAIL PROTECTED]
  - * 
  - * 5. Products  derived from this software may not  be called Apache, nor may
  - *Apache appear  in their name,  without prior written permission  of the
  - *Apache Software Foundation.
  - * 
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  - * FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  - * APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - * INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - * DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - * OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - * ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - * (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  - * 
  - * This software  consists of voluntary contributions made  by many individuals
  - * on  behalf of the Apache Software  Foundation and was  originally created by
  - * James Tauber [EMAIL PROTECTED]. For more  information on the Apache 
  - * Software Foundation, please see http://www.apache.org/.
  - *  
  - *
*/
   
   package org.apache.fop.datastructs;
   
   import java.util.ArrayList;
  -import java.util.ConcurrentModificationException;
   import java.util.NoSuchElementException;
   import java.util.Iterator;
   import java.util.ListIterator;
   
   /*
  - * @author a href=mailto:[EMAIL PROTECTED]Peter B. West/a
  - * @version 

cvs commit: xml-fop/src/java/org/apache/fop/datastructs Node.java

2004-01-27 Thread pbwest
pbwest  2004/01/27 22:19:56

  Modified:src/java/org/apache/fop/datastructs Tag:
FOP_0-20-0_Alt-Design Node.java
  Log:
  Added optional synchronization.
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.1.2.4   +357 -190  xml-fop/src/java/org/apache/fop/datastructs/Attic/Node.java
  
  Index: Node.java
  ===
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/datastructs/Attic/Node.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- Node.java 26 Jan 2004 23:03:53 -  1.1.2.3
  +++ Node.java 28 Jan 2004 06:19:56 -  1.1.2.4
  @@ -1,5 +1,5 @@
   /*
  -   Copyright 2004 The Apache Software Foundation.
  +   Copyright 2002-2004 The Apache Software Foundation.
   
  Licensed under the Apache License, Version 2.0 (the License);
  you may not use this file except in compliance with the License.
  @@ -59,135 +59,157 @@
   
   public class Node implements Cloneable {
   
  +/** The parent of this node.  If null, this is the root node. */
   protected Node parent;
  +/** An array of the children of this node. */
   protected ArrayList children; // ArrayList of Node
   /** Creation size of the ichildren/i ttArrayList/tt. */
   private static final int FAMILYSIZE = 4;
  +
  +/** Constant codeboolean/code for synchronization argument.  */
  +public static final boolean SYNCHRONIZE = true;
  +/** Constant codeboolean/code for synchronization argument.  */
  +public static final boolean DONT_SYNCHRONIZE = ! SYNCHRONIZE;
  +
  +public final boolean synchronize;
  +
  +/**
  + * This immutable empty array is provided as a convenient class-level
  + * synchronization object for circumstances where such synchronization
  + * is required.
  + */
  +public static final boolean[] sync = new boolean[0];
   
   /**
* No argument constructor.
  - *
  - * Assumes that this node is the root, and so will throw a
  - * ttTreeException/tt when the root node in the enclosing
  - * ttTree/tt object is non-null.
  + * Assumes that this node is the root of a new tree.
*/
   
   public Node() {
  +synchronize = false;
   parent = null;
   }
   
   /**
  - * @param parent Node which is the parent of this Node.  if this is
  - *   null, the generated Node is assumed to be the root
  - *   node.  If the Tree root node is already set, throws
  - *   a ttTreeException/tt.
  - * @param index  int index of child in parent.
  + * Constructor with specific synchronization flag.
  + * @param synchronize flag for synchronization
  + */
  +public Node(boolean synchronize) {
  +this.synchronize = synchronize;
  +parent = null;
  +}
  +
  +/**
  + * Adds a codeNode/code as a child at a given index position among
  + * its parent's children.
  + * @param parent of this Node
  + * @param index of child in parent.  If the parent reference
  + * is codenull/code, an IndexOutOfBoundsException is thrown.
  + * @param synchronize if true, synchronizes on the parent.
*/
   
  -public Node(Node parent, int index)
  -throws IndexOutOfBoundsException {
  +public Node(Node parent, int index, boolean synchronize)
  +throws IndexOutOfBoundsException {
   if (parent == null) {
  -this.parent = null;
  +throw new IndexOutOfBoundsException(Null parent);
   }
   else {
  +this.synchronize = synchronize;
   this.parent = parent;
  -// connect me to my parent
   parent.addChild(index, this);
   }
   }
  -
  +
   /**
  - * @param parent Node which is the parent of this Node.  if this is
  + * Adds a codeNode/code as a child of the given parent.
  + * @param parent of this Node.  if this is
*   null, the generated Node is assumed to be the root
*   node. 
  + * @param synchronize if true, synchronizes on the parent.
*/
   
  -public Node(Node parent)
  +public Node(Node parent, boolean synchronize)
   throws IndexOutOfBoundsException {
  -if (parent == null) {
  -this.parent = null;
  -}
  -else {
  -this.parent = parent;
  -// connect me to my parent
  +this.synchronize = synchronize;
  +this.parent = parent;
  +if (parent != null) {
   parent.addChild(this);
   }
   }
   
   
   /**
  - * Appends a child ttNode/tt to this node.  Synchronized on the
  - * containing ttTree/tt object.
  - *
  - * Calls the imodified/i method of the containing 

cvs commit: xml-fop/src/java/org/apache/fop/datastructs Node.java

2004-01-04 Thread pbwest
pbwest  2004/01/04 17:45:32

  Modified:src/java/org/apache/fop/datastructs Tag:
FOP_0-20-0_Alt-Design Node.java
  Log:
  Made children protected.
  Removed redundant casts flagged by Eclipse.
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.1.2.2   +9 -9  xml-fop/src/java/org/apache/fop/datastructs/Attic/Node.java
  
  Index: Node.java
  ===
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/datastructs/Attic/Node.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Node.java 5 Jul 2003 19:06:35 -   1.1.2.1
  +++ Node.java 5 Jan 2004 01:45:32 -   1.1.2.2
  @@ -97,7 +97,7 @@
   
   protected Tree tree;
   protected Node parent;
  -private ArrayList children; // ArrayList of Node
  +protected ArrayList children; // ArrayList of Node
   /** Creation size of the ichildren/i ttArrayList/tt. */
   private static final int FAMILYSIZE = 4;
   
  @@ -199,7 +199,7 @@
   synchronized (tree) {
   if (children == null)
   children = new ArrayList(FAMILYSIZE);
  -children.add((Object) child);
  +children.add(child);
   tree.modified();
   }
   }
  @@ -221,7 +221,7 @@
   synchronized (tree) {
   if (children == null)
   children = new ArrayList(FAMILYSIZE);
  -children.add(index, (Object) child);
  +children.add(index, child);
   tree.modified();
   }
   }
  @@ -418,7 +418,7 @@
   public Node removeChild(Node child)
   throws NoSuchElementException {
   synchronized (tree) {
  -int index = children.indexOf((Object) child);
  +int index = children.indexOf(child);
   if (index == -1) {
   throw new NoSuchElementException();
   }
  @@ -531,7 +531,7 @@
* @return the parent ttNode/tt.
*/
   public Node getParent() {
  -return (Node) parent;
  +return parent;
   }
   
   /**
  @@ -956,7 +956,7 @@
   // Not the root node; siblings may exist
   // Set up iterator on the parent's children ArrayList
   ArrayList siblings = refNode.children;
  -int index = siblings.indexOf((Object) Node.this);
  +int index = siblings.indexOf(Node.this);
   // if this is invalid, we are in serious trouble
   listIterator = siblings.listIterator(index + 1);
   } // end of if (Node.this.parent != null)
  @@ -1068,7 +1068,7 @@
   // Not the root node; siblings may exist
   // Set up iterator on the parent's children ArrayList
   ArrayList siblings = refNode.children;
  -int index = siblings.indexOf((Object) Node.this);
  +int index = siblings.indexOf(Node.this);
   // if this is invalid, we are in serious trouble
   listIterator = siblings.listIterator(index);
   } // end of if (Node.this.parent != null)
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]