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 |
|---|---|
| public static class | JStaticJavaFile.
A |
| private class | |
| public static interface | JStaticJavaFile.
Filter that alters the Java source code. |
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private final JStaticJavaFile. | |
| private final JStaticJavaFile. | |
| private final JPackage | |
| private final JStaticJavaFile. |
| Access | Constructor and Description |
|---|---|
| public | JStaticJavaFile(JPackage _pkg, String _className, Class<?> loadingClass, JStaticJavaFile.
|
| Modifier and Type | Method and Description |
|---|---|
| protected void | build(OutputStream os)
Implements abstract com. called by JPackage to produce the file image. |
| private JStaticJavaFile. | |
| public JClass | |
| protected boolean | isResource()
Overrides com. Returns true if this file should be generated into the directory that the resource files go into. |
| className | back to summary |
|---|---|
| private final String className | |
| clazz | back to summary |
|---|---|
| private final JStaticJavaFile. | |
| filter | back to summary |
|---|---|
| private final JStaticJavaFile. | |
| pkg | back to summary |
|---|---|
| private final JPackage pkg | |
| source | back to summary |
|---|---|
| private final JStaticJavaFile. | |
| JStaticJavaFile | back to summary |
|---|---|
| public JStaticJavaFile(JPackage _pkg, String _className, Class<?> loadingClass, JStaticJavaFile. | |
| build | back to summary |
|---|---|
| protected void build(OutputStream os) throws IOException Implements abstract com. Doc from com. called by JPackage to produce the file image.
| |
| createLineFilter | back to summary |
|---|---|
| private JStaticJavaFile. Creates a A derived class can override this method to process the contents of the source file. | |
| getJClass | back to summary |
|---|---|
| public JClass getJClass() Returns a class object that represents a statically generated code. | |
| isResource | back to summary |
|---|---|
| protected boolean isResource() Overrides com. Doc from com. Returns 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.
| |
LineFilter that combines two LineFilters.
| Modifier and Type | Field and Description |
|---|---|
| private final JStaticJavaFile. | |
| private final JStaticJavaFile. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String |
| first | back to summary |
|---|---|
| private final JStaticJavaFile. | |
| second | back to summary |
|---|---|
| private final JStaticJavaFile. | |
| ChainFilter | back to summary |
|---|---|
| public ChainFilter(JStaticJavaFile. | |
| process | back to summary |
|---|---|
| public String process(String line) throws ParseException Implements com.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final JTypeVar[] |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public JClass | _extends()
Implements abstract com. Gets the super class of this class. |
| public Iterator | _implements()
Implements abstract com. Iterates all super interfaces directly implemented by this class/interface. |
| public JPackage | _package()
Implements abstract com. Gets the package to which this class belongs. |
| public String | |
| public boolean | isAbstract()
Implements abstract com. Checks if this class is an abstract class. |
| public boolean | isInterface()
Implements abstract com. Checks if this object represents an interface. |
| public String | |
| protected JClass | substituteParams(JTypeVar[] variables, List<JClass> bindings)
Implements abstract com. Substitutes the type variables with their actual arguments. |
| public JTypeVar[] | typeParams()
Overrides com. Iterates all the type parameters of this class/interface. |
| typeParams | back to summary |
|---|---|
| private final JTypeVar[] typeParams | |
| JStaticClass | back to summary |
|---|---|
| pack-priv JStaticClass() | |
| _extends | back to summary |
|---|---|
| public JClass _extends() Implements abstract com. Doc from com. Gets the super class of this class.
| |
| _implements | back to summary |
|---|---|
| public Iterator Implements abstract com. Doc from com. Iterates all super interfaces directly implemented by this class/interface.
| |
| _package | back to summary |
|---|---|
| public JPackage _package() Implements abstract com. Doc from com. Gets the package to which this class belongs. Todo shall we move move this down?
| |
| fullName | back to summary |
|---|---|
| public String fullName() Implements abstract com. Doc from com. Gets the full name of the type. See http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#25430 for the details.
| |
| isAbstract | back to summary |
|---|---|
| public boolean isAbstract() Implements abstract com. Doc from com. Checks if this class is an abstract class.
| |
| isInterface | back to summary |
|---|---|
| public boolean isInterface() Implements abstract com. Doc from com. Checks if this object represents an interface.
| |
| name | back to summary |
|---|---|
| public String name() Implements abstract com. Doc from com. Gets the name of this class.
| |
| substituteParams | back to summary |
|---|---|
| protected JClass substituteParams(JTypeVar[] variables, List<JClass> bindings) Implements abstract com. Doc from com. Substitutes the type variables with their actual arguments.
For example, when this class is This method needs to work recursively.
| |
| typeParams | back to summary |
|---|---|
| public JTypeVar[] typeParams() Overrides com. Doc from com. Iterates all the type parameters of this class/interface.
For example, if this represents
| |
By implementing this interface, derived classes can modify the Java source file before it's written out.
| Modifier and Type | Method and Description |
|---|---|
| public String |
| process | back to summary |
|---|---|
public String process(String line) throws ParseException
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv InputStream |
| loadingClass | back to summary |
|---|---|
| pack-priv Class<?> loadingClass | |
| shortName | back to summary |
|---|---|
| pack-priv String shortName | |
| ResourceLoader | back to summary |
|---|---|
| pack-priv ResourceLoader(String shortName, Class<?> loadingClass) | |
| getResourceAsStream | back to summary |
|---|---|
| pack-priv InputStream getResourceAsStream() | |