KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > tools > DiagnosticCollector


1 /*
2  * @(#)DiagnosticCollector.java 1.2 06/03/17
3  *
4  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.tools;
9
10 import java.util.ArrayList JavaDoc;
11 import java.util.Collections JavaDoc;
12 import java.util.List JavaDoc;
13
14 /**
15  * Provides an easy way to collect diagnostics in a list.
16  *
17  * @param <S> the type of source objects used by diagnostics received
18  * by this object
19  *
20  * @author Peter von der Ah&eacute;
21  * @since 1.6
22  */

23 public final class DiagnosticCollector<S> implements DiagnosticListener<S> {
24     private List JavaDoc<Diagnostic<? extends S>> diagnostics =
25     Collections.synchronizedList(new ArrayList JavaDoc<Diagnostic<? extends S>>());
26
27     public void report(Diagnostic<? extends S> diagnostic) {
28     diagnostics.add(diagnostic);
29     }
30
31     /**
32      * Gets a list view of diagnostics collected by this object.
33      *
34      * @return a list view of diagnostics
35      */

36     public List JavaDoc<Diagnostic<? extends S>> getDiagnostics() {
37     return Collections.unmodifiableList(diagnostics);
38     }
39 }
40
Popular Tags