KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > apt > core > internal > env > ReconcileFilerImpl


1 /*******************************************************************************
2  * Copyright (c) 2006 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 package org.eclipse.jdt.apt.core.internal.env;
12
13 import java.io.File JavaDoc;
14 import java.io.IOException JavaDoc;
15 import java.io.OutputStream JavaDoc;
16 import java.io.PrintWriter JavaDoc;
17 import java.io.Writer JavaDoc;
18
19 import com.sun.mirror.apt.Filer;
20
21 /**
22  * An implementation of com.sun.mirror.apt.Filer for use during reconcile phase.
23  * This implementation is able to generate new Java source types (though it
24  * does not lay them onto disk), but it silently ignores attempts to generate
25  * binary, text, or class files.
26  */

27 final class ReconcileFilerImpl extends FilerImpl {
28     
29     private final ReconcileEnv _env;
30     
31     private static final OutputStream JavaDoc NO_OP_STREAM = new OutputStream JavaDoc(){
32         public void write(int b) throws IOException JavaDoc {
33             return;
34         }
35     };
36     
37     private static final class NoOpWriter extends Writer JavaDoc{
38         public void write(char[] cbuf, int off, int len)
39             throws IOException JavaDoc {
40             return;
41         }
42         public void flush() throws IOException JavaDoc {
43             return;
44         }
45         public void close() throws IOException JavaDoc {
46             return;
47         }
48     }
49     
50     public ReconcileFilerImpl(ReconcileEnv env) {
51         _env = env;
52     }
53     
54     @Override JavaDoc
55     protected AbstractCompilationEnv getEnv() {
56         return _env;
57     }
58
59     private static final PrintWriter JavaDoc NO_OP_WRITER = new PrintWriter JavaDoc(new NoOpWriter());
60     
61     public OutputStream JavaDoc createBinaryFile(Filer.Location loc, String JavaDoc pkg, File JavaDoc relPath)
62         throws IOException JavaDoc {
63         return NO_OP_STREAM;
64     }
65     
66     public OutputStream JavaDoc createClassFile(String JavaDoc name) throws IOException JavaDoc {
67         return NO_OP_STREAM;
68     }
69
70     public PrintWriter JavaDoc createTextFile(Filer.Location loc, String JavaDoc pkg, File JavaDoc relPath, String JavaDoc charsetName)
71         throws IOException JavaDoc {
72         return NO_OP_WRITER;
73     }
74 }
Popular Tags