Arch4J 1.1

org.arch4j.generator
Class JavaClassDefinition

java.lang.Object
  |
  +--org.arch4j.generator.JavaDefinition
        |
        +--org.arch4j.generator.JavaObjectDefinition
              |
              +--org.arch4j.generator.JavaClassDefinition
All Implemented Interfaces:
JavaKeywordConstants, JavaPrimitiveConstants

public class JavaClassDefinition
extends JavaObjectDefinition

This class is used to define the attributes of a Java class. The attributes can then be used to generate a valid Java class definition string.

The number of constructors are meant to make it easy to define a class with as few statements as possible. Once constructed, additional methods can be sent to further define the class.

Version:
1.0
Author:
Ross E. Greinke

Field Summary
protected  boolean isAbstract
          Is the class abstract? Default = false.
protected  boolean isFinal
          Is the class final? Default = false.
protected  JavaType superClassName
          The superclass, defined as a Java type.
 
Fields inherited from class org.arch4j.generator.JavaObjectDefinition
implementedInterfaces, isStrict, objectName
 
Fields inherited from class org.arch4j.generator.JavaDefinition
accessModifier, comment
 
Fields inherited from interface org.arch4j.generator.JavaKeywordConstants
ABSTRACT, CATCH, CLASS, DEFAULT_ACCESS, EXTENDS, FALSE, FINAL, FINALLY, IMPLEMENTS, IMPORT, INTERFACE, NATIVE, NEW, NULL, PACKAGE, PRIVATE, PROTECTED, PUBLIC, RETURN, STATIC, STRICTFP, SUPER, SYNCHRONIZED, THIS, THROW, THROWS, TRANSIENT, TRUE, TRY, VOID, VOLATILE
 
Fields inherited from interface org.arch4j.generator.JavaPrimitiveConstants
BOOLEAN, BYTE, CHAR, DOUBLE, FLOAT, INT, LONG, SHORT
 
Constructor Summary
JavaClassDefinition(JavaType className)
          Constructs a JavaClassDefinition with the specified Java class type.
JavaClassDefinition(JavaType className, JavaType superClassName)
          Constructs a JavaClassDefinition with the specified Java class type and superclass type.
JavaClassDefinition(JavaType className, JavaType superClassName, List implementedInterfaces)
          Constructs a JavaClassDefinition with the specified Java class type, superclass type, and list of implemented interfaces.
JavaClassDefinition(JavaType className, List implementedInterfaces)
          Constructs a JavaClassDefinition with the specified Java class type, and list of implemented interfaces.
JavaClassDefinition(String className)
          Constructs a JavaClassDefinition with the specified class name.
JavaClassDefinition(String comment, JavaAccessModifier accessModifier, boolean isAbstract, boolean isFinal, boolean isStrict, JavaType className, JavaType superClassName, List implementedInterfaces)
          Constructs a JavaClassDefinition with the specified comment, access control modifier, Java class type, superclass type, list of implemented interfaces, whether the class is abstract or final, and whether the object needs strictfp floating-point calculations.
JavaClassDefinition(String comment, JavaAccessModifier accessModifier, boolean isAbstract, boolean isFinal, JavaType className, JavaType superClassName, List implementedInterfaces)
          Constructs a JavaClassDefinition with the specified comment, access control modifier, Java class type, superclass type, list of implemented interfaces, and whether the class is abstract or final.
JavaClassDefinition(String comment, JavaAccessModifier accessModifier, JavaType className)
          Constructs a JavaClassDefinition with the specified comment, access control modifier, and Java class type.
JavaClassDefinition(String comment, JavaAccessModifier accessModifier, JavaType className, JavaType superClassName)
          Constructs a JavaClassDefinition with the specified comment, access control modifier, Java class type, and superclass type.
JavaClassDefinition(String comment, JavaAccessModifier accessModifier, JavaType className, JavaType superClassName, List implementedInterfaces)
          Constructs a JavaClassDefinition with the specified comment, access control modifier, Java class type, superclass type, and list of implemented interfaces.
JavaClassDefinition(String className, List implementedInterfaces)
          Constructs a JavaClassDefinition with the specified class name, and list of implemented interfaces.
JavaClassDefinition(String className, String superClassName)
          Constructs a JavaClassDefinition with the specified class name and superclass name.
JavaClassDefinition(String comment, String accessModifier, boolean isAbstract, boolean isFinal, boolean isStrict, String className, String superClassName, List implementedInterfaces)
          Constructs a JavaClassDefinition with the specified comment, access control modifier, class name, superclass name, list of implemented interfaces, whether the class is abstract or final, and whether the object needs strictfp floating-point calculations.
JavaClassDefinition(String comment, String accessModifier, boolean isAbstract, boolean isFinal, String className, String superClassName, List implementedInterfaces)
          Constructs a JavaClassDefinition with the specified comment, access control modifier, class name, superclass name, list of implemented interfaces, and whether the class is abstract or final.
JavaClassDefinition(String className, String superClassName, List implementedInterfaces)
          Constructs a JavaClassDefinition with the specified class name, superclass name, and list of implemented interfaces.
JavaClassDefinition(String comment, String accessModifier, String className)
          Constructs a JavaClassDefinition with the specified comment, access control modifier, and class name.
JavaClassDefinition(String comment, String accessModifier, String className, String superClassName)
          Constructs a JavaClassDefinition with the specified comment, access control modifier, class name, and superclass name.
JavaClassDefinition(String comment, String accessModifier, String className, String superClassName, List implementedInterfaces)
          Constructs a JavaClassDefinition with the specified comment, access control modifier, class name, superclass name, and list of implemented interfaces.
 
Method Summary
 List getImports()
          Returns a list of potential import types for the object.
 String getName()
          Returns the name of this class.
 String getObjectKeyword()
          Returns the object keyword for the object.
 String getPackageName()
          Returns the package within which this class is defined.
 JavaType getSuperClass()
          Returns the Java type that represents the class that this class extends.
 String getSuperClassName()
          Returns the name of the class that this class extends.
 boolean isAbstract()
          Returns whether the object is abstract or not.
 boolean isClassDefinition()
          Returns that this class is a class definition.
 boolean isFinal()
          Returns whether the object is final or not.
 void setAbstract(boolean value)
          Set whether the object is abstract or not.
 void setFinal(boolean value)
          Set whether the object is final or not.
 void writeDefinitionTo(CodeBuffer buffer)
          Write the Java source representation of the definition to the CodeBuffer.
 
Methods inherited from class org.arch4j.generator.JavaObjectDefinition
addImplementedInterface, addImplementedInterface, addImplementedInterfaces, getImplementedInterfaces, getObjectName, isInterfaceDefinition, isStrict, setImplementedInterfaces, setStrict
 
Methods inherited from class org.arch4j.generator.JavaDefinition
getAccessModifier, getComment, getDefinition, hasComment, setAccessModifier, setComment
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isAbstract

protected boolean isAbstract
Is the class abstract? Default = false.


isFinal

protected boolean isFinal
Is the class final? Default = false.


superClassName

protected JavaType superClassName
The superclass, defined as a Java type.

Constructor Detail

JavaClassDefinition

public JavaClassDefinition(String className)
Constructs a JavaClassDefinition with the specified class name. The access control modifier defaults to public access.

Parameters:
className - The class name.

JavaClassDefinition

public JavaClassDefinition(JavaType className)
Constructs a JavaClassDefinition with the specified Java class type. The access control modifier defaults to public access.

Parameters:
className - The class's Java type specification.

JavaClassDefinition

public JavaClassDefinition(String className,
                           String superClassName)
Constructs a JavaClassDefinition with the specified class name and superclass name. The access control modifier defaults to public access.

Parameters:
className - The class name.
superClassName - The superclass name.

JavaClassDefinition

public JavaClassDefinition(JavaType className,
                           JavaType superClassName)
Constructs a JavaClassDefinition with the specified Java class type and superclass type. The access control modifier defaults to public access.

Parameters:
className - The class's Java type specification.
superClassName - The superclass Java type specification.

JavaClassDefinition

public JavaClassDefinition(String className,
                           List implementedInterfaces)
Constructs a JavaClassDefinition with the specified class name, and list of implemented interfaces. The list should contain JavaType objects representing each interface that this class implements. Strings will be converted, though, if it is more convenient to use Strings. The access control modifier defaults to public access.

Parameters:
className - The class name.
implementedInterfaces - The list of implemented interfaces.

JavaClassDefinition

public JavaClassDefinition(JavaType className,
                           List implementedInterfaces)
Constructs a JavaClassDefinition with the specified Java class type, and list of implemented interfaces. The list should contain JavaType objects representing each interface that this class implements. Strings will be converted, though, if it is more convenient to use Strings. The access control modifier defaults to public access.

Parameters:
className - The class's Java type specification.
implementedInterfaces - The list of implemented interfaces.

JavaClassDefinition

public JavaClassDefinition(String className,
                           String superClassName,
                           List implementedInterfaces)
Constructs a JavaClassDefinition with the specified class name, superclass name, and list of implemented interfaces. The list should contain JavaType objects representing each interface that this class implements. Strings will be converted, though, if it is more convenient to use Strings. The access control modifier defaults to public access.

Parameters:
className - The class name.
superClassName - The superclass name.
implementedInterfaces - The list of implemented interfaces.

JavaClassDefinition

public JavaClassDefinition(JavaType className,
                           JavaType superClassName,
                           List implementedInterfaces)
Constructs a JavaClassDefinition with the specified Java class type, superclass type, and list of implemented interfaces. The list should contain JavaType objects representing each interface that this class implements. Strings will be converted, though, if it is more convenient to use Strings. The access control modifier defaults to public access.

Parameters:
className - The class's Java type specification.
superClassName - The superclass Java type specification.
implementedInterfaces - The list of implemented interfaces.

JavaClassDefinition

public JavaClassDefinition(String comment,
                           String accessModifier,
                           String className)
Constructs a JavaClassDefinition with the specified comment, access control modifier, and class name.

Parameters:
comment - The class's descriptive comment.
accessModifier - The class's access control modifier.
className - The class name.

JavaClassDefinition

public JavaClassDefinition(String comment,
                           JavaAccessModifier accessModifier,
                           JavaType className)
Constructs a JavaClassDefinition with the specified comment, access control modifier, and Java class type.

Parameters:
comment - The class's descriptive comment.
accessModifier - The class's access control modifier.
className - The class's Java type specification.

JavaClassDefinition

public JavaClassDefinition(String comment,
                           String accessModifier,
                           String className,
                           String superClassName)
Constructs a JavaClassDefinition with the specified comment, access control modifier, class name, and superclass name.

Parameters:
comment - The class's descriptive comment.
accessModifier - The class's access control modifier.
className - The class name.
superClassName - The superclass name.

JavaClassDefinition

public JavaClassDefinition(String comment,
                           JavaAccessModifier accessModifier,
                           JavaType className,
                           JavaType superClassName)
Constructs a JavaClassDefinition with the specified comment, access control modifier, Java class type, and superclass type.

Parameters:
comment - The class's descriptive comment.
accessModifier - The class's access control modifier.
className - The class's Java type specification.
superClassName - The superclass Java type specification.

JavaClassDefinition

public JavaClassDefinition(String comment,
                           String accessModifier,
                           String className,
                           String superClassName,
                           List implementedInterfaces)
Constructs a JavaClassDefinition with the specified comment, access control modifier, class name, superclass name, and list of implemented interfaces. The list should contain JavaType objects representing each interface that this class implements. Strings will be converted, though, if it is more convenient to use Strings.

Parameters:
comment - The class's descriptive comment.
accessModifier - The class's access control modifier.
className - The class name.
superClassName - The superclass name.
implementedInterfaces - The list of implemented interfaces.

JavaClassDefinition

public JavaClassDefinition(String comment,
                           JavaAccessModifier accessModifier,
                           JavaType className,
                           JavaType superClassName,
                           List implementedInterfaces)
Constructs a JavaClassDefinition with the specified comment, access control modifier, Java class type, superclass type, and list of implemented interfaces. The list should contain JavaType objects representing each interface that this class implements. Strings will be converted, though, if it is more convenient to use Strings.

Parameters:
comment - The class's descriptive comment.
accessModifier - The class's access control modifier.
className - The class's Java type specification.
superClassName - The superclass Java type specification.
implementedInterfaces - The list of implemented interfaces.

JavaClassDefinition

public JavaClassDefinition(String comment,
                           String accessModifier,
                           boolean isAbstract,
                           boolean isFinal,
                           String className,
                           String superClassName,
                           List implementedInterfaces)
Constructs a JavaClassDefinition with the specified comment, access control modifier, class name, superclass name, list of implemented interfaces, and whether the class is abstract or final. A class cannot be both abstract and final, so if both are specified as true, the class will be declared abstract. The list should contain JavaType objects representing each interface that this class implements. Strings will be converted, though, if it is more convenient to use Strings.

Parameters:
comment - The class's descriptive comment.
accessModifier - The class's access control modifier.
isAbstract - true if the class is defined to be abstract.
isFinal - true if the class is defined to be final.
className - The class name.
superClassName - The superclass name.
implementedInterfaces - The list of implemented interfaces.

JavaClassDefinition

public JavaClassDefinition(String comment,
                           JavaAccessModifier accessModifier,
                           boolean isAbstract,
                           boolean isFinal,
                           JavaType className,
                           JavaType superClassName,
                           List implementedInterfaces)
Constructs a JavaClassDefinition with the specified comment, access control modifier, Java class type, superclass type, list of implemented interfaces, and whether the class is abstract or final. A class cannot be both abstract and final, so if both are specified as true, the class will be declared abstract. The list should contain JavaType objects representing each interface that this class implements. Strings will be converted, though, if it is more convenient to use Strings.

Parameters:
comment - The class's descriptive comment.
accessModifier - The class's access control modifier.
isAbstract - true if the class is defined to be abstract.
isFinal - true if the class is defined to be final.
className - The class's Java type specification.
superClassName - The superclass Java type specification.
implementedInterfaces - The list of implemented interfaces.

JavaClassDefinition

public JavaClassDefinition(String comment,
                           String accessModifier,
                           boolean isAbstract,
                           boolean isFinal,
                           boolean isStrict,
                           String className,
                           String superClassName,
                           List implementedInterfaces)
Constructs a JavaClassDefinition with the specified comment, access control modifier, class name, superclass name, list of implemented interfaces, whether the class is abstract or final, and whether the object needs strictfp floating-point calculations. A class cannot be both abstract and final, so if both are specified as true, the class will be declared abstract. The list should contain JavaType objects representing each interface that this class implements. Strings will be converted, though, if it is more convenient to use Strings.

Parameters:
comment - The class's descriptive comment.
accessModifier - The class's access control modifier.
isAbstract - true if the class is defined to be abstract.
isFinal - true if the class is defined to be final.
className - The class name.
superClassName - The superclass name.
implementedInterfaces - The list of implemented interfaces.

JavaClassDefinition

public JavaClassDefinition(String comment,
                           JavaAccessModifier accessModifier,
                           boolean isAbstract,
                           boolean isFinal,
                           boolean isStrict,
                           JavaType className,
                           JavaType superClassName,
                           List implementedInterfaces)
Constructs a JavaClassDefinition with the specified comment, access control modifier, Java class type, superclass type, list of implemented interfaces, whether the class is abstract or final, and whether the object needs strictfp floating-point calculations. A class cannot be both abstract and final, so if both are specified as true, the class will be declared abstract. The list should contain JavaType objects representing each interface that this class implements. Strings will be converted, though, if it is more convenient to use Strings.

Parameters:
comment - The class's descriptive comment.
accessModifier - The class's access control modifier.
isAbstract - true if the class is defined to be abstract.
isFinal - true if the class is defined to be final.
className - The class's Java type specification.
superClassName - The superclass Java type specification.
implementedInterfaces - The list of implemented interfaces.
Method Detail

isAbstract

public boolean isAbstract()
Returns whether the object is abstract or not.

Specified by:
isAbstract in class JavaObjectDefinition
Returns:
true if the object is considered abstract.

setAbstract

public void setAbstract(boolean value)
Set whether the object is abstract or not.

Note: Calling this method with true will set the value for isFinal to false.

Parameters:
value - true for abstract.

isFinal

public boolean isFinal()
Returns whether the object is final or not.

Returns:
true if the object is considered final.

setFinal

public void setFinal(boolean value)
Set whether the object is final or not.

Note: Calling this method with true will set the value for isAbstract to false.

Parameters:
value - true for final.

getPackageName

public String getPackageName()
Returns the package within which this class is defined.

Returns:
The package within which this class is defined.

getName

public String getName()
Returns the name of this class.

Returns:
The name of this class.

getSuperClass

public JavaType getSuperClass()
Returns the Java type that represents the class that this class extends.

Returns:
The Java type that represents the class that this class extends.

getSuperClassName

public String getSuperClassName()
Returns the name of the class that this class extends.

Returns:
The name of the class that this class extends.

isClassDefinition

public boolean isClassDefinition()
Returns that this class is a class definition.

Overrides:
isClassDefinition in class JavaObjectDefinition
Returns:
true; this class is a class definition.

getObjectKeyword

public String getObjectKeyword()
Description copied from class: JavaObjectDefinition
Returns the object keyword for the object.

Specified by:
getObjectKeyword in class JavaObjectDefinition
Returns:
The object keyword for the object.

getImports

public List getImports()
Description copied from class: JavaObjectDefinition
Returns a list of potential import types for the object. It should be a List of JavaType objects.

Overrides:
getImports in class JavaObjectDefinition
Returns:
A list of potential import types for the object.

writeDefinitionTo

public void writeDefinitionTo(CodeBuffer buffer)
Description copied from class: JavaDefinition
Write the Java source representation of the definition to the CodeBuffer.

Specified by:
writeDefinitionTo in class JavaDefinition
Parameters:
buffer - The CodeBuffer with which to append the data.
See Also:
CodeBuffer

Arch4J 1.1

Copyright © 2000-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.