260
261 /**
262 * Iterate over the contents of the table.
263 * @param group if <code>true</code>, entries for the same relative
264 * URL are grouped together, and if more than one, returned in an
265 * array; if <code>false</code>, the iterator always returns
266 * separate entries.
267 * @see Entry
268 * @return an iterator for the table: the entries are either
269 * single instances of @link(Entry) or a mixture of @link(Entry)
270 * and @link(Entry)[], depending on the <code>group</code>
271 * parameter.
272 */
273 public Iterator<Entry> getIterator(boolean group) {
274 if (group)
275 return table.values().iterator();
276 else {
277 // flatten the enumeration into a vector, then
278 // enumerate that
279 List<Entry> v = new ArrayList<>(table.size());
280 for (Iterator<Entry> iter = table.values().iterator(); iter.hasNext(); ) {
281 Object o = iter.next();
282 if (o instanceof Entry)
283 v.add((Entry)o);
284 else {
285 Entry[] entries = (Entry[])o;
286 for (int i = 0; i < entries.length; i++)
287 v.add(entries[i]);
288 }
289 }
290 return v.iterator();
291 }
292
293 }
294
295
296 /**
297 * Merge the contents of another exclude list into this one.
298 * The individual entries are merged; The title of the exclude list
299 * being merged is ignored.
300 * @param other the exclude list to be merged with this one.
301 *
302 */
303 public void merge(KnownFailuresList other) {
304 synchronized (table) {
305 for (Iterator iter = other.getIterator(false); iter.hasNext(); ) {
306 Entry otherEntry = (Entry) (iter.next());
307 Key key = new Key(otherEntry.relativeURL);
308 Object o = table.get(key);
309 if (o == null) {
310 // Easy case: nothing already exists in the table, so just
311 // add this one
312 table.put(key, otherEntry);
313 }
314 else if (o instanceof Entry) {
315 // A single entry exists in the table
316 Entry curr = (Entry)o;
317 if (curr.testCase == null || otherEntry.testCase == null) {
318 table.put(key, new Entry(curr.relativeURL, null,
319 ExcludeList.mergeBugIds(curr.bugIdStrings, otherEntry.bugIdStrings),
320 ExcludeList.mergeSynopsis(curr.notes, otherEntry.notes)));
321 }
322 else
323 table.put(key, new Entry[] {curr, otherEntry});
324 }
325 else if (otherEntry.testCase == null) {
326 // An array of test cases exist in the table, but we're merging
690 char c1 = Character.toLowerCase(u1.charAt(i));
691 if (c1 == sep)
692 c1 = '/';
693 char c2 = Character.toLowerCase(u2.charAt(i));
694 if (c2 == sep)
695 c2 = '/';
696 if (c1 != c2)
697 return false;
698 }
699 return true;
700 }
701
702 private static final char sep = File.separatorChar;
703 private String relativeURL;
704 private int hash;
705 }
706
707 /**
708 * An entry in the exclude list.
709 */
710 public static final class Entry implements Comparable {
711 /**
712 * Create an ExcludeList entry.
713 * @param u The URL for the test, specified relative to the test suite root.
714 * @param tc One or more test cases within the test to be excluded.
715 * @param b An array of bug identifiers, justifying why the test is excluded.
716
717 * @param s A short synopsis of the reasons why the test is excluded.
718 */
719 public Entry(String u, String tc, String[] b, String s) {
720 if (b == null)
721 throw new NullPointerException();
722
723 // The file format cannot support platforms but no bugids,
724 // so fault that; other combinations (bugs, no platforms;
725 // no bugs, no platforms etc) are acceptable.
726 if (b.length == 0)
727 throw new IllegalArgumentException();
728
729 relativeURL = u;
730 testCase = tc;
731 bugIdStrings = b;
732 notes = s;
733 }
734
735 public int compareTo(Object o) {
736 Entry e = (Entry) o;
737 int n = relativeURL.compareTo(e.relativeURL);
738 if (n == 0) {
739 if (testCase == null && e.testCase == null)
740 return 0;
741 else if (testCase == null)
742 return -1;
743 else if (e.testCase == null)
744 return +1;
745 else
746 return testCase.compareTo(e.testCase);
747 }
748 else
749 return n;
750 }
751
752 public boolean containsTestCase(String s) {
753 String[] tcs = getTestCaseList();
754
755 if (tcs == null || tcs.length == 0)
756 return false;
|
260
261 /**
262 * Iterate over the contents of the table.
263 * @param group if <code>true</code>, entries for the same relative
264 * URL are grouped together, and if more than one, returned in an
265 * array; if <code>false</code>, the iterator always returns
266 * separate entries.
267 * @see Entry
268 * @return an iterator for the table: the entries are either
269 * single instances of @link(Entry) or a mixture of @link(Entry)
270 * and @link(Entry)[], depending on the <code>group</code>
271 * parameter.
272 */
273 public Iterator<Entry> getIterator(boolean group) {
274 if (group)
275 return table.values().iterator();
276 else {
277 // flatten the enumeration into a vector, then
278 // enumerate that
279 List<Entry> v = new ArrayList<>(table.size());
280 for (Iterator<Object> iter = table.values().iterator(); iter.hasNext(); ) {
281 Object o = iter.next();
282 if (o instanceof Entry)
283 v.add((Entry)o);
284 else {
285 Entry[] entries = (Entry[])o;
286 for (int i = 0; i < entries.length; i++)
287 v.add(entries[i]);
288 }
289 }
290 return v.iterator();
291 }
292
293 }
294
295
296 /**
297 * Merge the contents of another exclude list into this one.
298 * The individual entries are merged; The title of the exclude list
299 * being merged is ignored.
300 * @param other the exclude list to be merged with this one.
301 *
302 */
303 public void merge(KnownFailuresList other) {
304 synchronized (table) {
305 for (Iterator<Entry> iter = other.getIterator(false); iter.hasNext(); ) {
306 Entry otherEntry = iter.next();
307 Key key = new Key(otherEntry.relativeURL);
308 Object o = table.get(key);
309 if (o == null) {
310 // Easy case: nothing already exists in the table, so just
311 // add this one
312 table.put(key, otherEntry);
313 }
314 else if (o instanceof Entry) {
315 // A single entry exists in the table
316 Entry curr = (Entry)o;
317 if (curr.testCase == null || otherEntry.testCase == null) {
318 table.put(key, new Entry(curr.relativeURL, null,
319 ExcludeList.mergeBugIds(curr.bugIdStrings, otherEntry.bugIdStrings),
320 ExcludeList.mergeSynopsis(curr.notes, otherEntry.notes)));
321 }
322 else
323 table.put(key, new Entry[] {curr, otherEntry});
324 }
325 else if (otherEntry.testCase == null) {
326 // An array of test cases exist in the table, but we're merging
690 char c1 = Character.toLowerCase(u1.charAt(i));
691 if (c1 == sep)
692 c1 = '/';
693 char c2 = Character.toLowerCase(u2.charAt(i));
694 if (c2 == sep)
695 c2 = '/';
696 if (c1 != c2)
697 return false;
698 }
699 return true;
700 }
701
702 private static final char sep = File.separatorChar;
703 private String relativeURL;
704 private int hash;
705 }
706
707 /**
708 * An entry in the exclude list.
709 */
710 public static final class Entry implements Comparable<Entry> {
711 /**
712 * Create an ExcludeList entry.
713 * @param u The URL for the test, specified relative to the test suite root.
714 * @param tc One or more test cases within the test to be excluded.
715 * @param b An array of bug identifiers, justifying why the test is excluded.
716
717 * @param s A short synopsis of the reasons why the test is excluded.
718 */
719 public Entry(String u, String tc, String[] b, String s) {
720 if (b == null)
721 throw new NullPointerException();
722
723 // The file format cannot support platforms but no bugids,
724 // so fault that; other combinations (bugs, no platforms;
725 // no bugs, no platforms etc) are acceptable.
726 if (b.length == 0)
727 throw new IllegalArgumentException();
728
729 relativeURL = u;
730 testCase = tc;
731 bugIdStrings = b;
732 notes = s;
733 }
734
735 public int compareTo(Entry e) {
736 int n = relativeURL.compareTo(e.relativeURL);
737 if (n == 0) {
738 if (testCase == null && e.testCase == null)
739 return 0;
740 else if (testCase == null)
741 return -1;
742 else if (e.testCase == null)
743 return +1;
744 else
745 return testCase.compareTo(e.testCase);
746 }
747 else
748 return n;
749 }
750
751 public boolean containsTestCase(String s) {
752 String[] tcs = getTestCaseList();
753
754 if (tcs == null || tcs.length == 0)
755 return false;
|