Public Member Functions | |
| JCompUnit (String packageName, String fileName) | |
| JCompUnit (JClass jClass) | |
| JCompUnit (JInterface jInterface) | |
| void | addStructure (JStructure jStructure) throws IllegalArgumentException |
| void | addClass (JClass jClass) |
| void | addInterface (JInterface jInterface) |
| SortedSet | getImports () |
| String | getFilename (String destDir) |
| String | getPackageName () |
| void | print () |
| void | print (String destDir) |
| void | print (String destDir, String lineSeparator) |
| void | print (JSourceWriter jsw) |
| final void | printStructures (JSourceWriter jsw, boolean printPublic) |
| void | setHeader (JComment comment) |
Static Protected Member Functions | |
| static String | getPackageFromClassName (String className) |
A representation of the Java Source code for a Java compilation unit. This is a useful utility when creating in memory source code. This package was modelled after the Java Reflection API as much as possible to reduce the learning curve.
| org.exolab.javasource.JCompUnit.JCompUnit | ( | String | packageName, | |
| String | fileName | |||
| ) |
| org.exolab.javasource.JCompUnit.JCompUnit | ( | JClass | jClass | ) |
Creates a new JCompUnit with the given JClass (which must have been created with either a full class name or package/local name) as the public class. Package and file name are taken from jClass.
| jClass | the public class for this JCompUnit. |
References org.exolab.javasource.JType.getLocalName(), and org.exolab.javasource.JStructure.getPackageName().
| org.exolab.javasource.JCompUnit.JCompUnit | ( | JInterface | jInterface | ) |
Creates a new JCompUnit with the given JInterface as public interface Package and file name are taken from jInterface.
| jInterface | the public interface for this JCompUnit. |
References org.exolab.javasource.JType.getLocalName(), and org.exolab.javasource.JStructure.getPackageName().
| void org.exolab.javasource.JCompUnit.addClass | ( | JClass | jClass | ) |
Adds a JClass which should be printed in this file.
Referenced by org.exolab.javasource.JCompUnit.addStructure().
| void org.exolab.javasource.JCompUnit.addInterface | ( | JInterface | jInterface | ) |
Adds a JInterface which should be printed in this file.
Referenced by org.exolab.javasource.JCompUnit.addStructure().
| void org.exolab.javasource.JCompUnit.addStructure | ( | JStructure | jStructure | ) | throws IllegalArgumentException |
Adds the given JStructure (either a JInterface or a JClass) to this JCompUnit.
| jStructure | the JStructure to add |
| IllegalArgumentException | when the given JStructure has the same name of an existing JStructure or if the class of jStructure is unknown. |
References org.exolab.javasource.JCompUnit.addClass(), org.exolab.javasource.JCompUnit.addInterface(), and org.exolab.javasource.JStructure.getName().
| String org.exolab.javasource.JCompUnit.getFilename | ( | String | destDir | ) |
Returns the name of the file that this JCompUnit would be printed as, given a call to print.
| destDir | the destination directory. This may be null. |
Referenced by org.exolab.javasource.JCompUnit.print().
| SortedSet org.exolab.javasource.JCompUnit.getImports | ( | ) |
returns a array of String containing all import classes/packages, also imports within the same package of this object.
References org.exolab.javasource.JStructure.getImports().
Referenced by org.exolab.javasource.JCompUnit.print().
| static String org.exolab.javasource.JCompUnit.getPackageFromClassName | ( | String | className | ) | [static, protected] |
| String org.exolab.javasource.JCompUnit.getPackageName | ( | ) |
Returns the name of the package that this JCompUnit is a member of
Referenced by org.exolab.javasource.JCompUnit.print().
| void org.exolab.javasource.JCompUnit.print | ( | JSourceWriter | jsw | ) |
Prints the source code for this JClass.
| jsw | the JSourceWriter to print to. |
References org.exolab.javasource.JSourceWriter.flush(), org.exolab.javasource.JCompUnit.getImports(), org.exolab.javasource.JCompUnit.getPackageName(), org.exolab.javasource.JComment.print(), org.exolab.javasource.JCompUnit.printStructures(), org.exolab.javasource.JSourceWriter.write(), and org.exolab.javasource.JSourceWriter.writeln().
| void org.exolab.javasource.JCompUnit.print | ( | ) |
Prints the source code for this JClass in the current directory with the default line seperator of the the runtime platform.
Referenced by org.exolab.javasource.JCompUnit.print().
| void org.exolab.javasource.JCompUnit.print | ( | String | destDir, | |
| String | lineSeparator | |||
| ) |
Prints the source code for this JCompUnit.
| destDir | the destination directory to generate the file. | |
| lineSeparator | the line separator to use at the end of each line. If null, then the default line separator for the runtime platform will be used. |
References org.exolab.javasource.JSourceWriter.close(), org.exolab.javasource.JSourceWriter.flush(), org.exolab.javasource.JCompUnit.getFilename(), org.exolab.javasource.JCompUnit.print(), and org.exolab.javasource.JSourceWriter.setLineSeparator().
| void org.exolab.javasource.JCompUnit.print | ( | String | destDir | ) |
Prints the source code for this JClass with the default line seperator of the the runtime platform.
| destDir | the destination directory to generate the file. |
References org.exolab.javasource.JCompUnit.print().
| final void org.exolab.javasource.JCompUnit.printStructures | ( | JSourceWriter | jsw, | |
| boolean | printPublic | |||
| ) |
Print the source code for the contained JClass objects.
| jsw | the JSourceWriter to print to. | |
| printPublic | if true, print only public classes; if false, print only non-public classes. |
References org.exolab.javasource.JStructure.getModifiers(), org.exolab.javasource.JModifiers.isPublic(), org.exolab.javasource.JClass.print(), org.exolab.javasource.JInterface.print(), and org.exolab.javasource.JSourceWriter.writeln().
Referenced by org.exolab.javasource.JCompUnit.print().
| void org.exolab.javasource.JCompUnit.setHeader | ( | JComment | comment | ) |
Sets the header comment for this JCompUnit
| comment | the comment to display at the top of the source file when printed |
1.7.0