org.fuin.srcgen4javassist
Class SgClass

java.lang.Object
  extended by org.fuin.srcgen4javassist.SgClass

public final class SgClass
extends java.lang.Object

A class. TODO Add annotation handling


Field Summary
static SgClass BOOLEAN
          Simple "boolean" type.
static SgClass BYTE
          Simple "byte" type.
static SgClass CHAR
          Simple "char" type.
static SgClass DOUBLE
          Simple "double" type.
static SgClass FLOAT
          Simple "float" type.
static SgClass INT
          Simple "int" type.
static SgClass LONG
          Simple "long" type.
static SgClass OBJECT
          Base "Object" type.
static SgClass SHORT
          Simple "short" type.
static SgClass VOID
          Simple "void" type.
 
Constructor Summary
SgClass(java.lang.String packageName, java.lang.String simpleName)
          Basic constructor.
SgClass(java.lang.String modifiers, java.lang.String packageName, java.lang.String simpleName, boolean isinterface, SgClass enclosingClass)
          Constructor without super class.
SgClass(java.lang.String modifiers, java.lang.String packageName, java.lang.String simpleName, SgClass superClass, boolean isinterface, SgClass enclosingClass)
          Constructor with super class.
 
Method Summary
 void addClass(SgClass clasz)
          Adds an inner to this class.
 void addConstructor(SgConstructor constructor)
          Adds a constructor to the class.
 void addField(SgField field)
          Adds a field to the class.
 void addInterface(SgClass intf)
          Add an interface to the class.
 void addMethod(SgMethod method)
          Adds a method to the class.
static SgClass create(SgClassPool pool, java.lang.Class clasz)
          Creates a model class by analyzing the "real" class.
static SgClass create(SgClassPool pool, java.lang.String className)
          Creates a model class by loading the "real" class with Class.forName(..)
 SgClass findClassByName(java.lang.String name)
          Find an inner class by it's name.
 SgField findFieldByName(java.lang.String name)
          Find a field by it's name.
 SgMethod findMethodByName(java.lang.String name)
          Find a method by it's name.
 java.util.List<SgClass> getClasses()
          Returns a list of all inner class.
 java.util.List<SgConstructor> getConstructors()
          Returns a list of constructors.
 SgClass getEnclosingClass()
          Returns the enclosing class.
 java.util.List<SgField> getFields()
          Returns a list of all fields.
 java.util.List<SgClass> getInterfaces()
          Returns a list of all interfaces.
 java.lang.String getInterfacesCommaSeparated()
          Returns all (fully qualified) interface names.
 java.util.List<SgMethod> getMethods()
          Returns a list of all methods.
 java.lang.String getModifiers()
          Returns the modifiers as text.
 java.lang.String getName()
          Returns the name of the class.
 java.lang.String getNameAsBinFilename()
          Returns the package and name as a class filename.
 java.lang.String getNameAsFilename()
          Returns the package and name as a filename without extension.
 java.lang.String getNameAsSrcFilename()
          Returns the package and name as a source filename.
 java.lang.String getPackageName()
          Returns the package of the class.
 java.lang.String getSimpleName()
          Returns the simple name of the class.
 java.lang.String getSimpleNameAsPackage()
          Returns the simple name of the class with an "underscore" inserted before all upper case characters and all characters converted to lower case.
 java.lang.String getSourceName()
          Returns the name of the class for use in source codes.
 SgClass getSuperClass()
          Returns the super class.
 boolean isInterface()
          Returns if this is an interface.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VOID

public static final SgClass VOID
Simple "void" type.


BOOLEAN

public static final SgClass BOOLEAN
Simple "boolean" type.


BYTE

public static final SgClass BYTE
Simple "byte" type.


CHAR

public static final SgClass CHAR
Simple "char" type.


SHORT

public static final SgClass SHORT
Simple "short" type.


INT

public static final SgClass INT
Simple "int" type.


LONG

public static final SgClass LONG
Simple "long" type.


FLOAT

public static final SgClass FLOAT
Simple "float" type.


DOUBLE

public static final SgClass DOUBLE
Simple "double" type.


OBJECT

public static final SgClass OBJECT
Base "Object" type.

Constructor Detail

SgClass

public SgClass(java.lang.String packageName,
               java.lang.String simpleName)
Basic constructor.

Parameters:
packageName - Name of the package - Cannot be null.
simpleName - Name (without package) of the class - Cannot be null.

SgClass

public SgClass(java.lang.String modifiers,
               java.lang.String packageName,
               java.lang.String simpleName,
               boolean isinterface,
               SgClass enclosingClass)
Constructor without super class.

Parameters:
modifiers - Modifier names separated with space - Cannot be null.
packageName - Name of the package - Cannot be null.
simpleName - Name (without package) of the class - Cannot be null.
isinterface - Is this an interface?
enclosingClass - Enclosing class if this is an inner class - Null is allowed.

SgClass

public SgClass(java.lang.String modifiers,
               java.lang.String packageName,
               java.lang.String simpleName,
               SgClass superClass,
               boolean isinterface,
               SgClass enclosingClass)
Constructor with super class.

Parameters:
modifiers - Modifier names separated with space - Cannot be null.
packageName - Name of the package - Cannot be null.
simpleName - Name (without package) of the class - Cannot be null.
superClass - Super class or null.
isinterface - Is this an interface?
enclosingClass - Enclosing class if this is an inner class - Null is allowed
Method Detail

getSuperClass

public final SgClass getSuperClass()
Returns the super class.

Returns:
Super class or null.

getSimpleNameAsPackage

public final java.lang.String getSimpleNameAsPackage()
Returns the simple name of the class with an "underscore" inserted before all upper case characters and all characters converted to lower case.

Returns:
Name usable as a package - Always non-null.

getConstructors

public final java.util.List<SgConstructor> getConstructors()
Returns a list of constructors.

Returns:
Constructor list - Always non-null and is unmodifiable.

addConstructor

public final void addConstructor(SgConstructor constructor)
Adds a constructor to the class. Does nothing if the constructor is already in the list of constructors. You will never need to use this method in your code! A constructor is added automatically to the owning class when it's constructed!

Parameters:
constructor - Constructor to add - Cannot be null.

isInterface

public final boolean isInterface()
Returns if this is an interface.

Returns:
If it's an interface true else false.

getMethods

public final java.util.List<SgMethod> getMethods()
Returns a list of all methods.

Returns:
Method list - Always non-null and is unmodifiable.

addMethod

public final void addMethod(SgMethod method)
Adds a method to the class. Does nothing if the method is already in the list of methods. You will never need to use this method in your code! A method is added automatically to the owning class when it's constructed!

Parameters:
method - Method to add - Cannot be null.

getName

public final java.lang.String getName()
Returns the name of the class.

Returns:
Name with inner classes separated with "$".

getSourceName

public final java.lang.String getSourceName()
Returns the name of the class for use in source codes.

Returns:
Name with inner classes separated with ".".

getNameAsFilename

public final java.lang.String getNameAsFilename()
Returns the package and name as a filename without extension.

Returns:
Relative path and filename.

getNameAsSrcFilename

public final java.lang.String getNameAsSrcFilename()
Returns the package and name as a source filename.

Returns:
Relative path and filename with extension ".java".

getNameAsBinFilename

public final java.lang.String getNameAsBinFilename()
Returns the package and name as a class filename.

Returns:
Relative path and filename with extension ".class".

getPackageName

public final java.lang.String getPackageName()
Returns the package of the class.

Returns:
Package name.

getSimpleName

public final java.lang.String getSimpleName()
Returns the simple name of the class.

Returns:
Name without package.

getInterfaces

public final java.util.List<SgClass> getInterfaces()
Returns a list of all interfaces.

Returns:
List of interfaces - Always non-null and unmodifiable.

addInterface

public final void addInterface(SgClass intf)
Add an interface to the class.

Parameters:
intf - Interface to add - Cannot be null.

getInterfacesCommaSeparated

public final java.lang.String getInterfacesCommaSeparated()
Returns all (fully qualified) interface names.

Returns:
Names separated by a comma - Always non-null.

getFields

public final java.util.List<SgField> getFields()
Returns a list of all fields.

Returns:
List of fields - Always non-null and is unmodifiable

addField

public final void addField(SgField field)
Adds a field to the class. Does nothing if the field is already in the list of fields. You will never need to use this method in your code! A field is added automatically to the owning class when it's constructed!

Parameters:
field - Field to add - Cannot be null.

getClasses

public final java.util.List<SgClass> getClasses()
Returns a list of all inner class.

Returns:
List of inner classes - Always non-null and is unmodifiable.

addClass

public final void addClass(SgClass clasz)
Adds an inner to this class. Does nothing if the class is already in the list of inner classes.

Parameters:
clasz - Inner class to add - Cannot be null.

getEnclosingClass

public final SgClass getEnclosingClass()
Returns the enclosing class.

Returns:
Enclosing class or null.

findClassByName

public final SgClass findClassByName(java.lang.String name)
Find an inner class by it's name.

Parameters:
name - Full qualified name of the class to find - Cannot be null.
Returns:
Class or null if it's not found.

findMethodByName

public final SgMethod findMethodByName(java.lang.String name)
Find a method by it's name.

Parameters:
name - Name of the method to find - Cannot be null.
Returns:
Method or null if it's not found.

findFieldByName

public final SgField findFieldByName(java.lang.String name)
Find a field by it's name.

Parameters:
name - Name of the field to find - Cannot be null.
Returns:
Field or null if it's not found.

toString

public final java.lang.String toString()

Overrides:
toString in class java.lang.Object

create

public static SgClass create(SgClassPool pool,
                             java.lang.String className)
Creates a model class by loading the "real" class with Class.forName(..) and analyzing it. Throws an IllegalArgumentException if the class cannot be constructed with "forName".

Parameters:
pool - Pool to use.
className - Full qualified name.
Returns:
Class.

create

public static SgClass create(SgClassPool pool,
                             java.lang.Class clasz)
Creates a model class by analyzing the "real" class.

Parameters:
pool - Pool to use.
clasz - Class to analyze.
Returns:
Class.

getModifiers

public final java.lang.String getModifiers()
Returns the modifiers as text.

Returns:
Modifier names.


Copyright © 2010 Future Invent Informationsmanagement GmbH. All Rights Reserved.