com.sun.jdo.spi.persistence.utility.generator
Class JavaClassWriterHelper

java.lang.Object
  extended by com.sun.jdo.spi.persistence.utility.JavaTypeHelper
      extended by com.sun.jdo.spi.persistence.utility.generator.JavaClassWriterHelper

public class JavaClassWriterHelper
extends JavaTypeHelper


Field Summary
static String boolean_
           
static String brackets_
           
static String byte_
           
static String byteArray_
           
static String Class_
           
static String Collection_
           
static String Date_
           
static String delim_
           
static String dot_
           
static String endLine_
           
static String escapedEmptyString_
           
static String false_
           
static String fileName_
           
static String get_
           
static String Helper_
           
static String home_
           
static String int_
           
static String javaExtension_
           
static String new_
           
static String none_
           
static String null_
           
static String Object_
           
static String Oid_
           
static String param_
           
static String param0_
           
static String paramConcatenator_
           
static String paramInitializer_
           
static String paramList_
           
static String paramSeparator_
           
static String parenleft_
           
static String parenright_
           
static String parenthesis_
           
static String PersistenceCapable_
           
static String returnNull_
           
static String set_
           
static String Set_
           
static String space_
           
static String SqlDate_
           
static String SqlTime_
           
static String SqlTimestamp_
           
static String String_
           
static String[] super_
           
static String true_
           
static String void_
           
 
Constructor Summary
JavaClassWriterHelper()
           
 
Method Summary
static void addFields(String prop, int modifiers, JavaClassWriter writer)
          Adds fields to a class parsing the multi-String property.
static void addGenericMethod(Method m, String mname, String mtype, String body, JavaClassWriter writer)
          Adds a method to a class parsing the multi-String property.
static void addGenericMethod(String mname, int modifiers, String[] body, JavaClassWriter writer)
          Adds a private void no-args method to a class with this method body and modifiers.
static void addGenericMethod(String mname, int modifiers, String type, String[] body, JavaClassWriter writer)
          Adds a private void no-args method to a class with this method body, modifiers, and return type.
static void addGenericMethod(String mname, String[] body, JavaClassWriter writer)
          Adds a private void no-args method to a class with this method body.
static void addGenericMethod(String mname, String type, String[] body, JavaClassWriter writer)
          Adds a private no-args method to a class with this method body and return type.
static void addPrivateField(String prop, int modifiers, JavaClassWriter writer)
          Adds private fields to a class parsing the multi-String property.
static String[] getBodyAsStrings(String body)
          Converts method body into String array.
static String[] getExceptionNames(Method m)
          Returns exception type names as String[].
static String getParametersList(Method m)
          Returns list of method parameters in format param0[, param1[,...]]
static String getParametersListWithSeparator(Method m, String sep)
          Returns list of method parameters delimited by specified separator
static String getParameterTypesList(Method m)
          Returns list of method parameter types in format type0[,type1[,...]]
static String getPrimitiveType(Class cls)
          Returns name of the primitive type corresponding to the Object wrapper Class passed as a parameter.
static String getTypeRepr(Class clazz)
          Returns the String representation of the specified class instance.
static String getUnwrapMethodName(Class primitiveType)
          Returns the name of the method to access the value of the primitive type of the wrapper class.
static String getWrapperExpr(Class exprType, String expr)
          A helper method which generates an expression to wrap a primitive datatype to its corresponding wrapper class.
static Class getWrapperType(Class cls)
          Returns java Object wrapper Class corresponding to the primitive Class if the passed class represents a primitive.
 
Methods inherited from class com.sun.jdo.spi.persistence.utility.JavaTypeHelper
getPackageName, getPrimitiveClass, getPrimitiveName, getShortClassName, getWrapperClass, getWrapperName, valueOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

javaExtension_

public static final String javaExtension_
See Also:
Constant Field Values

void_

public static final String void_
See Also:
Constant Field Values

boolean_

public static final String boolean_
See Also:
Constant Field Values

byte_

public static final String byte_
See Also:
Constant Field Values

byteArray_

public static final String byteArray_
See Also:
Constant Field Values

param_

public static final String param_
See Also:
Constant Field Values

param0_

public static final String param0_
See Also:
Constant Field Values

null_

public static final String null_
See Also:
Constant Field Values

home_

public static final String home_
See Also:
Constant Field Values

delim_

public static final String delim_
See Also:
Constant Field Values

paramInitializer_

public static final String paramInitializer_
See Also:
Constant Field Values

paramSeparator_

public static final String paramSeparator_
See Also:
Constant Field Values

paramList_

public static final String paramList_
See Also:
Constant Field Values

paramConcatenator_

public static final String paramConcatenator_
See Also:
Constant Field Values

space_

public static final String space_
See Also:
Constant Field Values

none_

public static final String none_
See Also:
Constant Field Values

escapedEmptyString_

public static final String escapedEmptyString_
See Also:
Constant Field Values

dot_

public static final String dot_
See Also:
Constant Field Values

parenleft_

public static final String parenleft_
See Also:
Constant Field Values

parenright_

public static final String parenright_
See Also:
Constant Field Values

parenthesis_

public static final String parenthesis_
See Also:
Constant Field Values

new_

public static final String new_
See Also:
Constant Field Values

endLine_

public static final String endLine_
See Also:
Constant Field Values

true_

public static final String true_
See Also:
Constant Field Values

false_

public static final String false_
See Also:
Constant Field Values

Collection_

public static final String Collection_
See Also:
Constant Field Values

Set_

public static final String Set_
See Also:
Constant Field Values

PersistenceCapable_

public static final String PersistenceCapable_
See Also:
Constant Field Values

brackets_

public static final String brackets_
See Also:
Constant Field Values

get_

public static final String get_
See Also:
Constant Field Values

set_

public static final String set_
See Also:
Constant Field Values

Oid_

public static final String Oid_
See Also:
Constant Field Values

Helper_

public static final String Helper_
See Also:
Constant Field Values

returnNull_

public static final String returnNull_
See Also:
Constant Field Values

fileName_

public static final String fileName_
See Also:
Constant Field Values

int_

public static final String int_
See Also:
Constant Field Values

String_

public static final String String_
See Also:
Constant Field Values

Class_

public static final String Class_
See Also:
Constant Field Values

Date_

public static final String Date_
See Also:
Constant Field Values

SqlDate_

public static final String SqlDate_
See Also:
Constant Field Values

SqlTime_

public static final String SqlTime_
See Also:
Constant Field Values

SqlTimestamp_

public static final String SqlTimestamp_
See Also:
Constant Field Values

Object_

public static final String Object_
See Also:
Constant Field Values

super_

public static final String[] super_
Constructor Detail

JavaClassWriterHelper

public JavaClassWriterHelper()
Method Detail

getBodyAsStrings

public static String[] getBodyAsStrings(String body)
Converts method body into String array.

Parameters:
body - as String with each substring separated by "\n"
Returns:
method body as String array.

getWrapperType

public static Class getWrapperType(Class cls)
Returns java Object wrapper Class corresponding to the primitive Class if the passed class represents a primitive. If the parameter is of Object type, it is returned.

Parameters:
cls - the primitive Class to find Object wrapper for.
Returns:
Object type Class.

getWrapperExpr

public static String getWrapperExpr(Class exprType,
                                    String expr)
A helper method which generates an expression to wrap a primitive datatype to its corresponding wrapper class.

Parameters:
exprType - The class of the primitive type
expr - The expression representing a primtive typevalue
Returns:
A String containing the expression for wrapping the primitive datatype in its corresponding wrapperclass

getUnwrapMethodName

public static String getUnwrapMethodName(Class primitiveType)
Returns the name of the method to access the value of the primitive type of the wrapper class. example: boolean.class is mapped to "booleanValue()".

Parameters:
primitiveType - the class object of the primitive type.
Returns:
the name of the method to access the primitive value of the wrapper

getPrimitiveType

public static String getPrimitiveType(Class cls)
Returns name of the primitive type corresponding to the Object wrapper Class passed as a parameter. If the parameter is of primitive type, its name is returned.

Parameters:
cls - the Object wrapper Class to find name of the primitive type for.
Returns:
name of the primitive type as String.

getExceptionNames

public static String[] getExceptionNames(Method m)
Returns exception type names as String[].

Parameters:
m - the Method to identify exception types for.
Returns:
exception type names as String[].

getParameterTypesList

public static String getParameterTypesList(Method m)
Returns list of method parameter types in format type0[,type1[,...]]

Parameters:
m - the Method to identify list of method parameters for.
Returns:
list of method parameter types as String

getParametersList

public static String getParametersList(Method m)
Returns list of method parameters in format param0[, param1[,...]]

Parameters:
m - the Method to identify list of method parameters for.
Returns:
list of method parameters as String

getParametersListWithSeparator

public static String getParametersListWithSeparator(Method m,
                                                    String sep)
Returns list of method parameters delimited by specified separator

Parameters:
m - the Method to identify list of method parameters for.
sep - the separator to be used to delimit the parameter names
Returns:
list of method parameters as String

addFields

public static void addFields(String prop,
                             int modifiers,
                             JavaClassWriter writer)
                      throws IOException
Adds fields to a class parsing the multi-String property.

Parameters:
prop - String to use for field generation.
modifiers - other field modifiers for these fields.
writer - the Class writer.
Throws:
IOException - if writer fails to add a field.

addPrivateField

public static void addPrivateField(String prop,
                                   int modifiers,
                                   JavaClassWriter writer)
                            throws IOException
Adds private fields to a class parsing the multi-String property.

Parameters:
prop - String to use for field generation.
modifiers - field modifiers for these fields.
Throws:
IOException - if writer fails to add a field.

addGenericMethod

public static void addGenericMethod(String mname,
                                    String[] body,
                                    JavaClassWriter writer)
                             throws IOException
Adds a private void no-args method to a class with this method body.

Parameters:
mname - method name
body - the method body as String[]
Throws:
IOException - if writer fails to add a field.

addGenericMethod

public static void addGenericMethod(String mname,
                                    String type,
                                    String[] body,
                                    JavaClassWriter writer)
                             throws IOException
Adds a private no-args method to a class with this method body and return type.

Parameters:
mname - method name
type - return type of the method
body - the method body as String[]
Throws:
IOException - if writer fails to add a field.

addGenericMethod

public static void addGenericMethod(String mname,
                                    int modifiers,
                                    String[] body,
                                    JavaClassWriter writer)
                             throws IOException
Adds a private void no-args method to a class with this method body and modifiers.

Parameters:
mname - method name
modifiers - the method modifiers
body - the method body as String[]
Throws:
IOException - if writer fails to add a field.

addGenericMethod

public static void addGenericMethod(String mname,
                                    int modifiers,
                                    String type,
                                    String[] body,
                                    JavaClassWriter writer)
                             throws IOException
Adds a private void no-args method to a class with this method body, modifiers, and return type.

Parameters:
mname - method name
modifiers - the method modifiers
type - return type of the method
body - the method body as String[]
Throws:
IOException - if writer fails to add a field.

addGenericMethod

public static void addGenericMethod(Method m,
                                    String mname,
                                    String mtype,
                                    String body,
                                    JavaClassWriter writer)
                             throws IOException
Adds a method to a class parsing the multi-String property.

Parameters:
m - Method that describes one to be added to the bean.
mname - method name if different from Method#getName(). This will be true for finder/selector/create methods.
mtype - return type of the method, that can differ from the bean's local or remote interface.
body - String to use for method body generation.
Throws:
IOException - if writer fails to add a field.

getTypeRepr

public static String getTypeRepr(Class clazz)
Returns the String representation of the specified class instance. An array is represented as the name of the element type followed by [].



Copyright © 2012 GlassFish Community. All Rights Reserved.