de.ispsoft.jaxme.generator.javasource
Class JavaSource

java.lang.Object
  extended byde.ispsoft.jaxme.generator.javasource.JavaSource
Direct Known Subclasses:
JavaInnerClass

public class JavaSource
extends java.lang.Object

A class representing a Java source file.

Author:
Jochen Wiedmann

Constructor Summary
JavaSource(java.lang.String pPackage, java.lang.String pName)
          Creates a new instance of JavaSource with default protection.
JavaSource(java.lang.String pPackage, java.lang.String pName, java.lang.String pProtection)
          Creates a new instance of JavaSource with the given protection.
 
Method Summary
 void addConstructor(JavaConstructor c)
          Adds a constructor to this classes list of constructors.
 void addField(JavaField f)
          Adds a field to this classes list of fields.
 void addImplements(java.lang.String s)
          Adds an interface to the list of interfaces being implemented by this class or interface.
 void addImport(java.lang.String s)
          Adds a package or class to the list of packages and classes being imported.
 void addInnerClass(JavaInnerClass pClass)
          Adds an inner class.
 void addMethod(JavaMethod m)
          Adds a method to this classes list of methods.
 void addRawJavaSource(java.lang.String pSource)
          Adds a piece of raw Java source to the class.
 void clearInnerClasses()
          Clears the list of inner classes.
 void clearRawJavaSources()
          Clears the list of raw Java sources.
 JavaComment getComment()
          Returns the comment describing this class or interface.
 java.util.ArrayList getConstructors()
          Returns the list of constructors that this class has.
 java.lang.String getExtends()
          Returns the class or interface extended by this class or interface.
 java.util.ArrayList getFields()
          Returns the list of fields that this class has.
 java.util.ArrayList getImplements()
          Returns the list of interfaces being implented by this class or interface.
 java.util.ArrayList getImport()
          Returns the list of packages and classes being imported.
 JavaInnerClass[] getInnerClasses()
          Returns the array of inner classes.
 java.util.ArrayList getMethods()
          Returns the list of methods that this class has.
 java.lang.String getName()
          Returns the class or interface name.
 java.lang.String getPackage()
          Returns the package name; null indicates the root package.
 java.lang.String getProtection()
          Returns the protection; null for default protection.
 java.lang.String getQName()
          Returns the qualified class name, including the package name.
static java.lang.String getQuoted(java.lang.String s)
          Returns a quoted string constant suitable for embedding into Java source.
static java.lang.String getQuotedNoQuotes(java.lang.String s)
          Returns a quoted string constant suitable for embedding into Java source, but without quotes.
 java.lang.String[] getRawJavaSources()
          Returns an array with the pieces of raw Java sources.
protected  boolean getStatic()
          Returns whether this JavaSource is static (for inner classes).
 java.lang.String getType()
          Returns the JavaSource type.
 boolean isAbstract()
          Returns whether class is abstract.
 void setAbstract(boolean isAbstract)
          Sets whether this class is abstract,
 void setComment(JavaComment comment)
          Sets the comment describing this class or interface.
 void setExtends(java.lang.String pExtends)
          Sets the class or interface extended by this class or interface.
 void setName(java.lang.String name)
          Sets the class or interface name.
 void setPackage(java.lang.String pPackage)
          Sets the package name; null or empty string indicate the root package.
 void setProtection(java.lang.String protection)
          Sets the protection; use null for default protection.
 void setStatic(boolean pStatic)
          Sets whether this JavaSource is static (for inner classes).
 void setType(java.lang.String type)
          Sets the JavaSource type.
 java.lang.String toString()
          Returns a string representation of this JavaSource file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JavaSource

public JavaSource(java.lang.String pPackage,
                  java.lang.String pName)
Creates a new instance of JavaSource with default protection.

Parameters:
pPackage - The package name; null or empty string indicates the root package
pName - The class or interface name

JavaSource

public JavaSource(java.lang.String pPackage,
                  java.lang.String pName,
                  java.lang.String pProtection)

Creates a new instance of JavaSource with the given protection.

Parameters:
pPackage - The package name; null or empty string indicates the root package
pName - The class or interface name
pProtection - null, "public", "protected" or "private"
Method Detail

getName

public java.lang.String getName()

Returns the class or interface name.

See Also:
setName(java.lang.String)

setName

public void setName(java.lang.String name)

Sets the class or interface name.

See Also:
getName()

getProtection

public java.lang.String getProtection()

Returns the protection; null for default protection.

See Also:
setProtection(java.lang.String)

setProtection

public void setProtection(java.lang.String protection)

Sets the protection; use null for default protection.

See Also:
getProtection()

getPackage

public java.lang.String getPackage()

Returns the package name; null indicates the root package.

See Also:
setPackage(java.lang.String)

setPackage

public void setPackage(java.lang.String pPackage)

Sets the package name; null or empty string indicate the root package.

See Also:
getPackage()

getQName

public java.lang.String getQName()

Returns the qualified class name, including the package name.


getType

public java.lang.String getType()

Returns the JavaSource type.

Returns:
"class" or "interface"
See Also:
setType(java.lang.String)

setType

public void setType(java.lang.String type)

Sets the JavaSource type.

Parameters:
type - "class" or "interface"
See Also:
getType()

getComment

public JavaComment getComment()

Returns the comment describing this class or interface.

See Also:
setComment(de.ispsoft.jaxme.generator.javasource.JavaComment)

setComment

public void setComment(JavaComment comment)

Sets the comment describing this class or interface.

See Also:
getComment()

getExtends

public java.lang.String getExtends()

Returns the class or interface extended by this class or interface.

See Also:
setExtends(java.lang.String)

setExtends

public void setExtends(java.lang.String pExtends)

Sets the class or interface extended by this class or interface. Null or the empty string disable the "extends" clause.

See Also:
getExtends()

getImport

public java.util.ArrayList getImport()

Returns the list of packages and classes being imported.

See Also:
addImport(java.lang.String)

addImport

public void addImport(java.lang.String s)

Adds a package or class to the list of packages and classes being imported.

See Also:
addImport(java.lang.String)

getImplements

public java.util.ArrayList getImplements()

Returns the list of interfaces being implented by this class or interface.

See Also:
addImplements(java.lang.String)

addImplements

public void addImplements(java.lang.String s)

Adds an interface to the list of interfaces being implemented by this class or interface.

See Also:
getImplements()

getFields

public java.util.ArrayList getFields()

Returns the list of fields that this class has.

See Also:
addField(de.ispsoft.jaxme.generator.javasource.JavaField)

addField

public void addField(JavaField f)

Adds a field to this classes list of fields.

See Also:
getFields()

getConstructors

public java.util.ArrayList getConstructors()

Returns the list of constructors that this class has.

See Also:
addConstructor(de.ispsoft.jaxme.generator.javasource.JavaConstructor)

addConstructor

public void addConstructor(JavaConstructor c)

Adds a constructor to this classes list of constructors.

See Also:
getConstructors()

getMethods

public java.util.ArrayList getMethods()

Returns the list of methods that this class has.

See Also:
addMethod(de.ispsoft.jaxme.generator.javasource.JavaMethod)

addMethod

public void addMethod(JavaMethod m)

Adds a method to this classes list of methods.

See Also:
getMethods()

toString

public java.lang.String toString()

Returns a string representation of this JavaSource file.


getQuotedNoQuotes

public static java.lang.String getQuotedNoQuotes(java.lang.String s)

Returns a quoted string constant suitable for embedding into Java source, but without quotes.


getQuoted

public static java.lang.String getQuoted(java.lang.String s)

Returns a quoted string constant suitable for embedding into Java source.


addInnerClass

public void addInnerClass(JavaInnerClass pClass)

Adds an inner class.


clearInnerClasses

public void clearInnerClasses()

Clears the list of inner classes.


getInnerClasses

public JavaInnerClass[] getInnerClasses()

Returns the array of inner classes.


getStatic

protected boolean getStatic()

Returns whether this JavaSource is static (for inner classes).


setStatic

public void setStatic(boolean pStatic)

Sets whether this JavaSource is static (for inner classes).


addRawJavaSource

public void addRawJavaSource(java.lang.String pSource)

Adds a piece of raw Java source to the class.


clearRawJavaSources

public void clearRawJavaSources()

Clears the list of raw Java sources.


getRawJavaSources

public java.lang.String[] getRawJavaSources()

Returns an array with the pieces of raw Java sources.


isAbstract

public boolean isAbstract()

Returns whether class is abstract.


setAbstract

public void setAbstract(boolean isAbstract)

Sets whether this class is abstract,