aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Berger <maxberger@apache.org>2008-06-10 07:52:36 +0000
committerMaximilian Berger <maxberger@apache.org>2008-06-10 07:52:36 +0000
commit802e3087140006e4b59eaef052949ab4ddd28338 (patch)
tree25a5bc12e5d75561111686b2bdfefcc2ceaee554
parenta435c09dc62eeeba6201c74d1c1f3b2313c4356f (diff)
downloadxmlgraphics-fop-802e3087140006e4b59eaef052949ab4ddd28338.tar.gz
xmlgraphics-fop-802e3087140006e4b59eaef052949ab4ddd28338.zip
Replaced getLast() calls with calls to listUtil
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@665995 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/layoutmgr/AbstractBreaker.java28
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java18
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java30
-rw-r--r--src/java/org/apache/fop/layoutmgr/ElementListUtils.java12
-rw-r--r--src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java19
-rwxr-xr-xsrc/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java14
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java5
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java12
-rw-r--r--src/java/org/apache/fop/util/ListUtil.java55
9 files changed, 128 insertions, 65 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
index 6f204383d..c830220e7 100644
--- a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
+++ b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
@@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFactory;
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 abstract class AbstractBreaker {
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 @@ public abstract class AbstractBreaker {
/** @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 @@ public abstract class AbstractBreaker {
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 @@ public abstract class AbstractBreaker {
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 @@ public abstract class AbstractBreaker {
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)
diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
index 22d5fb941..732cb1ae7 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
@@ -39,6 +39,7 @@ import org.apache.fop.fo.flow.BlockContainer;
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 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
// 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 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
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 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
// 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 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
// // 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);
diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
index b2fb98ccd..4360f62e9 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
@@ -36,6 +36,7 @@ import org.apache.fop.fo.properties.SpaceProperty;
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 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
// 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 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
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 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
// 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 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
/* 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 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
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 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
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 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
// 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 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
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 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
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
diff --git a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
index f3d36276c..c04d197e4 100644
--- a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
+++ b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
@@ -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 @@ public class ElementListUtils {
* @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 @@ public class ElementListUtils {
* @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
diff --git a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
index 3a8786bd7..44e0cc476 100644
--- a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
@@ -38,6 +38,7 @@ import org.apache.fop.layoutmgr.PageBreakingAlgorithm.PageBreakingLayoutListener
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 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
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 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
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 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
setFinished(true);
- if (returnList.size() > 0) {
- return returnList;
- } else {
+ if (returnList.isEmpty()) {
return null;
+ } else {
+ return returnList;
}
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
index 123259cd4..d0874d626 100755
--- a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
@@ -56,6 +56,7 @@ import org.apache.fop.layoutmgr.SpaceSpecifier;
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 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
// 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 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
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 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
childLC.clearKeepsPending();
}
- lastSequence = (KnuthSequence) returnList
- .get(returnList.size() - 1);
+ lastSequence = (KnuthSequence) ListUtil.getLast(returnList);
lastChildLM = curLM;
}
@@ -379,7 +379,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
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 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
}
}
- return returnList.size() == 0 ? null : returnList;
+ return returnList.isEmpty() ? null : returnList;
}
/**
diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
index eec2b1e91..575728f0d 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
@@ -46,6 +46,7 @@ import org.apache.fop.text.linebreak.LineBreakStatus;
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 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
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);
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
index 1b402095d..43b34e4b7 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
@@ -27,7 +27,6 @@ import org.apache.commons.logging.LogFactory;
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.SpaceResolver;
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 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager
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 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager
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 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager
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 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager
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());
diff --git a/src/java/org/apache/fop/util/ListUtil.java b/src/java/org/apache/fop/util/ListUtil.java
new file mode 100644
index 000000000..a6b8d490c
--- /dev/null
+++ b/src/java/org/apache/fop/util/ListUtil.java
@@ -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);
+ }
+}