public final class JStaticJavaFile extends JResourceFile
This JResourceFile implementation will generate a Java source
file by copying the source code from a resource.
While copying a resource, we look for a package declaration and replace it with the target package name. This allows the static Java source code to have an arbitrary package declaration.
You can also use the getJClass method to obtain a JClass
object that represents the static file. This allows the client code
to refer to the class from other CodeModel generated code.
Note that because we don't parse the static Java source code,
the returned JClass object doesn't respond to methods like
"isInterface" or "_extends",
| Modifier and Type | Class and Description |
|---|---|
static class |
JStaticJavaFile.ChainFilter
A
JStaticJavaFile.LineFilter that combines two JStaticJavaFile.LineFilters. |
private class |
JStaticJavaFile.JStaticClass |
static interface |
JStaticJavaFile.LineFilter
Filter that alters the Java source code.
|
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
className |
private JStaticJavaFile.JStaticClass |
clazz |
private JStaticJavaFile.LineFilter |
filter |
private JPackage |
pkg |
private java.net.URL |
source |
| Constructor and Description |
|---|
JStaticJavaFile(JPackage _pkg,
java.lang.String className,
java.lang.String _resourceName) |
JStaticJavaFile(JPackage _pkg,
java.lang.String _className,
java.net.URL _source,
JStaticJavaFile.LineFilter _filter) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
build(java.io.OutputStream os)
called by JPackage to produce the file image.
|
private JStaticJavaFile.LineFilter |
createLineFilter()
Creates a
JStaticJavaFile.LineFilter. |
JClass |
getJClass()
Returns a class object that represents a statically generated code.
|
protected boolean |
isResource()
Returns true if this file should be generated into the directory
that the resource files go into.
|
nameprivate final JPackage pkg
private final java.lang.String className
private final java.net.URL source
private final JStaticJavaFile.JStaticClass clazz
private final JStaticJavaFile.LineFilter filter
public JStaticJavaFile(JPackage _pkg, java.lang.String className, java.lang.String _resourceName)
public JStaticJavaFile(JPackage _pkg, java.lang.String _className, java.net.URL _source, JStaticJavaFile.LineFilter _filter)
public final JClass getJClass()
protected boolean isResource()
JResourceFileReturns false if this file should be generated into the directory where other source files go.
isResource in class JResourceFileprotected void build(java.io.OutputStream os)
throws java.io.IOException
JResourceFilebuild in class JResourceFilejava.io.IOExceptionprivate JStaticJavaFile.LineFilter createLineFilter()
JStaticJavaFile.LineFilter.
A derived class can override this method to process the contents of the source file.