public final class JCompUnit extends Object
| Constructor and Description |
|---|
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.
|
JCompUnit(JInterface jInterface)
Creates a new JCompUnit with the given JInterface as public interface.
|
JCompUnit(String packageName,
String fileName)
Creates a new JCompUnit.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addClass(JClass jClass)
Adds a JClass to be printed in this file.
|
void |
addInterface(JInterface jInterface)
Adds a JInterface to be printed in this file.
|
void |
addStructure(JStructure jStructure)
Adds the given JStructure (either a JInterface or a JClass) to this JCompUnit.
|
String |
getFilename(String destDir)
Returns the name of the file that this JCompUnit would be printed to, given a call to
print(String, String), or if destDir is null, a call to print(). |
SortedSet<String> |
getImports()
Returns a array of String containing all imported classes/packages, also imports within the
same package of this object.
|
String |
getPackageName()
Returns the name of the package that this JCompUnit is a member of.
|
void |
print()
Prints the source code for this JClass in the current directory with the default line seperator
of the the runtime platform.
|
void |
print(JSourceWriter jsw)
Prints the source code for this JClass to the provided JSourceWriter.
|
void |
print(String destDir)
Prints the source code for this JClass with the default line seperator of the the runtime
platform.
|
void |
print(String destDir,
String lineSeparator)
Prints the source code for this JCompUnit using the provided root directory and line separator.
|
void |
printStructures(JSourceWriter jsw,
boolean printPublic)
Print the source code for the contained JClass objects.
|
void |
setHeader(JComment comment)
Sets the header comment for this JCompUnit.
|
public JCompUnit(String packageName, String fileName)
packageName - The name of the package for this JCompUnit. If packageName is null or empty,
no 'package' line will be generated.fileName - The name of the file to which this JCompUnit will be written.public JCompUnit(JClass jClass)
jClass - The public class for this JCompUnit.public JCompUnit(JInterface jInterface)
jInterface - The public interface for this JCompUnit.public void setHeader(JComment comment)
comment - The comment to display at the top of the source file when printed.public void addStructure(JStructure jStructure)
jStructure - The JStructure to add.public void addClass(JClass jClass)
jClass - The JClass to be printed in this file.public void addInterface(JInterface jInterface)
jInterface - The JInterface to be printed in this file.public SortedSet<String> getImports()
public String getFilename(String destDir)
print(String, String), or if destDir is null, a call to print().destDir - The destination directory. This may be null.public String getPackageName()
public void print()
print(String, String)public void print(String destDir)
destDir - The destination directory to use as the root directory for source generation.print(String, String)public void print(String destDir, String lineSeparator)
destDir - The destination directory to use as the root directory for source generation.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.public void print(JSourceWriter jsw)
jsw - The JSourceWriter to print to.public void printStructures(JSourceWriter jsw, boolean printPublic)
jsw - The JSourceWriter to print to.printPublic - If true, print only public classes; if false, print only non-public classes.Copyright © 2016. All rights reserved.