You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ma...@apache.org on 2008/06/10 09:52:37 UTC

svn commit: r665995 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop: layoutmgr/ layoutmgr/inline/ layoutmgr/table/ util/

Author: maxberger
Date: Tue Jun 10 00:52:36 2008
New Revision: 665995

URL: http://svn.apache.org/viewvc?rev=665995&view=rev
Log:
Replaced getLast() calls with calls to listUtil

Added:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ListUtil.java   (with props)
Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java?rev=665995&r1=665994&r2=665995&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java Tue Jun 10 00:52:36 2008
@@ -28,6 +28,7 @@
 
 import org.apache.fop.fo.Constants;
 import org.apache.fop.traits.MinOptMax;
+import org.apache.fop.util.ListUtil;
 
 /**
  * Abstract base class for breakers (page breakers, static region handlers etc.).
@@ -116,8 +117,8 @@
         public KnuthSequence endSequence(Position breakPosition) {
             // remove glue and penalty item at the end of the paragraph
             while (this.size() > ignoreAtStart
-                   && !((KnuthElement)this.get(this.size() - 1)).isBox()) {
-                this.remove(this.size() - 1);
+                    && !((KnuthElement) ListUtil.getLast(this)).isBox()) {
+                ListUtil.removeLast(this);
             }
             if (this.size() > ignoreAtStart) {
                 // add the elements representing the space at the end of the last line
@@ -215,7 +216,7 @@
 
     /** @return true if there's no content that could be handled. */
     public boolean isEmpty() {
-        return (this.blockLists.size() == 0);
+        return (this.blockLists.isEmpty());
     }
     
     protected void startPart(BlockSequence list, int breakClass) {
@@ -551,7 +552,7 @@
         BlockSequence blockList;
         List returnedList = getNextKnuthElements(childLC, alignment);
         if (returnedList != null) {
-            if (returnedList.size() == 0) {
+            if (returnedList.isEmpty()) {
                 nextSequenceStartsOn = handleSpanChange(childLC, nextSequenceStartsOn);
                 return nextSequenceStartsOn;
             }
@@ -561,10 +562,9 @@
             nextSequenceStartsOn = handleSpanChange(childLC, nextSequenceStartsOn);
             
             Position breakPosition = null;
-            if (((KnuthElement) returnedList.get(returnedList.size() - 1))
-                    .isForcedBreak()) {
-                KnuthPenalty breakPenalty = (KnuthPenalty) returnedList
-                        .remove(returnedList.size() - 1);
+            if (((KnuthElement) ListUtil.getLast(returnedList)).isForcedBreak()) {
+                KnuthPenalty breakPenalty = (KnuthPenalty) ListUtil
+                        .removeLast(returnedList);
                 breakPosition = breakPenalty.getPosition();
                 switch (breakPenalty.getBreakClass()) {
                 case Constants.EN_PAGE:
@@ -745,12 +745,12 @@
                     if (!bBoxSeen) {
                         // this is the first box met in this page
                         bBoxSeen = true;
-                    } else if (unconfirmedList.size() > 0) {
-                        // glue items in unconfirmedList were not after
-                        // the last box
-                        // in this page; they must be added to
-                        // blockSpaceList
-                        while (unconfirmedList.size() > 0) {
+                    } else {
+                        while (!unconfirmedList.isEmpty()) {
+                            // glue items in unconfirmedList were not after
+                            // the last box
+                            // in this page; they must be added to
+                            // blockSpaceList
                             KnuthGlue blockSpace = (KnuthGlue) unconfirmedList
                                     .removeFirst();
                             spaceMaxAdjustment.max += ((KnuthGlue) blockSpace)

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java?rev=665995&r1=665994&r2=665995&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java Tue Jun 10 00:52:36 2008
@@ -39,6 +39,7 @@
 import org.apache.fop.fo.properties.CommonAbsolutePosition;
 import org.apache.fop.traits.MinOptMax;
 import org.apache.fop.traits.SpaceVal;
+import org.apache.fop.util.ListUtil;
 
 /**
  * LayoutManager for a block-container FO.
@@ -285,7 +286,7 @@
 
                 // get elements from curLM
                 returnedList = curLM.getNextKnuthElements(childLC, alignment);
-                if (contentList.size() == 0 && childLC.isKeepWithPreviousPending()) {
+                if (contentList.isEmpty() && childLC.isKeepWithPreviousPending()) {
                     //Propagate keep-with-previous up from the first child
                     context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending());
                     childLC.clearKeepWithPreviousPending();
@@ -317,12 +318,12 @@
                         addInBetweenBreak(contentList, context, childLC);
                     }
                     contentList.addAll(returnedList);
-                    if (returnedList.size() == 0) {
+                    if (returnedList.isEmpty()) {
                         //Avoid NoSuchElementException below (happens with empty blocks)
                         continue;
                     }
-                    if (((ListElement) returnedList
-                            .get(returnedList.size() - 1)).isForcedBreak()) {
+                    if (((ListElement) ListUtil.getLast(returnedList))
+                            .isForcedBreak()) {
                         // a descendant of this block has break-after
                         if (curLM.isFinished()) {
                             // there is no other content in this block;
@@ -754,7 +755,7 @@
                     // pos was created by this BCLM and was inside an element
                     // representing space before or after
                     // this means the space was not discarded
-                    if (positionList.size() == 0 && bcpos == null) {
+                    if (positionList.isEmpty() && bcpos == null) {
                         // pos was in the element representing space-before
                         bSpaceBefore = true;
                     } else {
@@ -801,9 +802,10 @@
                 //    // between consecutive pages
                 List splitList = new LinkedList();
                 int splitLength = 0;
-                int iFirst = ((MappingPosition) positionList.get(0)).getFirstIndex();
-                int iLast = ((MappingPosition) positionList.get(positionList
-                        .size() - 1)).getLastIndex();
+                int iFirst = ((MappingPosition) positionList.get(0))
+                        .getFirstIndex();
+                int iLast = ((MappingPosition) ListUtil.getLast(positionList))
+                        .getLastIndex();
                 // copy from storedList to splitList all the elements from
                 // iFirst to iLast
                 ListIterator storedListIterator = storedList.listIterator(iFirst);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java?rev=665995&r1=665994&r2=665995&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java Tue Jun 10 00:52:36 2008
@@ -36,6 +36,7 @@
 import org.apache.fop.layoutmgr.inline.InlineLayoutManager;
 import org.apache.fop.layoutmgr.inline.LineLayoutManager;
 import org.apache.fop.traits.MinOptMax;
+import org.apache.fop.util.ListUtil;
 
 /**
  * Base LayoutManager class for all areas which stack their child
@@ -296,7 +297,7 @@
 
             // get elements from curLM
             returnedList = curLM.getNextKnuthElements(childLC, alignment);
-            if (contentList.size() == 0 && childLC.isKeepWithPreviousPending()) {
+            if (contentList.isEmpty() && childLC.isKeepWithPreviousPending()) {
                 //Propagate keep-with-previous up from the first child
                 context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending());
                 childLC.clearKeepWithPreviousPending();
@@ -312,7 +313,7 @@
                     break;
                 }
 
-                if (contentList.size() == 0) {
+                if (contentList.isEmpty()) {
                     // Empty fo:block, zero-length box makes sure the IDs and/or markers 
                     // are registered and borders/padding are painted.
                     returnList.add(new KnuthBox(0, notifyPos(new Position(this)), false));
@@ -339,17 +340,17 @@
                     // before the one handled by curLM
                     addInBetweenBreak(contentList, context, childLC);
                 }
-                if (returnedList == null || returnedList.size() == 0) {
+                if (returnedList == null || returnedList.isEmpty()) {
                     //Avoid NoSuchElementException below (happens with empty blocks)
                     continue;
                 }
                 contentList.addAll(returnedList);
-                if (((ListElement) returnedList.get(returnedList.size() - 1))
+                if (((ListElement) ListUtil.getLast(returnedList))
                         .isForcedBreak()) {
                     // a descendant of this block has break-after
                     if (curLM.isFinished() && !hasNextChildLM()) {
-                        forcedBreakAfterLast = (BreakElement) contentList
-                                .remove(contentList.size() - 1);
+                        forcedBreakAfterLast = (BreakElement) ListUtil
+                                .removeLast(contentList);                                
                         context.clearPendingMarks();
                         break;
                     }
@@ -381,7 +382,7 @@
         /* end of extension */
 
         returnedList = new LinkedList();
-        if (contentList.size() > 0) {
+        if (!contentList.isEmpty()) {
             wrapPositionElements(contentList, returnList);
         } else if (forcedBreakAfterLast == null) {
             // Empty fo:block, zero-length box makes sure the IDs and/or markers 
@@ -440,8 +441,7 @@
             return;
         }
         
-        ListElement last = (ListElement) contentList
-                .get(contentList.size() - 1); 
+        ListElement last = (ListElement) ListUtil.getLast(contentList);
         if (last.isGlue()) {
             // the last element in contentList is a glue;
             // it is a feasible breakpoint, there is no need to add
@@ -695,8 +695,8 @@
                     returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, 
                             new Position(this), false));
                 } else if (bSomethingAdded
-                        && !((KnuthElement) returnedList.get(returnedList
-                                .size() - 1)).isGlue()) {
+                        && !((KnuthElement) ListUtil.getLast(returnedList))
+                                .isGlue()) {
                     // add a null penalty to allow a break between blocks
                     returnedList.add(new KnuthPenalty(0, 0, false, new Position(this), false));
                 }
@@ -715,8 +715,8 @@
                 // currLM == this
                 // there are no more elements to add
                 // remove the last penalty added to returnedList
-                if (returnedList.size() > 0) {
-                    returnedList.remove(returnedList.size() - 1);
+                if (!returnedList.isEmpty()) {
+                    ListUtil.removeLast(returnedList);
                 }
                 //log.debug(" BLM.getChangedKnuthElements> elementi propri, ignorati, da " 
                 //  + fromIndex + " a " + workList.size());
@@ -1407,7 +1407,7 @@
             oldList.remove(0);
         }
         if (adjustedSpaceAfter > 0) {
-            oldList.remove(oldList.size() - 1);
+            ListUtil.removeLast(oldList);
         }
 
         // if space-before.conditionality is "discard", correct newList
@@ -1464,7 +1464,7 @@
             newList.addLast(new KnuthBox(wrongBox.getW() - decreasedLength,
                                          wrongBox.getPosition(), false));
             // add preserved elements
-            if (preserveList.size() > 0) {
+            if (!preserveList.isEmpty()) {
                 newList.addAll(preserveList);
             }
             // insert the correct glue

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java?rev=665995&r1=665994&r2=665995&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java Tue Jun 10 00:52:36 2008
@@ -19,16 +19,20 @@
 
 package org.apache.fop.layoutmgr;
 
-import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
 
 import org.apache.fop.traits.MinOptMax;
+import org.apache.fop.util.ListUtil;
 
 /**
  * Utilities for Knuth element lists.
  */
-public class ElementListUtils {
+public final class ElementListUtils {
+    
+    private ElementListUtils() {
+        // Utility class.
+    }
 
     /**
      * Removes legal breaks in an element list. A constraint can be specified to limit the
@@ -185,7 +189,7 @@
      * @return true if the list ends with a forced break
      */
     public static boolean endsWithForcedBreak(List elems) {
-        ListElement last = (ListElement) elems.get(elems.size() - 1);
+        ListElement last = (ListElement) ListUtil.getLast(elems);
         return last.isForcedBreak();
     }
 
@@ -196,7 +200,7 @@
      * @return true if the list ends with a non-infinite penalty
      */
     public static boolean endsWithNonInfinitePenalty(List elems) {
-        ListElement last = (ListElement) elems.get(elems.size() - 1);
+        ListElement last = (ListElement) ListUtil.getLast(elems);
         if (last.isPenalty() && ((KnuthPenalty)last).getP() < KnuthElement.INFINITE) {
             return true;
         } else if (last instanceof BreakElement

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java?rev=665995&r1=665994&r2=665995&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java Tue Jun 10 00:52:36 2008
@@ -38,6 +38,7 @@
 import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager;
 import org.apache.fop.layoutmgr.inline.TextLayoutManager;
 import org.apache.fop.traits.MinOptMax;
+import org.apache.fop.util.ListUtil;
 
 /**
  * LayoutManager for an fo:flow object.
@@ -142,7 +143,7 @@
                 returnList.addAll(returnedList);
                 return returnList;
             } else {
-                if (returnList.size() > 0) {
+                if (!returnList.isEmpty()) {
                     // there is a block before this one
                     if (prevLM.mustKeepWithNext()
                         || curLM.mustKeepWithPrevious()) {
@@ -150,16 +151,16 @@
                         returnList.add(new KnuthPenalty(0, 
                                 KnuthElement.INFINITE, false, 
                                 new Position(this), false));
-                    } else if (!((KnuthElement) returnList.get(returnList
-                            .size() - 1)).isGlue()) {
+                    } else if (!((KnuthElement) ListUtil.getLast(returnList))
+                            .isGlue()) {
                         // add a null penalty to allow a break between blocks
                         returnList.add(new KnuthPenalty(0, 0, false, new Position(this), false));
                     }
                 }
-/*LF*/          if (returnedList.size() > 0) { // controllare!
+/*LF*/          if (!returnedList.isEmpty()) { // controllare!
                     returnList.addAll(returnedList);
-                    final KnuthElement last = (KnuthElement) returnedList
-                            .get(returnedList.size() - 1);
+                    final KnuthElement last = (KnuthElement) ListUtil
+                            .getLast(returnedList);
                     if (last.isPenalty()
                             && ((KnuthPenalty) last).getP() == -KnuthElement.INFINITE) {
                         // a descendant of this flow has break-after
@@ -173,10 +174,10 @@
 
         setFinished(true);
 
-        if (returnList.size() > 0) {
-            return returnList;
-        } else {
+        if (returnList.isEmpty()) {
             return null;
+        } else {
+            return returnList;
         }
     }
     

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java?rev=665995&r1=665994&r2=665995&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java Tue Jun 10 00:52:36 2008
@@ -56,6 +56,7 @@
 import org.apache.fop.layoutmgr.TraitSetter;
 import org.apache.fop.traits.MinOptMax;
 import org.apache.fop.traits.SpaceVal;
+import org.apache.fop.util.ListUtil;
 
 /**
  * LayoutManager for objects which stack children in the inline direction,
@@ -312,11 +313,11 @@
             
             // get KnuthElements from curLM
             returnedList = curLM.getNextKnuthElements(childLC, alignment);
-            if (returnList.size() == 0 && childLC.isKeepWithPreviousPending()) {
+            if (returnList.isEmpty() && childLC.isKeepWithPreviousPending()) {
                 childLC.clearKeepWithPreviousPending();
             }
             if (returnedList == null
-                    || returnedList.size() == 0) {
+                    || returnedList.isEmpty()) {
                 // curLM returned null or an empty list, because it finished;
                 // just iterate once more to see if there is another child
                 continue;
@@ -335,7 +336,7 @@
                     returnedList.remove(0);
                 }
                 // add border and padding to the first complete sequence of this LM
-                if (!borderAdded && returnedList.size() != 0) {
+                if (!borderAdded && !returnedList.isEmpty()) {
                     addKnuthElementsForBorderPaddingStart((KnuthSequence) returnedList.get(0));
                     borderAdded = true;
                 }
@@ -367,8 +368,7 @@
                 context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
                 childLC.clearKeepsPending();
             }
-            lastSequence = (KnuthSequence) returnList
-                    .get(returnList.size() - 1);
+            lastSequence = (KnuthSequence) ListUtil.getLast(returnList);
             lastChildLM = curLM;
         }
         
@@ -379,7 +379,7 @@
         setFinished(true);
         log.trace(trace);
         
-        if (returnList.size() == 0) {
+        if (returnList.isEmpty()) {
             /*
              * if the FO itself is empty, but has an id specified 
              * or associated fo:markers, then we still need a dummy
@@ -396,7 +396,7 @@
             }
         }
         
-        return returnList.size() == 0 ? null : returnList;
+        return returnList.isEmpty() ? null : returnList;
     }
 
     /**

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java?rev=665995&r1=665994&r2=665995&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java Tue Jun 10 00:52:36 2008
@@ -46,6 +46,7 @@
 import org.apache.fop.traits.MinOptMax;
 import org.apache.fop.traits.SpaceVal;
 import org.apache.fop.util.CharUtilities;
+import org.apache.fop.util.ListUtil;
 
 /**
  * LayoutManager for text (a sequence of characters) which generates one
@@ -624,9 +625,9 @@
             sequence = this.processLinebreak(returnList, sequence);
         }
 
-        if (((List) returnList.get(returnList.size() - 1)).isEmpty()) {
+        if (((List) ListUtil.getLast(returnList)).isEmpty()) {
             //Remove an empty sequence because of a trailing newline
-            returnList.remove(returnList.size() - 1);
+            ListUtil.removeLast(returnList);
         }
         
         this.setFinished(true);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java?rev=665995&r1=665994&r2=665995&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java Tue Jun 10 00:52:36 2008
@@ -27,7 +27,6 @@
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Block;
 import org.apache.fop.area.Trait;
-import org.apache.fop.fo.flow.ListItem;
 import org.apache.fop.fo.flow.table.ConditionalBorder;
 import org.apache.fop.fo.flow.table.GridUnit;
 import org.apache.fop.fo.flow.table.PrimaryGridUnit;
@@ -53,6 +52,7 @@
 import org.apache.fop.layoutmgr.TraitSetter;
 import org.apache.fop.traits.BorderProps;
 import org.apache.fop.traits.MinOptMax;
+import org.apache.fop.util.ListUtil;
 
 /**
  * LayoutManager for a table-cell FO.
@@ -152,7 +152,7 @@
             if (childLC.isKeepWithNextPending()) {
                 log.debug("child LM signals pending keep with next");
             }
-            if (contentList.size() == 0 && childLC.isKeepWithPreviousPending()) {
+            if (contentList.isEmpty() && childLC.isKeepWithPreviousPending()) {
                 primaryGridUnit.setKeepWithPreviousStrength(childLC.getKeepWithPreviousPending());
                 childLC.clearKeepWithPreviousPending();
             }
@@ -163,7 +163,7 @@
                 addInBetweenBreak(contentList, context, childLC);
             }
             contentList.addAll(returnedList);
-            if (returnedList.size() == 0) {
+            if (returnedList.isEmpty()) {
                 //Avoid NoSuchElementException below (happens with empty blocks)
                 continue;
             }
@@ -177,7 +177,7 @@
         primaryGridUnit.setKeepWithNextStrength(context.getKeepWithNextPending());
 
         returnedList = new LinkedList();
-        if (contentList.size() > 0) {
+        if (!contentList.isEmpty()) {
             wrapPositionElements(contentList, returnList);
         } else {
             // In relaxed validation mode, table-cells having no children are authorised.
@@ -193,8 +193,8 @@
             returnList.remove(0);
             assert !returnList.isEmpty();
         }
-        final KnuthElement lastItem = (KnuthElement) returnList
-                .get(returnList.size() - 1);
+        final KnuthElement lastItem = (KnuthElement) ListUtil
+                .getLast(returnList);
         if (((KnuthElement) lastItem).isForcedBreak()) {
             KnuthPenalty p = (KnuthPenalty) lastItem;
             primaryGridUnit.setBreakAfter(p.getBreakClass());

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ListUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ListUtil.java?rev=665995&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ListUtil.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ListUtil.java Tue Jun 10 00:52:36 2008
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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$ */
+
+package org.apache.fop.util;
+
+import java.util.List;
+
+/**
+ * Provides helper functions for {@link java.util.List}.
+ * 
+ */
+public final class ListUtil {
+
+    private ListUtil() {
+        // Utility class.
+    }
+
+    /**
+     * Retrieve the last element from a list.
+     * 
+     * @param list
+     *            The list to work on
+     * @return last element
+     */
+    public static Object getLast(List list) {
+        return list.get(list.size() - 1);
+    }
+
+    /**
+     * Retrieve and remove the last element from a list.
+     * 
+     * @param list
+     *            The list to work on
+     * @return previous last element
+     */
+    public static Object removeLast(List list) {
+        return list.remove(list.size() - 1);
+    }
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ListUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ListUtil.java
------------------------------------------------------------------------------
    svn:keywords = Id



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org