39 import java.util.ArrayList;
43 public static int LevenshteinDistance(String a, String b) {
47 int [] costs =
new int [b.length() + 1];
48 for (
int j = 0; j < costs.length; j++)
50 for (
int i = 1; i <= a.length(); i++) {
54 for (
int j = 1; j <= b.length(); j++) {
55 int cj = Math.min(1 + Math.min(costs[j], costs[j - 1]), a.charAt(i - 1) == b.charAt(j - 1) ? nw : nw + 1);
60 return costs[b.length()];
63 public static boolean LevenshteinMatch(String fpsActuell, String fpsExpected,
int fpiDistance)
65 Boolean lvbReturn =
false;
67 int lviDistanceActuell = LevenshteinDistance( fpsActuell, fpsExpected);
70 if ( lviDistanceActuell <= fpiDistance )
83 public static boolean LevenshteinMatch(ArrayList<String> fpALActuell, ArrayList<String> fpALExpected,
int fpiDistance)
85 boolean lvb_Return =
true;
87 Integer ActualSize = (Integer)fpALActuell.size();
88 Integer ExpectedSize = (Integer)fpALExpected.size();
90 if( ActualSize.equals( ExpectedSize ))
93 for (
int i = 0; i < fpALActuell.size(); i++)
95 if ( !
Matcher.LevenshteinMatch(fpALActuell.get(i), fpALExpected.get(i), fpiDistance ) )
118 boolean lvb_Return =
false;
120 lvb_Return = fpsActuell.matches(fpsExpected.replace(
"?",
".").replace(
"*",
".*").replace(
"#",
"\\d"));
131 public static boolean WildcardMatch(ArrayList<String> fpALActuell, ArrayList<String> fpALExpected)
133 boolean lvb_Return =
true;
135 Integer ActualSize = (Integer)fpALActuell.size();
136 Integer ExpectedSize = (Integer)fpALExpected.size();
138 if( ActualSize.equals( ExpectedSize ))
141 for (
int i = 0; i < fpALActuell.size(); i++)
159 public static boolean RegexMatch(String fpsActuell, String fpsExpectedRegex)
161 boolean lvb_Return =
false;
163 lvb_Return = fpsActuell.matches(fpsExpectedRegex);
173 public static boolean RegexMatch(ArrayList<String> fpALActuell, ArrayList<String> fpALExpected)
175 boolean lvb_Return =
true;
177 Integer ActualSize = (Integer)fpALActuell.size();
178 Integer ExpectedSize = (Integer)fpALExpected.size();
180 if( ActualSize.equals( ExpectedSize ))
183 for (
int i = 0; i < fpALActuell.size(); i++)
185 if ( !
Matcher.RegexMatch(fpALActuell.get(i), fpALExpected.get(i)) )