KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > mdr > JMIStreamFactory


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.api.mdr;
21
22 import java.io.IOException JavaDoc;
23 import java.io.OutputStream JavaDoc;
24 import java.util.List JavaDoc;
25
26 /** Class used by JMI mapper to obtain output streams for generating JMI interfaces.
27  * Subclasses should implement the <code>{@link #createStream(List, String, String)}
28  * method to create/open an output stream based on a provided package name, class
29  * name and file extension.
30  *
31  */

32 public abstract class JMIStreamFactory {
33
34     /** Extension for Java source files */
35     public static final String JavaDoc EXT_JAVA = "java"; //NOI18N
36

37     /** Extension for Java bytecode files */
38     public static final String JavaDoc EXT_CLASS = "class"; //NOI18N
39

40     /** Creates a new output stream based on a provided package name and class name.
41      * Assumes that the data generated will be Java source code (e.g. creates FileOutputStream
42      * for a file with "java" extension). Calling this method has the same effect
43      * as calling {@link #createStream(List, String, String)} with the last parameter
44      * set to <code>EXT_JAVA</code>.
45      * @param pkg Parsed package name.
46      * @param className Class name.
47      * @throws IOException I/O error during stream creation.
48      * @return Created stream, or <code>null</code> if nothing needs to be written
49      * for the class or interface.
50      *
51      */

52     public OutputStream JavaDoc createStream(List JavaDoc pkg, String JavaDoc className) throws IOException JavaDoc {
53         return createStream(pkg, className, EXT_JAVA);
54     }
55
56     /** Creates a new output stream based on a provided package name, class name and
57      * extension for the returned stream should correspond to (e.g.
58      * {@link #EXT_CLASS} to generate byte code or {@link #EXT_JAVA} to generate
59      * source code). The stream factory can return <code>null</code> to indicate
60      * that nothing needs to be written for the given class or interface. For
61      * example, if the stream factory is able to determine that the destination
62      * file already exists and is up to date, then <code>null</code> could be
63      * returned so that the file is not needlessly rewritten.
64      * @param pkg Parsed package name.
65      * @param className Class name.
66      * @param extension The type of file that should be generated.
67      * @throws IOException I/O error during stream creation.
68      * @return Created stream, or <code>null</code> if nothing needs to be written
69      * for the class or interface.
70      *
71      */

72     public abstract OutputStream JavaDoc createStream(List JavaDoc pkg, String JavaDoc className, String JavaDoc extension) throws IOException JavaDoc;
73 }
74
75
Popular Tags