|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exolab.javasource.JType
org.exolab.javasource.JClass
A representation of the Java Source code for a Java Class. 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.
Field Summary |
Fields inherited from class org.exolab.javasource.JType |
Boolean, Byte, Char, Double, Float, Int, Long, Short |
Constructor Summary | |
JClass(java.lang.String name)
Creates a new JClass with the given name |
Method Summary | |
void |
addConstructor(JConstructor constructor)
Adds the given Constructor to this classes list of constructors. |
void |
addField(JField jField)
Adds the given JField to this JClass |
void |
addImport(java.lang.String className)
|
void |
addInterface(java.lang.String interfaceName)
|
void |
addMember(JMember jMember)
Adds the given JMember to this JClass |
void |
addMethod(JMethod jMethod)
Adds the given JMethod to this JClass |
void |
addMethods(JMethod[] jMethods)
Adds the given array of JMethods to this JClass |
JConstructor |
createConstructor()
Adds a JClass which should be printed in the same source file as this JClass public void addPackageClass(JClass jClass) { if (jClass != null) packageClasses.addElement(jClass); } //-- addPackageClass |
JConstructor |
getConstructor(int index)
|
JConstructor[] |
getConstructors()
|
JField |
getField(java.lang.String name)
Returns the member with the given name, or null if no member was found with the given name |
JField[] |
getFields()
Returns an array of all the JFields of this JClass |
java.lang.String |
getFilename(java.lang.String destDir)
Returns the name of the file that this JClass would be printed as, given a call to #print. |
JDocComment |
getJDocComment()
Returns the Java Doc comment for this JClass |
JMethod |
getMethod(int index)
|
JMethod |
getMethod(java.lang.String name,
int startIndex)
|
JMethod[] |
getMethods()
Returns an array of all the JMethods of this JClass |
JModifiers |
getModifiers()
Returns the JModifiers which allows the qualifiers to be changed |
java.lang.String |
getName(boolean stripPackage)
Returns the name of the class. |
java.lang.String |
getPackageName()
Returns the name of the package that this JClass is a member of |
JSourceCode |
getStaticInitializationCode()
Returns the JSourceCode for the static initializer of this JClass |
java.lang.String |
getSuperClass()
Gets the super Class that this class extends |
static boolean |
isValidClassName(java.lang.String name)
|
void |
print()
|
void |
print(java.lang.String destDir,
java.lang.String lineSeparator)
Prints the source code for this JClass |
void |
removeField(JField jField)
Removes the given JField from this JClass |
void |
removeField(java.lang.String name)
Removes the field with the given name from this JClass |
boolean |
removeImport(java.lang.String className)
|
void |
setHeader(JComment comment)
Sets the header comment for this JClass |
void |
setPackageName(java.lang.String packageName)
Allows changing the package name of this JClass |
void |
setSuperClass(java.lang.String superClass)
Sets the super Class that this class extends |
Methods inherited from class org.exolab.javasource.JType |
changePackage, createArray, getComponentType, getLocalName, getName, isArray, isPrimitive, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public JClass(java.lang.String name) throws java.lang.IllegalArgumentException
name
- the name of the JClass to create
java.lang.IllegalArgumentException
- when the given name
is not a valid Class nameMethod Detail |
public void addImport(java.lang.String className)
public void addInterface(java.lang.String interfaceName)
public void addConstructor(JConstructor constructor) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public void addField(JField jField) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- when the given
JField has a name of an existing JFieldpublic void addMember(JMember jMember) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- when the given
JMember has the same name of an existing JField
or JMethod respectively.public void addMethod(JMethod jMethod) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- when the given
JMethod has the same name of an existing JMethod.public void addMethods(JMethod[] jMethods) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- when any of the given
JMethods has the same name of an existing JMethod.public JConstructor createConstructor()
public JConstructor getConstructor(int index)
public JConstructor[] getConstructors()
public java.lang.String getFilename(java.lang.String destDir)
destDir
- the destination directory. This may be null.
public JDocComment getJDocComment()
public JField getField(java.lang.String name)
name
- the name of the member to return
public JField[] getFields()
public JMethod[] getMethods()
public JMethod getMethod(java.lang.String name, int startIndex)
public JMethod getMethod(int index)
public JModifiers getModifiers()
public java.lang.String getPackageName()
public java.lang.String getName(boolean stripPackage)
stripPackage
- True if you want the package name striped of the name
public boolean removeImport(java.lang.String className)
public JSourceCode getStaticInitializationCode()
public static boolean isValidClassName(java.lang.String name)
public void print()
public void print(java.lang.String destDir, java.lang.String lineSeparator)
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 removeField(java.lang.String name)
name
- the name of the field to removepublic void removeField(JField jField)
public void setHeader(JComment comment)
comment
- the comment to display at the top of the source file
when printedpublic void setPackageName(java.lang.String packageName)
packageName
- the package name to usepublic void setSuperClass(java.lang.String superClass)
superClass
- the super Class that this Class extendspublic java.lang.String getSuperClass()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |