Quellcode durchsuchen

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.


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197323 13f79535-47bb-0310-9956-ffa450edef68
tags/Alt-Design_pre_awt_renderer_import
Peter Bernard West vor 20 Jahren
Ursprung
Commit
8ff20f9a1a
1 geänderte Dateien mit 15 neuen und 7 gelöschten Zeilen
  1. 15
    7
      src/java/org/apache/fop/datastructs/Node.java

+ 15
- 7
src/java/org/apache/fop/datastructs/Node.java Datei anzeigen

* Constructor for pre-order iterator. * Constructor for pre-order iterator.
*/ */
public PreOrder() { 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 // so that a call to next() without a preceding call to
// hasNext() will behave sanely // hasNext() will behave sanely
} }
*/ */
public PreOrder(Object sync) { public PreOrder(Object sync) {
synchronized (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 // so that a call to next() without a preceding call to
// hasNext() will behave sanely // hasNext() will behave sanely
} }
} }
public boolean hasNext() { public boolean hasNext() {
return hasNextNode();
}
private boolean hasNextNode() {
if (selfNotReturned) { if (selfNotReturned) {
return true; return true;
} }
// self has been returned - are there any children? // self has been returned - are there any children?
// if so, we must always have an iterator available // 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 // way by next(). The iterator has a chance to do this
// because self will always be returned first. // because self will always be returned first.
// The test of nextChildIndex must always be made because // The test of nextChildIndex must always be made because
} }


public Object next() { public Object next() {
if (! hasNext()) {
if (! hasNextNode()) {
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
if (selfNotReturned) { if (selfNotReturned) {
* Constructor for post-order iterator. * Constructor for post-order iterator.
*/ */
public PostOrder() { 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 // so that a call to next() without a preceding call to
// hasNext() will behave sanely // hasNext() will behave sanely
} }
*/ */
public PostOrder(Object sync) { public PostOrder(Object sync) {
synchronized (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 // so that a call to next() without a preceding call to
// hasNext() will behave sanely // hasNext() will behave sanely
} }
} }
public boolean hasNext() { public boolean hasNext() {
return hasNextNode();
}
private boolean hasNextNode() {
// self is always the last to go // self is always the last to go
if (selfReturned) { // nothing left if (selfReturned) { // nothing left
return false; return false;
} }


public Object next() throws NoSuchElementException { public Object next() throws NoSuchElementException {
if (! hasNext()) {
if (! hasNextNode()) {
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
// Are there any children? // Are there any children?

Laden…
Abbrechen
Speichern