git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1722662 13f79535-47bb-0310-9956-ffa450edef68pull/39/head
@@ -20,7 +20,6 @@ | |||
package org.apache.fop.fo; | |||
// Java | |||
import java.util.Iterator; | |||
import java.util.ListIterator; | |||
import java.util.Map; | |||
import java.util.Stack; | |||
@@ -321,9 +320,9 @@ public abstract class FONode implements Cloneable { | |||
* has been reached. | |||
* The default implementation simply calls {@link #finalizeNode()}, without | |||
* sending any event to the {@link FOEventHandler}. | |||
* <br/><i>Note: the recommended way to override this method in subclasses is</i> | |||
* <br/><br/><code>super.endOfNode(); // invoke finalizeNode() | |||
* <br/>getFOEventHandler().endXXX(); // send endOfNode() notification</code> | |||
* <p><i>Note: the recommended way to override this method in subclasses is</i></p> | |||
* <p><code>super.endOfNode(); // invoke finalizeNode()</code></p> | |||
* <p><code>getFOEventHandler().endXXX(); // send endOfNode() notification</code></p> | |||
* | |||
* @throws FOPException if there's a problem during processing | |||
*/ | |||
@@ -622,7 +621,7 @@ public abstract class FONode implements Cloneable { | |||
* | |||
* @param propertyName the name of the property. | |||
* @param propertyValue the value of the property. | |||
* * @param e optional property parsing exception. | |||
* @param e optional property parsing exception. | |||
* @throws ValidationException the validation error provoked by the method call | |||
*/ | |||
protected void invalidPropertyValueError(String propertyName, String propertyValue, Exception e) | |||
@@ -936,7 +935,7 @@ public abstract class FONode implements Cloneable { | |||
* @param ranges a stack of delimited text ranges | |||
* @return the (possibly) updated stack of delimited text ranges | |||
*/ | |||
public Stack collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges) { | |||
public Stack<DelimitedTextRange> collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges) { | |||
// if boundary before, then push new range | |||
if (isRangeBoundaryBefore()) { | |||
maybeNewRange(ranges); | |||
@@ -965,9 +964,11 @@ public abstract class FONode implements Cloneable { | |||
* @param currentRange the current range or null (if none) | |||
* @return the (possibly) updated stack of delimited text ranges | |||
*/ | |||
protected Stack collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges, DelimitedTextRange currentRange) { | |||
for (Iterator it = getChildNodes(); (it != null) && it.hasNext();) { | |||
ranges = ((FONode) it.next()).collectDelimitedTextRanges(ranges); | |||
protected Stack<DelimitedTextRange> collectDelimitedTextRanges( | |||
Stack<DelimitedTextRange> ranges, DelimitedTextRange currentRange) { | |||
for (FONodeIterator it = getChildNodes(); (it != null) && it.hasNext();) { | |||
ranges = it.next().collectDelimitedTextRanges(ranges); | |||
} | |||
return ranges; | |||
} | |||
@@ -1011,9 +1012,10 @@ public abstract class FONode implements Cloneable { | |||
} | |||
/** | |||
* Base iterator interface over a FO's children | |||
* Base iterator interface over a FO's children, offering three methods on top of the base interface | |||
* methods {@see java.util.ListIterator}. | |||
*/ | |||
public interface FONodeIterator extends ListIterator { | |||
public interface FONodeIterator extends ListIterator<FONode> { | |||
/** | |||
* Returns the parent node for this iterator's list | |||
@@ -1021,23 +1023,7 @@ public abstract class FONode implements Cloneable { | |||
* | |||
* @return the parent node | |||
*/ | |||
FObj parentNode(); | |||
/** | |||
* Convenience method with return type of FONode | |||
* (semantically equivalent to: <code>(FONode) next();</code>) | |||
* | |||
* @return the next node (if any), as a type FONode | |||
*/ | |||
FONode nextNode(); | |||
/** | |||
* Convenience method with return type of FONode | |||
* (semantically equivalent to: <code>(FONode) previous();</code>) | |||
* | |||
* @return the previous node (if any), as a type FONode | |||
*/ | |||
FONode previousNode(); | |||
FObj parent(); | |||
/** | |||
* Returns the first node in the list, and decreases the index, | |||
@@ -1046,7 +1032,7 @@ public abstract class FONode implements Cloneable { | |||
* | |||
* @return the first node in the list | |||
*/ | |||
FONode firstNode(); | |||
FONode first(); | |||
/** | |||
* Returns the last node in the list, and advances the | |||
@@ -1055,7 +1041,7 @@ public abstract class FONode implements Cloneable { | |||
* | |||
* @return the last node in the list | |||
*/ | |||
FONode lastNode(); | |||
FONode last(); | |||
} | |||
@@ -198,7 +198,7 @@ public abstract class FObj extends FONode implements Constants { | |||
*/ | |||
private void checkId(String id) throws ValidationException { | |||
if (!inMarker() && !id.equals("")) { | |||
Set idrefs = getBuilderContext().getIDReferences(); | |||
Set<String> idrefs = getBuilderContext().getIDReferences(); | |||
if (!idrefs.contains(id)) { | |||
idrefs.add(id); | |||
} else { | |||
@@ -270,7 +270,7 @@ public abstract class FObj extends FONode implements Constants { | |||
if (firstChild != null) { | |||
firstChild.siblings[0] = null; | |||
} | |||
} else { | |||
} else if (child.siblings != null) { | |||
FONode prevChild = child.siblings[0]; | |||
prevChild.siblings[1] = nextChild; | |||
if (nextChild != null) { | |||
@@ -338,7 +338,7 @@ public abstract class FObj extends FONode implements Constants { | |||
return it; | |||
} else { | |||
while (it.hasNext() | |||
&& it.nextNode().siblings[1] != childNode) { | |||
&& it.next().siblings[1] != childNode) { | |||
//nop | |||
} | |||
if (it.hasNext()) { | |||
@@ -373,8 +373,8 @@ public abstract class FObj extends FONode implements Constants { | |||
String mcname = marker.getMarkerClassName(); | |||
if (firstChild != null) { | |||
// check for empty childNodes | |||
for (Iterator iter = getChildNodes(); iter.hasNext();) { | |||
FONode node = (FONode) iter.next(); | |||
for (Iterator<FONode> iter = getChildNodes(); iter.hasNext();) { | |||
FONode node = iter.next(); | |||
if (node instanceof FObj | |||
|| (node instanceof FOText | |||
&& ((FOText) node).willCreateArea())) { | |||
@@ -414,7 +414,7 @@ public abstract class FObj extends FONode implements Constants { | |||
/** {@inheritDoc} */ | |||
protected String getContextInfoAlt() { | |||
StringBuffer sb = new StringBuffer(); | |||
StringBuilder sb = new StringBuilder(); | |||
if (getLocalName() != null) { | |||
sb.append(getName()); | |||
sb.append(", "); | |||
@@ -448,7 +448,7 @@ public abstract class FObj extends FONode implements Constants { | |||
if (iter == null) { | |||
return null; | |||
} | |||
StringBuffer sb = new StringBuffer(); | |||
StringBuilder sb = new StringBuilder(); | |||
while (iter.hasNext()) { | |||
FONode node = (FONode) iter.next(); | |||
String s = node.gatherContextInfo(); | |||
@@ -466,7 +466,7 @@ public abstract class FObj extends FONode implements Constants { | |||
/** | |||
* Convenience method for validity checking. Checks if the | |||
* incoming node is a member of the "%block;" parameter entity | |||
* as defined in Sect. 6.2 of the XSL 1.0 & 1.1 Recommendations | |||
* as defined in Sect. 6.2 of the XSL 1.0 & 1.1 Recommendations | |||
* | |||
* @param nsURI namespace URI of incoming node | |||
* @param lName local name (i.e., no prefix) of incoming node | |||
@@ -486,7 +486,7 @@ public abstract class FObj extends FONode implements Constants { | |||
/** | |||
* Convenience method for validity checking. Checks if the | |||
* incoming node is a member of the "%inline;" parameter entity | |||
* as defined in Sect. 6.2 of the XSL 1.0 & 1.1 Recommendations | |||
* as defined in Sect. 6.2 of the XSL 1.0 & 1.1 Recommendations | |||
* | |||
* @param nsURI namespace URI of incoming node | |||
* @param lName local name (i.e., no prefix) of incoming node | |||
@@ -528,7 +528,7 @@ public abstract class FObj extends FONode implements Constants { | |||
/** | |||
* Convenience method for validity checking. Checks if the | |||
* incoming node is a member of the neutral item list | |||
* as defined in Sect. 6.2 of the XSL 1.0 & 1.1 Recommendations | |||
* as defined in Sect. 6.2 of the XSL 1.0 & 1.1 Recommendations | |||
* @param nsURI namespace URI of incoming node | |||
* @param lName local name (i.e., no prefix) of incoming node | |||
* @return true if a member, false if not | |||
@@ -619,16 +619,16 @@ public abstract class FObj extends FONode implements Constants { | |||
* @param bidiLevel a non-negative bidi embedding level | |||
*/ | |||
public void setBidiLevel(int bidiLevel) { | |||
assert bidiLevel >= 0; | |||
if (bidiLevel >= 0) { | |||
if ((this.bidiLevel < 0) || (bidiLevel < this.bidiLevel)) { | |||
this.bidiLevel = bidiLevel; | |||
if ((parent != null) && !isBidiPropagationBoundary()) { | |||
FObj foParent = (FObj) parent; | |||
int parentBidiLevel = foParent.getBidiLevel(); | |||
if ((parentBidiLevel < 0) || (bidiLevel < parentBidiLevel)) { | |||
foParent.setBidiLevel(bidiLevel); | |||
} | |||
if ((this.bidiLevel < 0) || (bidiLevel < this.bidiLevel)) { | |||
this.bidiLevel = bidiLevel; | |||
if ((parent != null) && !isBidiPropagationBoundary()) { | |||
FObj foParent = (FObj) parent; | |||
int parentBidiLevel = foParent.getBidiLevel(); | |||
if ((parentBidiLevel < 0) || (bidiLevel < parentBidiLevel)) { | |||
foParent.setBidiLevel(bidiLevel); | |||
} | |||
} | |||
} | |||
@@ -765,12 +765,12 @@ public abstract class FObj extends FONode implements Constants { | |||
} | |||
/** {@inheritDoc} */ | |||
public FObj parentNode() { | |||
public FObj parent() { | |||
return parentNode; | |||
} | |||
/** {@inheritDoc} */ | |||
public Object next() { | |||
public FONode next() { | |||
if (currentNode != null) { | |||
if (currentIndex != 0) { | |||
if (currentNode.siblings != null | |||
@@ -789,7 +789,7 @@ public abstract class FObj extends FONode implements Constants { | |||
} | |||
/** {@inheritDoc} */ | |||
public Object previous() { | |||
public FONode previous() { | |||
if (currentNode.siblings != null | |||
&& currentNode.siblings[0] != null) { | |||
currentIndex--; | |||
@@ -802,9 +802,8 @@ public abstract class FObj extends FONode implements Constants { | |||
} | |||
/** {@inheritDoc} */ | |||
public void set(Object o) { | |||
public void set(FONode newNode) { | |||
if ((flags & F_SET_ALLOWED) == F_SET_ALLOWED) { | |||
FONode newNode = (FONode) o; | |||
if (currentNode == parentNode.firstChild) { | |||
parentNode.firstChild = newNode; | |||
} else { | |||
@@ -823,8 +822,7 @@ public abstract class FObj extends FONode implements Constants { | |||
} | |||
/** {@inheritDoc} */ | |||
public void add(Object o) { | |||
FONode newNode = (FONode) o; | |||
public void add(FONode newNode) { | |||
if (currentIndex == -1) { | |||
if (currentNode != null) { | |||
FONode.attachSiblings(newNode, currentNode); | |||
@@ -838,9 +836,9 @@ public abstract class FObj extends FONode implements Constants { | |||
} else { | |||
if (currentNode.siblings != null | |||
&& currentNode.siblings[1] != null) { | |||
FONode.attachSiblings((FONode) o, currentNode.siblings[1]); | |||
FONode.attachSiblings(newNode, currentNode.siblings[1]); | |||
} | |||
FONode.attachSiblings(currentNode, (FONode) o); | |||
FONode.attachSiblings(currentNode, newNode); | |||
if (currentNode == parentNode.lastChild) { | |||
parentNode.lastChild = newNode; | |||
} | |||
@@ -894,7 +892,7 @@ public abstract class FObj extends FONode implements Constants { | |||
} | |||
/** {@inheritDoc} */ | |||
public FONode lastNode() { | |||
public FONode last() { | |||
while (currentNode != null | |||
&& currentNode.siblings != null | |||
&& currentNode.siblings[1] != null) { | |||
@@ -905,20 +903,10 @@ public abstract class FObj extends FONode implements Constants { | |||
} | |||
/** {@inheritDoc} */ | |||
public FONode firstNode() { | |||
public FONode first() { | |||
currentNode = parentNode.firstChild; | |||
currentIndex = 0; | |||
return currentNode; | |||
} | |||
/** {@inheritDoc} */ | |||
public FONode nextNode() { | |||
return (FONode) next(); | |||
} | |||
/** {@inheritDoc} */ | |||
public FONode previousNode() { | |||
return (FONode) previous(); | |||
} | |||
} | |||
} |
@@ -149,7 +149,7 @@ public abstract class FObjMixed extends FObj { | |||
= this.getChildNodes(this.currentTextNode); | |||
FONode node; | |||
while (nodeIter.hasNext()) { | |||
node = nodeIter.nextNode(); | |||
node = nodeIter.next(); | |||
assert (node instanceof FOText | |||
|| node.getNameId() == FO_CHARACTER); | |||
if (node.getNameId() == FO_CHARACTER) { |
@@ -78,7 +78,7 @@ public class Declarations extends FObj { | |||
public void endOfNode() throws FOPException { | |||
if (firstChild != null) { | |||
for (FONodeIterator iter = getChildNodes(); iter.hasNext();) { | |||
FONode node = iter.nextNode(); | |||
FONode node = iter.next(); | |||
if (node.getName().equals("fo:color-profile")) { | |||
ColorProfile cp = (ColorProfile)node; | |||
if (!"".equals(cp.getColorProfileName())) { |
@@ -68,7 +68,7 @@ public class TableRowIterator { | |||
List rowGroupsList = new LinkedList(); | |||
// TODO this is ugly | |||
for (FONodeIterator iter = table.getChildNodes(); iter.hasNext();) { | |||
FONode node = iter.nextNode(); | |||
FONode node = iter.next(); | |||
if (node instanceof TableBody) { | |||
rowGroupsList.addAll(((TableBody) node).getRowGroups()); | |||
} |
@@ -140,7 +140,7 @@ public class CollapsedConditionalBorderTestCase extends AbstractTableTest { | |||
do { | |||
String baseErrorMsge = "table " + Integer.toString(tableNum) + " (0-based), "; | |||
Table table = (Table) tableIterator.next(); | |||
TablePart part = (TablePart) table.getChildNodes().nextNode(); | |||
TablePart part = (TablePart) table.getChildNodes().next(); | |||
GridUnit gu = getGridUnit(part); | |||
String errorMsge = baseErrorMsge + "border-before"; | |||
@@ -182,7 +182,7 @@ public class CollapsedConditionalBorderTestCase extends AbstractTableTest { | |||
resolvedBordersHF[tableNum][borderNum++]); | |||
FONodeIterator bodyIter = table.getChildNodes(); | |||
TableBody body = (TableBody) bodyIter.nextNode(); | |||
TableBody body = (TableBody) bodyIter.next(); | |||
gu = getGridUnit(body); | |||
checkBorder(errorMsge, gu.borderBefore.normal, | |||
resolvedBordersHF[tableNum][borderNum++]); | |||
@@ -197,7 +197,7 @@ public class CollapsedConditionalBorderTestCase extends AbstractTableTest { | |||
checkBorder(errorMsge, gu.borderAfter.rest, | |||
resolvedBordersHF[tableNum][borderNum++]); | |||
body = (TableBody) bodyIter.nextNode(); | |||
body = (TableBody) bodyIter.next(); | |||
gu = getGridUnit(body); | |||
checkBorder(errorMsge, gu.borderBefore.normal, | |||
resolvedBordersHF[tableNum][borderNum++]); |