Class IOJavaClassWriter
java.lang.Object
com.sun.jdo.spi.persistence.utility.generator.io.IOJavaClassWriter
- All Implemented Interfaces:
JavaClassWriter
This implementation of the
JavaClassWriter interface is based on
simple StringBuffer "println" type statements.
The order of the generated code in this implementation depends on the initialization. The default order is to accept fields and methods in any order and generate all fields together and all methods together (by member category). Specifying the ordered parameter in the constructor will lead to a slightly different order: generation of fields and methods interspersed among each other in exactly the order they were added (no member categories).
- Author:
- raccah
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of IOJavaClassWriter which maintains the order of member input but groups them by category.IOJavaClassWriter(boolean maintainCategories) Creates a new instance of IOJavaClassWriter in which the order of the generated code depends on the specified flag. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddClass(JavaClassWriter classWriter) Adds an inner class to this class.voidaddConstructor(String name, int modifiers, String[] parameterNames, String[] parameterTypes, String[] exceptions, String[] body, String[] comments) Adds a constructor to this class.voidAdds a field to the list of those declared by this class.voidaddInitializer(boolean isStatic, String[] body, String[] comments) Adds an initializer to this class.voidaddInterface(String name) Adds an interface to the list of those implemented by this class.voidaddMethod(String name, int modifiers, String returnType, String[] parameterNames, String[] parameterTypes, String[] exceptions, String[] body, String[] comments) Adds a method to this class.voidsetClassDeclaration(int modifiers, String className, String[] comments) Sets the information for the class declaration including modifiers, name, and comments.voidsetSuperclass(String name) Sets the superclass of this class.toString()Returns a string representation of this object.
-
Constructor Details
-
IOJavaClassWriter
public IOJavaClassWriter()Creates a new instance of IOJavaClassWriter which maintains the order of member input but groups them by category.- See Also:
-
IOJavaClassWriter
public IOJavaClassWriter(boolean maintainCategories) Creates a new instance of IOJavaClassWriter in which the order of the generated code depends on the specified flag.- Parameters:
maintainCategories- Iftrue, the order of members is preserved within category groups. Iffalse, the generation of fields and methods will be interspersed among each other in exactly the order they were added with no member categories.
-
-
Method Details
-
setClassDeclaration
Sets the information for the class declaration including modifiers, name, and comments. Note that the name must not be fully qualified.- Specified by:
setClassDeclarationin interfaceJavaClassWriter- Parameters:
modifiers- The modifier flags for this class.className- The (non-qualified) name of this class.comments- The comments shown just above the class declaration. The comments are passed as an array so the line separators can be added by the implementation. Note that not all implementations will choose to make use of this comment.- See Also:
-
setSuperclass
Sets the superclass of this class. Note that the name format must be package style (that is - it can contain . but not / or $).- Specified by:
setSuperclassin interfaceJavaClassWriter- Parameters:
name- The name of the superclass.
-
addInterface
Adds an interface to the list of those implemented by this class.- Specified by:
addInterfacein interfaceJavaClassWriter- Parameters:
name- The name of the interface.
-
addField
public void addField(String name, int modifiers, String type, String initialValue, String[] comments) Adds a field to the list of those declared by this class. Note that the type format must be package style (that is - it can contain . but not / or $).- Specified by:
addFieldin interfaceJavaClassWriter- Parameters:
name- The name of the field.modifiers- The modifier flags for this field.type- A string representing the type of this field.initialValue- A string representing the initial value of this field.comments- The comments shown just above the declaration of this field. The comments are passed as an array so the line separators can be added by the implementation. Note that not all implementations will choose to make use of this comment.- See Also:
-
addInitializer
Adds an initializer to this class.- Specified by:
addInitializerin interfaceJavaClassWriter- Parameters:
isStatic- True if this is a static initializer, false otherwise.body- The implementation block of the initializer. The body of the implementation is passed as an array so the line separators can be added by the implementation.comments- The comments shown just above the initializer block. The comments are passed as an array so the line separators can be added by the implementation. Note that not all implementations will choose to make use of this comment.
-
addConstructor
public void addConstructor(String name, int modifiers, String[] parameterNames, String[] parameterTypes, String[] exceptions, String[] body, String[] comments) Adds a constructor to this class. Note that the type format in the parameter type strings must be package style (that is - it can contain . but not / or $).- Specified by:
addConstructorin interfaceJavaClassWriter- Parameters:
name- The name of the constructor - should be the same as the name of the class.modifiers- The modifier flags for this constructor.parameterNames- A list of parameter names.parameterTypes- A list of parameter types.exceptions- A list of exceptions.body- The implementation block of the constructor. The body of the implementation is passed as an array so the line separators can be added by the implementation.comments- The comments shown just above the constructor. The comments are passed as an array so the line separators can be added by the implementation. Note that not all implementations will choose to make use of this comment.- See Also:
-
addMethod
public void addMethod(String name, int modifiers, String returnType, String[] parameterNames, String[] parameterTypes, String[] exceptions, String[] body, String[] comments) Adds a method to this class. Note that the type format in the return type and parameter type strings must be package style (that is - it can contain . but not / or $).- Specified by:
addMethodin interfaceJavaClassWriter- Parameters:
name- The name of the method.modifiers- The modifier flags for this method.returnType- A string representing the return type of this method.parameterNames- A list of parameter names.parameterTypes- A list of parameter types.exceptions- A list of exceptions.body- The implementation block of the method. The body of the implementation is passed as an array so the line separators can be added by the implementation.comments- The comments shown just above the method. The comments are passed as an array so the line separators can be added by the implementation. Note that not all implementations will choose to make use of this comment.- See Also:
-
addClass
Adds an inner class to this class.- Specified by:
addClassin interfaceJavaClassWriter- Parameters:
classWriter- The definition of the inner class.
-
toString
Returns a string representation of this object.
-