Classes | Public Member Functions | Static Public Member Functions

org.exolab.javasource.JClass Class Reference

Inheritance diagram for org.exolab.javasource.JClass:
org.exolab.javasource.JStructure org.exolab.javasource.JType org.exolab.javasource.JAnnotatedElement org.exolab.castor.builder.util.DescriptorJClass org.exolab.javasource.JClass.JInnerClass

List of all members.

Classes

class  JInnerClass

Public Member Functions

 JClass (String name) throws IllegalArgumentException
void addConstructor (JConstructor constructor) throws IllegalArgumentException
void addField (JField jField) throws IllegalArgumentException
void addMember (JMember jMember) throws IllegalArgumentException
void addMethod (JMethod jMethod)
void addMethod (JMethod jMethod, boolean importReturnType) throws IllegalArgumentException
void addMethods (JMethod[] jMethods) throws IllegalArgumentException
JConstructor createConstructor ()
JConstructor createConstructor (JParameter[] params)
JClass createInnerClass (String localname)
JConstructor getConstructor (int index)
JConstructor[] getConstructors ()
JField getField (String name)
JField[] getFields ()
JClass[] getInnerClasses ()
JMethod[] getMethods ()
JMethod getMethod (String name, int startIndex)
JMethod getMethod (int index)
JSourceCode getStaticInitializationCode ()
String getSuperClass ()
void print (JSourceWriter jsw)
void print (JSourceWriter jsw, boolean classOnly)
boolean removeConstructor (JConstructor constructor)
boolean removeMethod (JMethod method)
JField removeField (String name)
boolean removeField (JField jField)
boolean removeInnerClass (JClass jClass)
void setSuperClass (String superClass)

Static Public Member Functions

static void main (String[] args)

Detailed Description

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.

Author:
Keith Visco
Martin Skopp
Version:
Revision:
1.4
Date:
2004/12/03 18:36:30

Constructor & Destructor Documentation

org.exolab.javasource.JClass.JClass ( String  name  )  throws IllegalArgumentException

Creates a new JClass with the given name

Parameters:
name the name of the JClass to create
Exceptions:
IllegalArgumentException when the given name is not a valid Class name

References org.exolab.javasource.JDocComment.appendComment(), org.exolab.javasource.JStructure.getJDocComment(), and org.exolab.javasource.JType.getLocalName().

Referenced by org.exolab.javasource.JClass.main().


Member Function Documentation

void org.exolab.javasource.JClass.addConstructor ( JConstructor  constructor  )  throws IllegalArgumentException

Adds the given Constructor to this classes list of constructors. The constructor must have been created with this JClass' createConstructor.

Exceptions:
IllegalArgumentException 

check signatures (add later)

References org.exolab.javasource.JStructure.addImport(), and org.exolab.javasource.JStructure.getAnnotations().

Referenced by org.exolab.javasource.JClass.createConstructor().

void org.exolab.javasource.JClass.addMember ( JMember  jMember  )  throws IllegalArgumentException [virtual]

Adds the given JMember to this JClass

Parameters:
jMember,the JMember to add
Exceptions:
IllegalArgumentException when the given JMember has the same name of an existing JField or JMethod respectively, or if the JMember is of an unrecognized class.

Implements org.exolab.javasource.JStructure.

References org.exolab.javasource.JClass.addField(), org.exolab.javasource.JClass.addMethod(), and org.exolab.javasource.JMethod.getName().

Referenced by org.exolab.javasource.JClass.main().

void org.exolab.javasource.JClass.addMethod ( JMethod  jMethod  ) 

Adds the given JMethod to this JClass

Parameters:
jMethod,the JMethod to add
importReturnType true if we add the importReturnType to the class import lists. It could be useful to set it to false when all types are fully qualified.
Exceptions:
IllegalArgumentException when the given JMethod has the same name of an existing JMethod.

Referenced by org.exolab.javasource.JClass.addMember(), org.exolab.javasource.JClass.addMethods(), org.exolab.castor.builder.FieldInfo.createAccessMethods(), org.exolab.castor.builder.CollectionInfoJ2.createAccessMethods(), org.exolab.castor.builder.CollectionInfo.createAccessMethods(), org.exolab.castor.builder.SourceFactory.createEqualsMethod(), org.exolab.castor.builder.SourceFactory.createTestableMethods(), and org.exolab.javasource.JClass.main().

void org.exolab.javasource.JClass.addMethod ( JMethod  jMethod,
boolean  importReturnType 
) throws IllegalArgumentException

Adds the given JMethod to this JClass

Parameters:
jMethod,the JMethod to add
importReturnType true if we add the importReturnType to the class import lists. It could be useful to set it to false when all types are fully qualified.
Exceptions:
IllegalArgumentException when the given JMethod has the same name of an existing JMethod.

References org.exolab.javasource.JStructure.addImport(), org.exolab.javasource.JStructure.getAnnotations(), org.exolab.javasource.JType.getComponentType(), org.exolab.javasource.JMethod.getModifiers(), org.exolab.javasource.JStructure.getModifiers(), org.exolab.javasource.JType.getName(), org.exolab.javasource.JMethod.getName(), org.exolab.javasource.JType.isArray(), org.exolab.javasource.JType.isPrimitive(), org.exolab.javasource.JModifiers.isPrivate(), and org.exolab.javasource.JModifiers.setAbstract().

void org.exolab.javasource.JClass.addMethods ( JMethod[]  jMethods  )  throws IllegalArgumentException

Adds the given array of JMethods to this JClass

Parameters:
jMethods,the JMethod[] to add
Exceptions:
IllegalArgumentException when any of the given JMethods has the same name of an existing JMethod.

References org.exolab.javasource.JClass.addMethod().

JConstructor org.exolab.javasource.JClass.createConstructor ( JParameter[]  params  ) 

Creates a new JConstructor and adds it to this JClass.

Returns:
the newly created constructor

References org.exolab.javasource.JClass.addConstructor(), and org.exolab.javasource.JConstructor.addParameter().

JConstructor org.exolab.javasource.JClass.createConstructor (  ) 

Creates a new JConstructor and adds it to this JClass.

Returns:
the newly created constructor

Referenced by org.exolab.javasource.JClass.main().

JClass org.exolab.javasource.JClass.createInnerClass ( String  localname  ) 

Creates and returns an inner-class for this JClass

Parameters:
localname the name of the class (no package name)
Returns:
the new JClass

References org.exolab.javasource.JStructure.getPackageName().

Referenced by org.exolab.javasource.JClass.main().

JConstructor org.exolab.javasource.JClass.getConstructor ( int  index  ) 

Returns the constructor at the specified index.

Parameters:
index the index of the constructor to return
Returns:
the JConstructor at the specified index.

Referenced by org.exolab.castor.builder.DescriptorSourceFactory.createSource(), and org.exolab.castor.builder.SourceFactory.createSourceCode().

JConstructor [] org.exolab.javasource.JClass.getConstructors (  ) 

Returns the an array of the JConstructors contained within this JClass

Returns:
an array of JConstructor
JField org.exolab.javasource.JClass.getField ( String  name  )  [virtual]

Returns the member with the given name, or null if no member was found with the given name

Parameters:
name the name of the member to return
Returns:
the member with the given name, or null if no member was found with the given name

Implements org.exolab.javasource.JStructure.

References org.exolab.javasource.JNamedMap.get().

JField [] org.exolab.javasource.JClass.getFields (  )  [virtual]
JClass [] org.exolab.javasource.JClass.getInnerClasses (  ) 

Returns an array of JClass (the inner classes) contained within this JClass.

Returns:
an array of JClass contained within this JClass
JMethod org.exolab.javasource.JClass.getMethod ( String  name,
int  startIndex 
)

Returns the first occurance of the method with the given name, starting from the specified index.

Parameters:
name the name of the method to look for
startIndex the starting index to begin the search
Returns:
the method if found, otherwise null.

References org.exolab.javasource.JMethod.getName().

Referenced by org.exolab.castor.builder.SourceFactory.createTestableMethods().

JMethod org.exolab.javasource.JClass.getMethod ( int  index  ) 

Returns the JMethod located at the specified index

Parameters:
index the index of the JMethod to return.
Returns:
the JMethod
JMethod [] org.exolab.javasource.JClass.getMethods (  ) 

Returns an array of all the JMethods of this JClass

Returns:
an array of all the JMethods of this JClass
JSourceCode org.exolab.javasource.JClass.getStaticInitializationCode (  ) 

Returns the JSourceCode for the static initializer of this JClass

Returns:
the JSourceCode for the static initializer of this JClass

Referenced by org.exolab.javasource.JClass.main().

String org.exolab.javasource.JClass.getSuperClass (  ) 

Gets the super Class that this class extends

Returns:
superClass the super Class that this Class extends

Referenced by org.exolab.castor.builder.SourceFactory.createEqualsMethod(), and org.exolab.castor.builder.SourceFactory.createSourceCode().

void org.exolab.javasource.JClass.print ( JSourceWriter  jsw,
boolean  classOnly 
)

Prints the source code for this JClass to the given JSourceWriter

Parameters:
jsw the JSourceWriter to print to. [May not be null]

References org.exolab.javasource.JStructure.addImport(), org.exolab.javasource.JSourceWriter.flush(), org.exolab.javasource.JNamedMap.get(), org.exolab.javasource.JStructure.getAnnotatedElementHelper(), org.exolab.javasource.JField.getComment(), org.exolab.javasource.JStructure.getImports(), org.exolab.javasource.JField.getInitString(), org.exolab.javasource.JStructure.getInterfaceCount(), org.exolab.javasource.JStructure.getInterfaces(), org.exolab.javasource.JStructure.getJDocComment(), org.exolab.javasource.JType.getLocalName(), org.exolab.javasource.JField.getModifiers(), org.exolab.javasource.JStructure.getModifiers(), org.exolab.javasource.JField.getName(), org.exolab.javasource.JField.getType(), org.exolab.javasource.JStructure.hasImport(), org.exolab.javasource.JSourceWriter.indent(), org.exolab.javasource.JSourceCode.isEmpty(), org.exolab.javasource.JModifiers.isPrivate(), org.exolab.javasource.JModifiers.isPublic(), org.exolab.javasource.JClass.print(), org.exolab.javasource.JMethod.print(), org.exolab.javasource.JConstructor.print(), org.exolab.javasource.JDocComment.print(), org.exolab.javasource.JStructure.printHeader(), org.exolab.javasource.JStructure.printImportDeclarations(), org.exolab.javasource.JStructure.printPackageDeclaration(), org.exolab.javasource.JStructure.removeImport(), org.exolab.javasource.JNamedMap.size(), org.exolab.javasource.JSourceCode.toString(), org.exolab.javasource.JType.toString(), org.exolab.javasource.JModifiers.toString(), org.exolab.javasource.JSourceWriter.unindent(), org.exolab.javasource.JSourceWriter.write(), and org.exolab.javasource.JSourceWriter.writeln().

void org.exolab.javasource.JClass.print ( JSourceWriter  jsw  )  [virtual]

Prints the source code for this JClass to the given JSourceWriter

Parameters:
jsw the JSourceWriter to print to. [May not be null]

Implements org.exolab.javasource.JStructure.

References org.exolab.javasource.JStructure.print().

Referenced by org.exolab.javasource.JClass.main(), org.exolab.javasource.JClass.print(), and org.exolab.javasource.JCompUnit.printStructures().

boolean org.exolab.javasource.JClass.removeConstructor ( JConstructor  constructor  ) 

Removes the given constructor from this JClass

Parameters:
constructor the JConstructor to remove
Returns:
true if the constructor was removed, otherwise false.
JField org.exolab.javasource.JClass.removeField ( String  name  ) 

Removes the field with the given name from this JClass

Parameters:
name the name of the field to remove

References org.exolab.javasource.JNamedMap.remove().

boolean org.exolab.javasource.JClass.removeField ( JField  jField  ) 
boolean org.exolab.javasource.JClass.removeInnerClass ( JClass  jClass  ) 

Removes the given inner-class (JClass) from this JClass.

Parameters:
jClass the JClass (inner-class) to remove.
Returns:
true if the JClass was removed, otherwise false.
boolean org.exolab.javasource.JClass.removeMethod ( JMethod  method  ) 

Removes the given method from this JClass

Parameters:
method the JMethod to remove
Returns:
true if the method was removed, otherwise false.
void org.exolab.javasource.JClass.setSuperClass ( String  superClass  ) 

Sets the super Class that this class extends

Parameters:
superClass the super Class that this Class extends

Referenced by org.exolab.castor.builder.SourceFactory.createSourceCode().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties