KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > apt > pluggable > core > filer > IdeOutputJavaFileObject


1 /*******************************************************************************
2  * Copyright (c) 2007 BEA Systems, Inc.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * wharley@bea.com - initial API and implementation
10  *
11  *******************************************************************************/

12
13 package org.eclipse.jdt.internal.apt.pluggable.core.filer;
14
15 import java.io.IOException JavaDoc;
16 import java.io.InputStream JavaDoc;
17 import java.io.OutputStream JavaDoc;
18 import java.io.Reader JavaDoc;
19 import java.io.Writer JavaDoc;
20 import java.net.URI JavaDoc;
21 import java.util.Collection JavaDoc;
22
23 import javax.lang.model.element.Modifier;
24 import javax.lang.model.element.NestingKind;
25 import javax.tools.JavaFileObject;
26
27 import org.eclipse.core.resources.IFile;
28 import org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl;
29
30 /**
31  * Implementation of JavaFileObject used for Java 6 annotation processing within the IDE.
32  * This object is used only for writing source and class files.
33  *
34  * @since 3.3
35  */

36 public class IdeOutputJavaFileObject implements JavaFileObject {
37     
38     private final IdeProcessingEnvImpl _env;
39     private final CharSequence JavaDoc _name;
40     private final Collection JavaDoc<IFile> _parentFiles;
41
42     public IdeOutputJavaFileObject(IdeProcessingEnvImpl env, CharSequence JavaDoc name, Collection JavaDoc<IFile> parentFiles) {
43         _env = env;
44         _parentFiles = parentFiles;
45         _name = name;
46     }
47
48     /* (non-Javadoc)
49      * @see javax.tools.JavaFileObject#getAccessLevel()
50      */

51     @Override JavaDoc
52     public Modifier getAccessLevel() {
53         //TODO
54
throw new UnsupportedOperationException JavaDoc("Not yet implemented");
55     }
56
57     /* (non-Javadoc)
58      * @see javax.tools.JavaFileObject#getKind()
59      */

60     @Override JavaDoc
61     public Kind getKind() {
62         //TODO
63
throw new UnsupportedOperationException JavaDoc("Not yet implemented");
64     }
65
66     /* (non-Javadoc)
67      * @see javax.tools.JavaFileObject#getNestingKind()
68      */

69     @Override JavaDoc
70     public NestingKind getNestingKind() {
71         //TODO
72
throw new UnsupportedOperationException JavaDoc("Not yet implemented");
73     }
74
75     /* (non-Javadoc)
76      * @see javax.tools.JavaFileObject#isNameCompatible(java.lang.String, javax.tools.JavaFileObject.Kind)
77      */

78     @Override JavaDoc
79     public boolean isNameCompatible(String JavaDoc simpleName, Kind kind) {
80         //TODO
81
throw new UnsupportedOperationException JavaDoc("Not yet implemented");
82     }
83
84     /* (non-Javadoc)
85      * @see javax.tools.FileObject#delete()
86      */

87     @Override JavaDoc
88     public boolean delete() {
89         throw new UnsupportedOperationException JavaDoc("Deleting a file is not permitted from within an annotation processor");
90     }
91
92     /* (non-Javadoc)
93      * @see javax.tools.FileObject#getCharContent(boolean)
94      */

95     @Override JavaDoc
96     public CharSequence JavaDoc getCharContent(boolean ignoreEncodingErrors) throws IOException JavaDoc {
97         //TODO
98
throw new IllegalStateException JavaDoc("Generated files are write-only");
99     }
100
101     /* (non-Javadoc)
102      * @see javax.tools.FileObject#getLastModified()
103      */

104     @Override JavaDoc
105     public long getLastModified() {
106         //TODO
107
throw new UnsupportedOperationException JavaDoc("Not yet implemented");
108     }
109
110     /* (non-Javadoc)
111      * @see javax.tools.FileObject#getName()
112      */

113     @Override JavaDoc
114     public String JavaDoc getName() {
115         return _name.toString();
116     }
117
118     /* (non-Javadoc)
119      * @see javax.tools.FileObject#openInputStream()
120      */

121     @Override JavaDoc
122     public InputStream JavaDoc openInputStream() throws IOException JavaDoc {
123         throw new IllegalStateException JavaDoc("Opening an input stream on a generated file is not permitted");
124     }
125
126     /* (non-Javadoc)
127      * @see javax.tools.FileObject#openOutputStream()
128      */

129     @Override JavaDoc
130     public OutputStream JavaDoc openOutputStream() throws IOException JavaDoc {
131         //TODO
132
throw new UnsupportedOperationException JavaDoc("Not yet implemented");
133     }
134
135     /* (non-Javadoc)
136      * @see javax.tools.FileObject#openReader(boolean)
137      */

138     @Override JavaDoc
139     public Reader JavaDoc openReader(boolean ignoreEncodingErrors) throws IOException JavaDoc {
140         throw new IllegalStateException JavaDoc("Opening a reader on a generated file is not permitted");
141     }
142
143     /* (non-Javadoc)
144      * @see javax.tools.FileObject#openWriter()
145      */

146     @Override JavaDoc
147     public Writer JavaDoc openWriter() throws IOException JavaDoc {
148         return new IdeJavaSourceFileWriter(_env, _name, _parentFiles);
149     }
150
151     /* (non-Javadoc)
152      * @see javax.tools.FileObject#toUri()
153      */

154     @Override JavaDoc
155     public URI JavaDoc toUri() {
156         // The file does not exist until its writer is closed.
157
throw new UnsupportedOperationException JavaDoc("Not yet implemented");
158     }
159
160 }
161
Popular Tags