Class JStaticJavaFile
- java.lang.Object
-
- com.sun.codemodel.JResourceFile
-
- com.sun.codemodel.fmt.JStaticJavaFile
-
public final class JStaticJavaFile extends JResourceFile
Statically generated Java soruce file.This
JResourceFileimplementation 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
JClassobject 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
JClassobject doesn't respond to methods like "isInterface" or "_extends",
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJStaticJavaFile.ChainFilterAJStaticJavaFile.LineFilterthat combines twoJStaticJavaFile.LineFilters.private classJStaticJavaFile.JStaticClassstatic interfaceJStaticJavaFile.LineFilterFilter that alters the Java source code.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringclassNameprivate JStaticJavaFile.JStaticClassclazzprivate JStaticJavaFile.LineFilterfilterprivate JPackagepkgprivate java.net.URLsource
-
Constructor Summary
Constructors Constructor 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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbuild(java.io.OutputStream os)called by JPackage to produce the file image.private JStaticJavaFile.LineFiltercreateLineFilter()Creates aJStaticJavaFile.LineFilter.JClassgetJClass()Returns a class object that represents a statically generated code.protected booleanisResource()Returns true if this file should be generated into the directory that the resource files go into.-
Methods inherited from class com.sun.codemodel.JResourceFile
name
-
-
-
-
Field Detail
-
pkg
private final JPackage pkg
-
className
private final java.lang.String className
-
source
private final java.net.URL source
-
clazz
private final JStaticJavaFile.JStaticClass clazz
-
filter
private final JStaticJavaFile.LineFilter filter
-
-
Constructor Detail
-
JStaticJavaFile
public JStaticJavaFile(JPackage _pkg, java.lang.String className, java.lang.String _resourceName)
-
JStaticJavaFile
public JStaticJavaFile(JPackage _pkg, java.lang.String _className, java.net.URL _source, JStaticJavaFile.LineFilter _filter)
-
-
Method Detail
-
getJClass
public final JClass getJClass()
Returns a class object that represents a statically generated code.
-
isResource
protected boolean isResource()
Description copied from class:JResourceFileReturns true if this file should be generated into the directory that the resource files go into.Returns false if this file should be generated into the directory where other source files go.
- Overrides:
isResourcein classJResourceFile
-
build
protected void build(java.io.OutputStream os) throws java.io.IOExceptionDescription copied from class:JResourceFilecalled by JPackage to produce the file image.- Specified by:
buildin classJResourceFile- Throws:
java.io.IOException
-
createLineFilter
private JStaticJavaFile.LineFilter createLineFilter()
Creates aJStaticJavaFile.LineFilter.A derived class can override this method to process the contents of the source file.
-
-