Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrbrooks2010-09-20 21:46:02 +0000
committerRyan D. Brooks2010-09-20 21:46:02 +0000
commit6c7ac2d215c95bcc3d469bdfb730a4fbc4369f18 (patch)
treeae250f3ec47e759f7cd47eb9410ab47fb7a66015
parent0b84fc0c6296a175c1b65d985fe6ca408deb092e (diff)
downloadorg.eclipse.osee-6c7ac2d215c95bcc3d469bdfb730a4fbc4369f18.tar.gz
org.eclipse.osee-6c7ac2d215c95bcc3d469bdfb730a4fbc4369f18.tar.xz
org.eclipse.osee-6c7ac2d215c95bcc3d469bdfb730a4fbc4369f18.zip
refactor: Convert nested class FindResults.FindResultsIterator to a top level class
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/ExtractTestRelations.java3
-rw-r--r--plugins/org.eclipse.osee.framework.core.test/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/text/FindResults.java55
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/text/tool/FindResultsIterator.java70
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/text/tool/FunctionCallStats.java2
5 files changed, 78 insertions, 55 deletions
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/ExtractTestRelations.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/ExtractTestRelations.java
index 53ba46e2d63..95d2b07abfa 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/ExtractTestRelations.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/ExtractTestRelations.java
@@ -28,6 +28,7 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.jdk.core.text.FindResults;
import org.eclipse.osee.framework.jdk.core.text.tool.Find;
+import org.eclipse.osee.framework.jdk.core.text.tool.FindResultsIterator;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
@@ -56,7 +57,7 @@ public class ExtractTestRelations {
app.find(999999, true);
FindResults results = app.getResults();
- for (FindResults.FindResultsIterator i = results.iterator(); i.hasNext();) {
+ for (FindResultsIterator i = results.iterator(); i.hasNext();) {
try {
addRelationToDatabaseIfNotAlreadyThere(AWorkspace.fileToIFile(i.currentFile), i.currentRegion);
} catch (Exception ex) {
diff --git a/plugins/org.eclipse.osee.framework.core.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.core.test/META-INF/MANIFEST.MF
index bbc54f3a93a..62ff07de859 100644
--- a/plugins/org.eclipse.osee.framework.core.test/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.core.test/META-INF/MANIFEST.MF
@@ -9,4 +9,5 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.junit4;bundle-version="4.5.0"
Export-Package: org.eclipse.osee.framework.core.test,
org.eclipse.osee.framework.core.test.mocks
-Import-Package: org.eclipse.osee.framework.jdk.core.text.tool
+Import-Package: org.eclipse.osee.framework.jdk.core.text,
+ org.eclipse.osee.framework.jdk.core.text.tool
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/text/FindResults.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/text/FindResults.java
index 6a903215a8e..b9740d46d2e 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/text/FindResults.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/text/FindResults.java
@@ -21,6 +21,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import org.eclipse.osee.framework.jdk.core.text.tool.FindResultsIterator;
/**
* @author Ryan D. Brooks
@@ -49,7 +50,7 @@ public class FindResults {
}
public void writeFindResutls(Writer out) throws IOException {
- for (FindResults.FindResultsIterator i = iterator(); i.hasNext();) {
+ for (FindResultsIterator i = iterator(); i.hasNext();) {
// write out the file name, pattern, and region surrounding match
out.write(i.currentPattern);
out.write('@');
@@ -63,57 +64,7 @@ public class FindResults {
}
public FindResultsIterator iterator() {
- return new FindResultsIterator();
- }
-
- /**
- * @author Ryan D. Brooks
- */
- public class FindResultsIterator {
- private Iterator<Entry<String, HashMap<File, List<String>>>> patternIterator;
- private Iterator<Entry<File, List<String>>> fileIterator;
- private Iterator<String> listIterator;
- private boolean more;
- public String currentPattern;
- public File currentFile;
- public String currentRegion;
-
- private FindResultsIterator() {
- reset();
- }
-
- public void reset() {
- this.more = true;
- this.patternIterator = results.entrySet().iterator();
- this.listIterator = null;
- this.fileIterator = null;
- }
-
- // assumption every the list and file itorator's will have at least one item
- private void primePump() {
- if (listIterator == null || !listIterator.hasNext()) {
- if (fileIterator == null || !fileIterator.hasNext()) {
- if (!patternIterator.hasNext()) {
- more = false;
- return;
- }
- Map.Entry<String, HashMap<File, List<String>>> entry = patternIterator.next();
- currentPattern = entry.getKey();
- HashMap<File, List<String>> fileMatches = entry.getValue();
- fileIterator = fileMatches.entrySet().iterator();
- }
- Map.Entry<File, List<String>> entry = fileIterator.next();
- currentFile = entry.getKey();
- List<String> list = entry.getValue();
- listIterator = list.iterator();
- }
- currentRegion = listIterator.next();
- }
-
- public boolean hasNext() {
- primePump();
- return more;
- }
+ return new FindResultsIterator(results);
}
/**
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/text/tool/FindResultsIterator.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/text/tool/FindResultsIterator.java
new file mode 100644
index 00000000000..78b9c4240e7
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/text/tool/FindResultsIterator.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.jdk.core.text.tool;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class FindResultsIterator {
+ private Iterator<Entry<String, HashMap<File, List<String>>>> patternIterator;
+ private Iterator<Entry<File, List<String>>> fileIterator;
+ private Iterator<String> listIterator;
+ private boolean more;
+ public String currentPattern;
+ public File currentFile;
+ public String currentRegion;
+ private final HashMap<String, HashMap<File, List<String>>> results;
+
+ public FindResultsIterator(HashMap<String, HashMap<File, List<String>>> results) {
+ this.results = results;
+ reset();
+ }
+
+ public void reset() {
+ this.more = true;
+ this.patternIterator = results.entrySet().iterator();
+ this.listIterator = null;
+ this.fileIterator = null;
+ }
+
+ // assumption every the list and file itorator's will have at least one item
+ private void primePump() {
+ if (listIterator == null || !listIterator.hasNext()) {
+ if (fileIterator == null || !fileIterator.hasNext()) {
+ if (!patternIterator.hasNext()) {
+ more = false;
+ return;
+ }
+ Map.Entry<String, HashMap<File, List<String>>> entry = patternIterator.next();
+ currentPattern = entry.getKey();
+ HashMap<File, List<String>> fileMatches = entry.getValue();
+ fileIterator = fileMatches.entrySet().iterator();
+ }
+ Map.Entry<File, List<String>> entry = fileIterator.next();
+ currentFile = entry.getKey();
+ List<String> list = entry.getValue();
+ listIterator = list.iterator();
+ }
+ currentRegion = listIterator.next();
+ }
+
+ public boolean hasNext() {
+ primePump();
+ return more;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/text/tool/FunctionCallStats.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/text/tool/FunctionCallStats.java
index 6c4b123a0ae..d7d7b265f01 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/text/tool/FunctionCallStats.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/text/tool/FunctionCallStats.java
@@ -59,7 +59,7 @@ public class FunctionCallStats {
String lastFileName = null;
HashMap functions = new HashMap(1000);
- for (FindResults.FindResultsIterator i = results.iterator(); i.hasNext();) {
+ for (FindResultsIterator i = results.iterator(); i.hasNext();) {
String currentFileName = i.currentFile.getName();
if (i.currentRegion != null) {

Back to the top