author | iignatyev |
Mon, 30 Apr 2018 18:10:24 -0700 | |
changeset 49934 | 44839fbb20db |
permissions | -rw-r--r-- |
49934
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
1 |
/* |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
2 |
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
4 |
* |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
8 |
* |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
14 |
* |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
18 |
* |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
22 |
*/ |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
23 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
24 |
package nsk.share; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
25 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
26 |
import java.util.*; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
27 |
import java.util.regex.*; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
28 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
29 |
/** |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
30 |
* Weak emulator of perl's grep function with very small functionality. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
31 |
* This class does not use java.util.regexp classes which appear in |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
32 |
* JDK1.4 API. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
33 |
* |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
34 |
* @see Grep |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
35 |
*/ |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
36 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
37 |
public class Paragrep { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
38 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
39 |
String[] stringArray; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
40 |
/** |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
41 |
* Takes String array as character sequence for matching the pattern. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
42 |
*/ |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
43 |
public Paragrep (String[] stringArray) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
44 |
this.stringArray = stringArray; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
45 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
46 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
47 |
/** |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
48 |
* Returns number of non-interleaved occurences of the pattern string. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
49 |
*/ |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
50 |
public int find (String pattern) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
51 |
if (pattern.length() == 0) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
52 |
throw new Failure("Empty string as input parameter for Grep.find(pattern) method"); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
53 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
54 |
int counter = 0; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
55 |
for (int i = 0; i < stringArray.length; i++) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
56 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
57 |
String string = stringArray[i]; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
58 |
if (string != null) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
59 |
// Find all non-interleaved occurences of pattern in this string |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
60 |
for (int ind = 0; ind < string.length(); ) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
61 |
int k = 0; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
62 |
if ((k = string.indexOf(pattern, ind)) >= 0) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
63 |
counter++; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
64 |
ind = k + pattern.length(); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
65 |
} else { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
66 |
break; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
67 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
68 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
69 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
70 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
71 |
return counter; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
72 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
73 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
74 |
/** |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
75 |
* Returns all string in <code>stringArray</code> which have |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
76 |
* occurences of the pattern string. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
77 |
*/ |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
78 |
public String[] findStrings (String pattern) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
79 |
if (pattern.length() == 0) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
80 |
throw new Failure("Empty string as input parameter for Grep.find(pattern) method"); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
81 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
82 |
Vector<String> v = new Vector<String>(); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
83 |
for (int i = 0; i < stringArray.length; i++) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
84 |
String string = stringArray[i]; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
85 |
if (string != null && string.indexOf(pattern) >= 0) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
86 |
v.add(string); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
87 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
88 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
89 |
String[] result = new String[v.size()]; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
90 |
v.toArray(result); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
91 |
return result; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
92 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
93 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
94 |
/** |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
95 |
* Returns first string of stringArray which contains |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
96 |
* the pattern string or empty string othrewise. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
97 |
*/ |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
98 |
public String findFirst (String pattern) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
99 |
if (pattern.length() == 0) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
100 |
throw new Failure("Empty string as input parameter for Paragrep.findFirst(pattern) method"); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
101 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
102 |
String result = ""; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
103 |
for (int i = 0; i < stringArray.length; i++) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
104 |
String string = stringArray[i]; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
105 |
if (string != null) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
106 |
if (string.indexOf(pattern) >= 0) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
107 |
result = string; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
108 |
break; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
109 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
110 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
111 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
112 |
return result; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
113 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
114 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
115 |
/** |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
116 |
* Returns first string of stringArray which contains |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
117 |
* all of the pattern strings or empty string otherwise. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
118 |
*/ |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
119 |
public String findFirst (Vector<String> patternVector) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
120 |
if (patternVector.isEmpty()) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
121 |
throw new Failure("Empty vector as input parameter for Paragrep.findFirst(patternVector) method"); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
122 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
123 |
String[] patterns = new String[patternVector.size()]; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
124 |
patternVector.toArray(patterns); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
125 |
String result = ""; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
126 |
for (int i = 0; i < stringArray.length; i++) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
127 |
String string = stringArray[i]; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
128 |
if (string != null && string.length() > 0) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
129 |
for (int j = 0; j < patterns.length; j++) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
130 |
String pattern = patterns[j]; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
131 |
if (string.indexOf(pattern) >= 0) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
132 |
if (j + 1 == patterns.length) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
133 |
// found all patterns in the current string |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
134 |
result = string; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
135 |
i = stringArray.length; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
136 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
137 |
} else { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
138 |
break; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
139 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
140 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
141 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
142 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
143 |
return result; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
144 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
145 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
146 |
/** |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
147 |
* Returns count of strings in stringArray which contain |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
148 |
* all of the pattern strings. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
149 |
*/ |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
150 |
public int find (Vector<String> patternVector) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
151 |
if (patternVector.isEmpty()) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
152 |
throw new Failure("Empty vector as input parameter for Paragrep.find(patternVector) method"); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
153 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
154 |
String[] patterns = new String[patternVector.size()]; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
155 |
patternVector.toArray(patterns); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
156 |
int counter = 0; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
157 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
158 |
for (int i = 0; i < stringArray.length; i++) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
159 |
String string = stringArray[i]; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
160 |
if (string != null && string.length() > 0) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
161 |
for (int j = 0; j < patterns.length; j++) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
162 |
String pattern = patterns[j]; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
163 |
if (string.indexOf(pattern) >= 0) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
164 |
if (j + 1 == patterns.length) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
165 |
// found all patterns in the current string |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
166 |
counter++; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
167 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
168 |
} else { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
169 |
break; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
170 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
171 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
172 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
173 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
174 |
return counter; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
175 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
176 |
} |