de.enough.polish.sourceparser
Class JavaSourceClass

java.lang.Object
  extended by de.enough.polish.sourceparser.JavaSourceClass

public class JavaSourceClass
extends Object

Parses Java source code and provides reflection-like information about it.

Copyright Enough Software 2006

 history
        Dec 28, 2006 - rob creation
 

Author:
Robert Virkus, j2mepolish@enough.de

Field Summary
protected static Pattern CLASSNAME_PATTERN
           
protected static String CLASSNAME_STR
           
protected static Pattern EXTENDS_PATTERN
           
protected static String EXTENDS_STR
           
protected static Pattern IMPLEMENTS_PATTERN
           
protected static String IMPLEMENTS_STR
           
protected static Pattern IMPORT_PATTERN
           
protected static String IMPORT_STR
           
protected static String JAVA_VAR_STR
           
protected static Pattern METHOD_PATTERN
           
protected static String METHOD_STR
           
protected static Pattern PACKAGE_PATTERN
           
protected static String PACKAGE_STR
           
 
Constructor Summary
JavaSourceClass(String[] lines)
          Creates a new Java source file.
 
Method Summary
 void addImport(String importStatement)
           
 void addMethod(JavaSourceMethod method)
           
 String getClassName()
           
 String getExtendsStatement()
           
 String[] getImplementedInterfaces()
           
 String[] getImportStatements()
           
 JavaSourceMethod[] getMethods()
           
 String getPackageName()
           
 boolean isClass()
           
 void parse(String[] lines)
          Parses the given Java source code.
static String[] removeComments(String[] lines)
          Removes any Java comments from the given source code.
 String[] renderCode()
           
 void setClass(boolean isClass)
           
 void setClassName(String className)
           
 void setExtendsStatement(String extendsStatement)
           
 void setImplementedInterfaces(String[] implementedInterfaces)
           
 void setImportStatements(String[] importStatements)
           
 void setMethods(JavaSourceMethod[] methods)
           
 void setPackageName(String packageName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAVA_VAR_STR

protected static final String JAVA_VAR_STR
See Also:
Constant Field Values

PACKAGE_STR

protected static final String PACKAGE_STR
See Also:
Constant Field Values

PACKAGE_PATTERN

protected static final Pattern PACKAGE_PATTERN

IMPORT_STR

protected static final String IMPORT_STR
See Also:
Constant Field Values

IMPORT_PATTERN

protected static final Pattern IMPORT_PATTERN

CLASSNAME_STR

protected static final String CLASSNAME_STR
See Also:
Constant Field Values

CLASSNAME_PATTERN

protected static final Pattern CLASSNAME_PATTERN

EXTENDS_STR

protected static final String EXTENDS_STR
See Also:
Constant Field Values

EXTENDS_PATTERN

protected static final Pattern EXTENDS_PATTERN

IMPLEMENTS_STR

protected static final String IMPLEMENTS_STR
See Also:
Constant Field Values

IMPLEMENTS_PATTERN

protected static final Pattern IMPLEMENTS_PATTERN

METHOD_STR

protected static final String METHOD_STR
See Also:
Constant Field Values

METHOD_PATTERN

protected static final Pattern METHOD_PATTERN
Constructor Detail

JavaSourceClass

public JavaSourceClass(String[] lines)
Creates a new Java source file.

Parameters:
lines - the source code
Method Detail

parse

public void parse(String[] lines)
Parses the given Java source code.

Parameters:
lines - the source code

removeComments

public static String[] removeComments(String[] lines)
Removes any Java comments from the given source code.

Parameters:
lines - the original source code
Returns:
the source code without any comments and empty lines and blank space removed

getClassName

public String getClassName()
Returns:
the className

getImportStatements

public String[] getImportStatements()
Returns:
the importStatements

isClass

public boolean isClass()
Returns:
the isClass

getPackageName

public String getPackageName()
Returns:
the packageName

getExtendsStatement

public String getExtendsStatement()
Returns:
the extendsStatement

getImplementedInterfaces

public String[] getImplementedInterfaces()
Returns:
the implementedInterfaces

getMethods

public JavaSourceMethod[] getMethods()
Returns:
the methods

setMethods

public void setMethods(JavaSourceMethod[] methods)
Parameters:
methods - the methods to set

setClassName

public void setClassName(String className)
Parameters:
className - the className to set

setExtendsStatement

public void setExtendsStatement(String extendsStatement)
Parameters:
extendsStatement - the extendsStatement to set

setImplementedInterfaces

public void setImplementedInterfaces(String[] implementedInterfaces)
Parameters:
implementedInterfaces - the implementedInterfaces to set

setImportStatements

public void setImportStatements(String[] importStatements)
Parameters:
importStatements - the importStatements to set

setClass

public void setClass(boolean isClass)
Parameters:
isClass - the isClass to set

setPackageName

public void setPackageName(String packageName)
Parameters:
packageName - the packageName to set

renderCode

public String[] renderCode()

addImport

public void addImport(String importStatement)

addMethod

public void addMethod(JavaSourceMethod method)