From: Andreas L. Delmelle Date: Sun, 9 Jan 2011 12:20:21 +0000 (+0000) Subject: Switch to type-safe collections (+ related cleanup of redundant casts, for-loops...) X-Git-Tag: fop-1_1rc1old~378 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=aaf2ae529ec3f02e0062fd0f26ef8c98e4a634d0;p=xmlgraphics-fop.git Switch to type-safe collections (+ related cleanup of redundant casts, for-loops...) git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1056926 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fo/pagination/Declarations.java b/src/java/org/apache/fop/fo/pagination/Declarations.java index 1385bccc9..9c68043ff 100644 --- a/src/java/org/apache/fop/fo/pagination/Declarations.java +++ b/src/java/org/apache/fop/fo/pagination/Declarations.java @@ -41,7 +41,7 @@ import org.apache.fop.fo.ValidationException; */ public class Declarations extends FObj { - private Map colorProfiles = null; + private Map colorProfiles = null; /** * @param parent FONode that is the parent of this object @@ -98,7 +98,7 @@ public class Declarations extends FObj { private void addColorProfile(ColorProfile cp) { if (colorProfiles == null) { - colorProfiles = new java.util.HashMap(); + colorProfiles = new java.util.HashMap(); } if (colorProfiles.get(cp.getColorProfileName()) != null) { // duplicate names @@ -132,7 +132,7 @@ public class Declarations extends FObj { public ColorProfile getColorProfile(String cpName) { ColorProfile profile = null; if (this.colorProfiles != null) { - profile = (ColorProfile)this.colorProfiles.get(cpName); + profile = this.colorProfiles.get(cpName); } return profile; } diff --git a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java index 482ec83c4..c4189d0c4 100644 --- a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java +++ b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java @@ -44,8 +44,8 @@ import org.apache.fop.fo.ValidationException; */ public class LayoutMasterSet extends FObj { - private Map simplePageMasters; - private Map pageSequenceMasters; + private Map simplePageMasters; + private Map pageSequenceMasters; /** * Create a LayoutMasterSet instance that is a child of the given @@ -65,8 +65,8 @@ public class LayoutMasterSet extends FObj { /** {@inheritDoc} */ protected void startOfNode() throws FOPException { getRoot().setLayoutMasterSet(this); - simplePageMasters = new java.util.HashMap(); - pageSequenceMasters = new java.util.HashMap(); + simplePageMasters = new java.util.HashMap(); + pageSequenceMasters = new java.util.HashMap(); } /** {@inheritDoc} */ @@ -98,18 +98,13 @@ public class LayoutMasterSet extends FObj { */ private void checkRegionNames() throws ValidationException { // (user-entered) region-name to default region map. - Map allRegions = new java.util.HashMap(); - for (Iterator spm = simplePageMasters.values().iterator(); - spm.hasNext();) { - SimplePageMaster simplePageMaster - = (SimplePageMaster)spm.next(); - Map spmRegions = simplePageMaster.getRegions(); - for (Iterator e = spmRegions.values().iterator(); - e.hasNext();) { - Region region = (Region) e.next(); + Map allRegions = new java.util.HashMap(); + for (SimplePageMaster simplePageMaster : simplePageMasters.values()) { + Map spmRegions = simplePageMaster.getRegions(); + for (Region region : spmRegions.values()) { if (allRegions.containsKey(region.getRegionName())) { String defaultRegionName - = (String) allRegions.get(region.getRegionName()); + = allRegions.get(region.getRegionName()); if (!defaultRegionName.equals(region.getDefaultRegionName())) { getFOValidationEventProducer().regionNameMappedToMultipleRegionClasses(this, region.getRegionName(), @@ -118,7 +113,7 @@ public class LayoutMasterSet extends FObj { } } allRegions.put(region.getRegionName(), - region.getDefaultRegionName()); + region.getDefaultRegionName()); } } } @@ -155,7 +150,7 @@ public class LayoutMasterSet extends FObj { * @return the requested simple-page-master */ public SimplePageMaster getSimplePageMaster(String masterName) { - return (SimplePageMaster)this.simplePageMasters.get(masterName); + return this.simplePageMasters.get(masterName); } /** @@ -185,7 +180,7 @@ public class LayoutMasterSet extends FObj { * @return the requested PageSequenceMaster instance */ public PageSequenceMaster getPageSequenceMaster(String masterName) { - return (PageSequenceMaster)this.pageSequenceMasters.get(masterName); + return this.pageSequenceMasters.get(masterName); } /** @@ -194,9 +189,8 @@ public class LayoutMasterSet extends FObj { * @return true when the region name specified has a region in this LayoutMasterSet */ public boolean regionNameExists(String regionName) { - for (Iterator e = simplePageMasters.values().iterator(); - e.hasNext();) { - if (((SimplePageMaster)e.next()).regionNameExists(regionName)) { + for (SimplePageMaster spm : simplePageMasters.values()) { + if (spm.regionNameExists(regionName)) { return true; } } diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java index 74b85e78c..ee78bb8ba 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java @@ -48,7 +48,7 @@ public class PageSequence extends AbstractPageSequence { // the set of flows includes StaticContent flows also /** Map of flows to their flow name (flow-name, Flow) */ - private Map/**/ flowMap; + private Map flowMap; /** * The currentSimplePageMaster is either the page master for the @@ -96,7 +96,7 @@ public class PageSequence extends AbstractPageSequence { /** {@inheritDoc} */ protected void startOfNode() throws FOPException { super.startOfNode(); - flowMap = new java.util.HashMap/**/(); + flowMap = new java.util.HashMap(); this.simplePageMaster = getRoot().getLayoutMasterSet().getSimplePageMaster(masterReference); @@ -167,7 +167,7 @@ public class PageSequence extends AbstractPageSequence { break; case FO_STATIC_CONTENT: addFlow((StaticContent)child); - flowMap.put(((StaticContent)child).getFlowName(), child); + flowMap.put(((Flow)child).getFlowName(), (Flow)child); break; default: super.addChildNode(child); @@ -239,7 +239,7 @@ public class PageSequence extends AbstractPageSequence { } /** @return the flow map for this page-sequence */ - public Map getFlowMap() { + public Map getFlowMap() { return this.flowMap; } diff --git a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java index 705b955e9..5b71525d3 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java @@ -44,7 +44,7 @@ public class PageSequenceMaster extends FObj { // End of property values private LayoutMasterSet layoutMasterSet; - private List subSequenceSpecifiers; + private List subSequenceSpecifiers; private SubSequenceSpecifier currentSubSequence; private int currentSubSequenceNumber = -1; @@ -76,7 +76,7 @@ public class PageSequenceMaster extends FObj { /** {@inheritDoc} */ protected void startOfNode() throws FOPException { - subSequenceSpecifiers = new java.util.ArrayList(); + subSequenceSpecifiers = new java.util.ArrayList(); layoutMasterSet = parent.getRoot().getLayoutMasterSet(); layoutMasterSet.addPageSequenceMaster(masterName, this); } @@ -121,8 +121,7 @@ public class PageSequenceMaster extends FObj { currentSubSequenceNumber++; if (currentSubSequenceNumber >= 0 && currentSubSequenceNumber < subSequenceSpecifiers.size()) { - return (SubSequenceSpecifier)subSequenceSpecifiers - .get(currentSubSequenceNumber); + return subSequenceSpecifiers.get(currentSubSequenceNumber); } return null; } @@ -134,8 +133,8 @@ public class PageSequenceMaster extends FObj { currentSubSequenceNumber = -1; currentSubSequence = null; if (subSequenceSpecifiers != null) { - for (int i = 0; i < subSequenceSpecifiers.size(); i++) { - ((SubSequenceSpecifier)subSequenceSpecifiers.get(i)).reset(); + for (SubSequenceSpecifier subSequenceSpecifier : subSequenceSpecifiers) { + subSequenceSpecifier.reset(); } } } @@ -150,7 +149,7 @@ public class PageSequenceMaster extends FObj { if (!success) { if (currentSubSequenceNumber > 0) { currentSubSequenceNumber--; - currentSubSequence = (SubSequenceSpecifier)subSequenceSpecifiers + currentSubSequence = subSequenceSpecifiers .get(currentSubSequenceNumber); } else { currentSubSequence = null; diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java index 9b4c6544f..629d7d59d 100644 --- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java +++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java @@ -48,7 +48,7 @@ public class RepeatablePageMasterAlternatives extends FObj private int numberConsumed = 0; - private List conditionalPageMasterRefs; + private List conditionalPageMasterRefs; private boolean hasPagePositionLast = false; private boolean hasPagePositionOnly = false; @@ -68,7 +68,7 @@ public class RepeatablePageMasterAlternatives extends FObj /** {@inheritDoc} */ protected void startOfNode() throws FOPException { - conditionalPageMasterRefs = new java.util.ArrayList(); + conditionalPageMasterRefs = new java.util.ArrayList(); assert parent.getName().equals("fo:page-sequence-master"); //Validation by the parent PageSequenceMaster pageSequenceMaster = (PageSequenceMaster)parent; @@ -128,9 +128,7 @@ public class RepeatablePageMasterAlternatives extends FObj numberConsumed++; } - for (int i = 0; i < conditionalPageMasterRefs.size(); i++) { - ConditionalPageMasterReference cpmr - = (ConditionalPageMasterReference)conditionalPageMasterRefs.get(i); + for (ConditionalPageMasterReference cpmr : conditionalPageMasterRefs) { if (cpmr.isValid(isOddPage, isFirstPage, isLastPage, isBlankPage)) { return cpmr.getMasterReference(); } diff --git a/src/java/org/apache/fop/fo/pagination/Root.java b/src/java/org/apache/fop/fo/pagination/Root.java index 8f8e0a509..b413d9224 100644 --- a/src/java/org/apache/fop/fo/pagination/Root.java +++ b/src/java/org/apache/fop/fo/pagination/Root.java @@ -47,8 +47,8 @@ public class Root extends FObj { private LayoutMasterSet layoutMasterSet; private Declarations declarations; private BookmarkTree bookmarkTree = null; - private List destinationList; - private List pageSequences; + private List destinationList; + private List pageSequences; // temporary until above list populated private boolean pageSequenceFound = false; @@ -77,7 +77,7 @@ public class Root extends FObj { */ public Root(FONode parent) { super(parent); - pageSequences = new java.util.ArrayList(); + pageSequences = new java.util.ArrayList(); } /** {@inheritDoc} */ @@ -243,7 +243,7 @@ public class Root extends FObj { return null; } if (currentIndex < (pageSequences.size() - 1)) { - return (PageSequence)pageSequences.get(currentIndex + 1); + return pageSequences.get(currentIndex + 1); } else { return null; } @@ -295,7 +295,7 @@ public class Root extends FObj { */ public void addDestination(Destination destination) { if (destinationList == null) { - destinationList = new java.util.ArrayList(); + destinationList = new java.util.ArrayList(); } destinationList.add(destination); } diff --git a/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java b/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java index aa2c2bb8b..2bb891cd9 100644 --- a/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java +++ b/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java @@ -28,6 +28,7 @@ public interface SubSequenceSpecifier { /** * Returns the name of the next page master. + * * @param isOddPage True if the next page number is odd * @param isFirstPage True if the next page is the first * @param isLastPage True if the next page is the last