2 * Copyright (c) 2004 World Wide Web Consortium,
3 * (Massachusetts Institute of Technology, Institut National de
4 * Recherche en Informatique et en Automatique, Keio University). All
5 * Rights Reserved. This program is distributed under the W3C's Software
6 * Intellectual Property License. This program is distributed in the
7 * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
13 package org.w3c.domts;
15 import java.util.ArrayList;
16 import java.util.List;
17 import java.util.Iterator;
19 import org.w3c.dom.DOMError;
20 import org.w3c.dom.DOMErrorHandler;
23 * This is a utility implementation of EventListener
24 * that captures all events and provides access
25 * to lists of all events by mode
27 public class DOMErrorMonitor
28 implements DOMErrorHandler {
29 private final List errors = new ArrayList();
35 public DOMErrorMonitor() {
39 * Implementation of DOMErrorHandler.handleError that
40 * adds copy of error to list for later retrieval.
43 public boolean handleError(DOMError error) {
44 errors.add(new DOMErrorImpl(error));
51 * @return return errors
53 public List getAllErrors() {
54 return new ArrayList(errors);
57 public void assertLowerSeverity(DOMTestCase testCase, String id, int severity) {
58 Iterator iter = errors.iterator();
59 while (iter.hasNext()) {
60 DOMError error = (DOMError) iter.next();
61 if (error.getSeverity() >= severity) {
62 testCase.fail(id + error.getMessage());