KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > source > util > TaskEvent


1 /*
2  * @(#)TaskEvent.java 1.4 06/03/30
3  *
4  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  *
7  * Use and Distribution is subject to the Java Research License available
8  * at <http://wwws.sun.com/software/communitysource/jrl.html>.
9  */

10
11 package com.sun.source.util;
12
13 import com.sun.source.tree.CompilationUnitTree;
14 import javax.lang.model.element.TypeElement;
15 import javax.tools.JavaFileObject;
16
17 /**
18  * Provides details about work that has been done by the Sun Java Compiler, javac.
19  *
20  * @author Jonathan Gibbons
21  * @since 1.6
22  */

23 public final class TaskEvent
24 {
25     /**
26      * Kind of task event.
27      * @since 1.6
28      */

29     public enum Kind {
30         /**
31          * For events related to the parsing of a file.
32          */

33     PARSE,
34         /**
35          * For events relating to elements being entered.
36          **/

37     ENTER,
38         /**
39          * For events relating to elements being analyzed for errors.
40          **/

41     ANALYZE,
42         /**
43          * For events relating to class files being generated.
44          **/

45     GENERATE,
46         /**
47          * For events relating to overall annotaion processing.
48          **/

49         ANNOTATION_PROCESSING,
50         /**
51          * For events relating to an individual annotation processing round.
52          **/

53         ANNOTATION_PROCESSING_ROUND
54     };
55
56     public TaskEvent(Kind kind) {
57     this(kind, null, null, null);
58     }
59
60     public TaskEvent(Kind kind, JavaFileObject sourceFile) {
61     this(kind, sourceFile, null, null);
62     }
63
64     public TaskEvent(Kind kind, CompilationUnitTree unit) {
65     this(kind, unit.getSourceFile(), unit, null);
66     }
67
68     public TaskEvent(Kind kind, CompilationUnitTree unit, TypeElement clazz) {
69     this(kind, unit.getSourceFile(), unit, clazz);
70     }
71
72     private TaskEvent(Kind kind, JavaFileObject file, CompilationUnitTree unit, TypeElement clazz) {
73     this.kind = kind;
74     this.file = file;
75     this.unit = unit;
76     this.clazz = clazz;
77     }
78
79     public Kind getKind() {
80     return kind;
81     }
82
83     public JavaFileObject getSourceFile() {
84     return file;
85     }
86
87     public CompilationUnitTree getCompilationUnit() {
88     return unit;
89     }
90
91     public TypeElement getTypeElement() {
92     return clazz;
93     }
94     
95     public String JavaDoc toString() {
96     return "TaskEvent["
97         + kind + ","
98         + file + ","
99         // the compilation unit is identified by the file
100
+ clazz + "]";
101     }
102
103     private Kind kind;
104     private JavaFileObject file;
105     private CompilationUnitTree unit;
106     private TypeElement clazz;
107 }
108
Popular Tags