From 46b7e0614c3251dbb50ea97211d8d79af3dedade Mon Sep 17 00:00:00 2001 From: Simon Steiner Date: Fri, 16 Sep 2016 11:17:35 +0000 Subject: FOP-2648: Code cleanup, use foreach git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1761020 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/fop/events/DefaultEventBroadcaster.java | 4 ++-- .../main/java/org/apache/fop/tools/EventProducerCollector.java | 9 +++------ .../java/org/apache/fop/tools/EventProducerCollectorTask.java | 6 ++---- 3 files changed, 7 insertions(+), 12 deletions(-) (limited to 'fop-events') diff --git a/fop-events/src/main/java/org/apache/fop/events/DefaultEventBroadcaster.java b/fop-events/src/main/java/org/apache/fop/events/DefaultEventBroadcaster.java index 596a0a86b..24499ea35 100644 --- a/fop-events/src/main/java/org/apache/fop/events/DefaultEventBroadcaster.java +++ b/fop-events/src/main/java/org/apache/fop/events/DefaultEventBroadcaster.java @@ -104,8 +104,8 @@ public class DefaultEventBroadcaster implements EventBroadcaster { } private static synchronized EventProducerModel getEventProducerModel(Class clazz) { - for (int i = 0, c = eventModels.size(); i < c; i++) { - EventModel eventModel = (EventModel)eventModels.get(i); + for (Object eventModel1 : eventModels) { + EventModel eventModel = (EventModel) eventModel1; EventProducerModel producerModel = eventModel.getProducer(clazz); if (producerModel != null) { return producerModel; diff --git a/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollector.java b/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollector.java index 7151f5a9c..2351fc870 100644 --- a/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollector.java +++ b/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollector.java @@ -93,8 +93,7 @@ class EventProducerCollector { builder.addSource(src); JavaClass[] classes = builder.getClasses(); boolean eventProducerFound = false; - for (int i = 0, c = classes.length; i < c; i++) { - JavaClass clazz = classes[i]; + for (JavaClass clazz : classes) { if (clazz.isInterface() && implementsInterface(clazz, CLASSNAME_EVENT_PRODUCER)) { processEventProducerInterface(clazz); eventProducerFound = true; @@ -105,8 +104,7 @@ class EventProducerCollector { private boolean implementsInterface(JavaClass clazz, String intf) { JavaClass[] classes = clazz.getImplementedInterfaces(); - for (int i = 0, c = classes.length; i < c; i++) { - JavaClass cl = classes[i]; + for (JavaClass cl : classes) { if (cl.getFullyQualifiedName().equals(intf)) { return true; } @@ -124,8 +122,7 @@ class EventProducerCollector { throws EventConventionException, ClassNotFoundException { EventProducerModel prodMeta = new EventProducerModel(clazz.getFullyQualifiedName()); JavaMethod[] methods = clazz.getMethods(true); - for (int i = 0, c = methods.length; i < c; i++) { - JavaMethod method = methods[i]; + for (JavaMethod method : methods) { EventMethodModel methodMeta = createMethodModel(method); prodMeta.addMethod(methodMeta); } diff --git a/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollectorTask.java b/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollectorTask.java index 85c10f09a..f56eea2e4 100644 --- a/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollectorTask.java +++ b/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollectorTask.java @@ -67,8 +67,7 @@ public class EventProducerCollectorTask extends Task { try { EventProducerCollector collector = new EventProducerCollector(); long lastModified = processFileSets(collector); - for (Iterator iter = collector.getModels().iterator(); iter.hasNext();) { - EventModel model = (EventModel) iter.next(); + for (EventModel model : collector.getModels()) { File parentDir = getParentDir(model); if (!parentDir.exists() && !parentDir.mkdirs()) { throw new BuildException( @@ -208,8 +207,7 @@ public class EventProducerCollectorTask extends Task { DirectoryScanner ds = fs.getDirectoryScanner(getProject()); String[] srcFiles = ds.getIncludedFiles(); File directory = fs.getDir(getProject()); - for (int i = 0, c = srcFiles.length; i < c; i++) { - String filename = srcFiles[i]; + for (String filename : srcFiles) { File src = new File(directory, filename); boolean eventProducerFound = collector.scanFile(src); if (eventProducerFound) { -- cgit v1.2.3