@@ -16,7 +16,6 @@ public class Finder {
1616 final public static String UP = "up" ;
1717 final public static String DOWN = "down" ;
1818
19- private static String findDirection = UP ; //default direction is up
2019 private static Finder currentFinder ;
2120 private static Color currentColor ;
2221 private String goToName = null ;
@@ -27,7 +26,6 @@ public Finder () {
2726 }
2827
2928 public void setGoToIndex (int offset ) {
30- System .out .println (offset + " off" );
3129 goToOffset = offset ;
3230 }
3331
@@ -49,44 +47,16 @@ public String getGoToFunc() {
4947 return null ;
5048 }
5149
52- public ArrayList <DataNode > getOccurrences (String data ) {
53- if (findDirection .equals (UP )) {
54- UpFinder finder = UpFinder .getInstance ();
55- return finder .getUpOccurrences (data );
56- }
57- else if (findDirection .equals (DOWN )) {
58- DownFinder finder = DownFinder .getInstance ();
59- return finder .getDownOccurrences (data );
60- }
61- return null ;
62- }
63-
64- /**
65- * Controls which flow the tool will navigate to show data flow
66- * @param s: Direction for flow display, required to be UP or DOWN
67- */
68- /*public void setFlowDirection(String s) {
69- if(s.equals(UP)) {
70- findDirection = s;
71- currentFinder = UpFinder.getInstance();
72- SuggestedSelectionAnnotation.color = new Color(null, 0, 0, 255);
73- }
74- else if(s.equals(DOWN)) {
75- findDirection = s;
76- currentFinder = DownFinder.getInstance();
77- SuggestedSelectionAnnotation.color = new Color(null, 255, 0, 0);
78- }
79- else {
80- //something went very wrong...
81- findDirection = null;
82- }
83- }*/
84-
8550 /**
86- * Function to return the current direction of the flow navigation.
51+ * Returns the occurrences of the selected string in the class
52+ * @param data: current String value
53+ * @returns ArrayList of DataNodes for string
8754 */
88- public String getFlowDirection () {
89- return findDirection ;
55+ public ArrayList <DataNode > getOccurrences (String data ) {
56+ ArrayList <DataNode > occurrences = new ArrayList <DataNode >();
57+ occurrences .addAll (UpFinder .getInstance ().getUpOccurrences (data ));
58+ occurrences .addAll (DownFinder .getInstance ().getDownOccurrences (data ));
59+ return occurrences ;
9060 }
9161
9262 /**
@@ -95,20 +65,6 @@ public String getFlowDirection() {
9565 * @returns true if current variable is a DataNode, else false
9666 */
9767 public boolean contains (String str ) {
98- return currentFinder .contains (str );
99- }
100-
101- /**
102- * Function to get the finder instance
103- * @returns the current finder instance searching in the appropriate direction.
104- */
105- public static Finder getInstance () {
106- if (findDirection .equals (UP )) {
107- return UpFinder .getInstance ();
108- }
109- else if (findDirection .equals (DOWN )){
110- return DownFinder .getInstance ();
111- }
112- return null ;
68+ return (UpFinder .getInstance ().contains (str ) || DownFinder .getInstance ().contains (str ));
11369 }
11470}
0 commit comments