001: /*
002: * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.source.util;
027:
028: import com.sun.source.tree.CompilationUnitTree;
029: import javax.lang.model.element.TypeElement;
030: import javax.tools.JavaFileObject;
031:
032: /**
033: * Provides details about work that has been done by the Sun Java Compiler, javac.
034: *
035: * @author Jonathan Gibbons
036: * @since 1.6
037: */
038: public final class TaskEvent {
039: /**
040: * Kind of task event.
041: * @since 1.6
042: */
043: public enum Kind {
044: /**
045: * For events related to the parsing of a file.
046: */
047: PARSE,
048: /**
049: * For events relating to elements being entered.
050: **/
051: ENTER,
052: /**
053: * For events relating to elements being analyzed for errors.
054: **/
055: ANALYZE,
056: /**
057: * For events relating to class files being generated.
058: **/
059: GENERATE,
060: /**
061: * For events relating to overall annotaion processing.
062: **/
063: ANNOTATION_PROCESSING,
064: /**
065: * For events relating to an individual annotation processing round.
066: **/
067: ANNOTATION_PROCESSING_ROUND
068: };
069:
070: public TaskEvent(Kind kind) {
071: this (kind, null, null, null);
072: }
073:
074: public TaskEvent(Kind kind, JavaFileObject sourceFile) {
075: this (kind, sourceFile, null, null);
076: }
077:
078: public TaskEvent(Kind kind, CompilationUnitTree unit) {
079: this (kind, unit.getSourceFile(), unit, null);
080: }
081:
082: public TaskEvent(Kind kind, CompilationUnitTree unit,
083: TypeElement clazz) {
084: this (kind, unit.getSourceFile(), unit, clazz);
085: }
086:
087: private TaskEvent(Kind kind, JavaFileObject file,
088: CompilationUnitTree unit, TypeElement clazz) {
089: this .kind = kind;
090: this .file = file;
091: this .unit = unit;
092: this .clazz = clazz;
093: }
094:
095: public Kind getKind() {
096: return kind;
097: }
098:
099: public JavaFileObject getSourceFile() {
100: return file;
101: }
102:
103: public CompilationUnitTree getCompilationUnit() {
104: return unit;
105: }
106:
107: public TypeElement getTypeElement() {
108: return clazz;
109: }
110:
111: public String toString() {
112: return "TaskEvent[" + kind + "," + file + ","
113: // the compilation unit is identified by the file
114: + clazz + "]";
115: }
116:
117: private Kind kind;
118: private JavaFileObject file;
119: private CompilationUnitTree unit;
120: private TypeElement clazz;
121: }
|