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 java.lang.String boolean_
           
static java.lang.String brackets_
           
static java.lang.String byte_
           
static java.lang.String byteArray_
           
static java.lang.String Class_
           
static java.lang.String Collection_
           
static java.lang.String Date_
           
static java.lang.String delim_
           
static java.lang.String dot_
           
static java.lang.String endLine_
           
static java.lang.String escapedEmptyString_
           
static java.lang.String false_
           
static java.lang.String fileName_
           
static java.lang.String get_
           
static java.lang.String Helper_
           
static java.lang.String home_
           
static java.lang.String int_
           
static java.lang.String javaExtension_
           
static java.lang.String new_
           
static java.lang.String none_
           
static java.lang.String null_
           
static java.lang.String Object_
           
static java.lang.String Oid_
           
static java.lang.String param_
           
static java.lang.String param0_
           
static java.lang.String paramConcatenator_
           
static java.lang.String paramInitializer_
           
static java.lang.String paramList_
           
static java.lang.String paramSeparator_
           
static java.lang.String parenleft_
           
static java.lang.String parenright_
           
static java.lang.String parenthesis_
           
static java.lang.String PersistenceCapable_
           
static java.lang.String returnNull_
           
static java.lang.String set_
           
static java.lang.String Set_
           
static java.lang.String space_
           
static java.lang.String SqlDate_
           
static java.lang.String SqlTime_
           
static java.lang.String SqlTimestamp_
           
static java.lang.String String_
           
static java.lang.String[] super_
           
static java.lang.String true_
           
static java.lang.String void_
           
 
Constructor Summary
JavaClassWriterHelper()
           
 
Method Summary
static void addFields(java.lang.String prop, int modifiers, JavaClassWriter writer)
          Adds fields to a class parsing the multi-String property.
static void addGenericMethod(java.lang.reflect.Method m, java.lang.String mname, java.lang.String mtype, java.lang.String body, JavaClassWriter writer)
          Adds a method to a class parsing the multi-String property.
static void addGenericMethod(java.lang.String mname, int modifiers, java.lang.String[] body, JavaClassWriter writer)
          Adds a private void no-args method to a class with this method body and modifiers.
static void addGenericMethod(java.lang.String mname, int modifiers, java.lang.String type, java.lang.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(java.lang.String mname, java.lang.String[] body, JavaClassWriter writer)
          Adds a private void no-args method to a class with this method body.
static void addGenericMethod(java.lang.String mname, java.lang.String type, java.lang.String[] body, JavaClassWriter writer)
          Adds a private no-args method to a class with this method body and return type.
static void addPrivateField(java.lang.String prop, int modifiers, JavaClassWriter writer)
          Adds private fields to a class parsing the multi-String property.
static java.lang.String[] getBodyAsStrings(java.lang.String body)
          Converts method body into String array.
static java.lang.String[] getExceptionNames(java.lang.reflect.Method m)
          Returns exception type names as String[].
static java.lang.String getParametersList(java.lang.reflect.Method m)
          Returns list of method parameters in format param0[, param1[,...]]
static java.lang.String getParametersListWithSeparator(java.lang.reflect.Method m, java.lang.String sep)
          Returns list of method parameters delimited by specified separator
static java.lang.String getParameterTypesList(java.lang.reflect.Method m)
          Returns list of method parameter types in format type0[,type1[,...]]
static java.lang.String getPrimitiveType(java.lang.Class cls)
          Returns name of the primitive type corresponding to the Object wrapper Class passed as a parameter.
static java.lang.String getTypeRepr(java.lang.Class clazz)
          Returns the String representation of the specified class instance.
static java.lang.String getUnwrapMethodName(java.lang.Class primitiveType)
          Returns the name of the method to access the value of the primitive type of the wrapper class.
static java.lang.String getWrapperExpr(java.lang.Class exprType, java.lang.String expr)
          A helper method which generates an expression to wrap a primitive datatype to its corresponding wrapper class.
static java.lang.Class getWrapperType(java.lang.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 java.lang.String javaExtension_
See Also:
Constant Field Values

void_

public static final java.lang.String void_
See Also:
Constant Field Values

boolean_

public static final java.lang.String boolean_
See Also:
Constant Field Values

byte_

public static final java.lang.String byte_
See Also:
Constant Field Values

byteArray_

public static final java.lang.String byteArray_
See Also:
Constant Field Values

param_

public static final java.lang.String param_
See Also:
Constant Field Values

param0_

public static final java.lang.String param0_
See Also:
Constant Field Values

null_

public static final java.lang.String null_
See Also:
Constant Field Values

home_

public static final java.lang.String home_
See Also:
Constant Field Values

delim_

public static final java.lang.String delim_
See Also:
Constant Field Values

paramInitializer_

public static final java.lang.String paramInitializer_
See Also:
Constant Field Values

paramSeparator_

public static final java.lang.String paramSeparator_
See Also:
Constant Field Values

paramList_

public static final java.lang.String paramList_
See Also:
Constant Field Values

paramConcatenator_

public static final java.lang.String paramConcatenator_
See Also:
Constant Field Values

space_

public static final java.lang.String space_
See Also:
Constant Field Values

none_

public static final java.lang.String none_
See Also:
Constant Field Values

escapedEmptyString_

public static final java.lang.String escapedEmptyString_
See Also:
Constant Field Values

dot_

public static final java.lang.String dot_
See Also:
Constant Field Values

parenleft_

public static final java.lang.String parenleft_
See Also:
Constant Field Values

parenright_

public static final java.lang.String parenright_
See Also:
Constant Field Values

parenthesis_

public static final java.lang.String parenthesis_
See Also:
Constant Field Values

new_

public static final java.lang.String new_
See Also:
Constant Field Values

endLine_

public static final java.lang.String endLine_
See Also:
Constant Field Values

true_

public static final java.lang.String true_
See Also:
Constant Field Values

false_

public static final java.lang.String false_
See Also:
Constant Field Values

Collection_

public static final java.lang.String Collection_
See Also:
Constant Field Values

Set_

public static final java.lang.String Set_
See Also:
Constant Field Values

PersistenceCapable_

public static final java.lang.String PersistenceCapable_
See Also:
Constant Field Values

brackets_

public static final java.lang.String brackets_
See Also:
Constant Field Values

get_

public static final java.lang.String get_
See Also:
Constant Field Values

set_

public static final java.lang.String set_
See Also:
Constant Field Values

Oid_

public static final java.lang.String Oid_
See Also:
Constant Field Values

Helper_

public static final java.lang.String Helper_
See Also:
Constant Field Values

returnNull_

public static final java.lang.String returnNull_
See Also:
Constant Field Values

fileName_

public static final java.lang.String fileName_
See Also:
Constant Field Values

int_

public static final java.lang.String int_
See Also:
Constant Field Values

String_

public static final java.lang.String String_
See Also:
Constant Field Values

Class_

public static final java.lang.String Class_
See Also:
Constant Field Values

Date_

public static final java.lang.String Date_
See Also:
Constant Field Values

SqlDate_

public static final java.lang.String SqlDate_
See Also:
Constant Field Values

SqlTime_

public static final java.lang.String SqlTime_
See Also:
Constant Field Values

SqlTimestamp_

public static final java.lang.String SqlTimestamp_
See Also:
Constant Field Values

Object_

public static final java.lang.String Object_
See Also:
Constant Field Values

super_

public static final java.lang.String[] super_
Constructor Detail

JavaClassWriterHelper

public JavaClassWriterHelper()
Method Detail

getBodyAsStrings

public static java.lang.String[] getBodyAsStrings(java.lang.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 java.lang.Class getWrapperType(java.lang.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 java.lang.String getWrapperExpr(java.lang.Class exprType,
                                              java.lang.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 java.lang.String getUnwrapMethodName(java.lang.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 java.lang.String getPrimitiveType(java.lang.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 java.lang.String[] getExceptionNames(java.lang.reflect.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 java.lang.String getParameterTypesList(java.lang.reflect.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 java.lang.String getParametersList(java.lang.reflect.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 java.lang.String getParametersListWithSeparator(java.lang.reflect.Method m,
                                                              java.lang.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(java.lang.String prop,
                             int modifiers,
                             JavaClassWriter writer)
                      throws java.io.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:
java.io.IOException - if writer fails to add a field.

addPrivateField

public static void addPrivateField(java.lang.String prop,
                                   int modifiers,
                                   JavaClassWriter writer)
                            throws java.io.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:
java.io.IOException - if writer fails to add a field.

addGenericMethod

public static void addGenericMethod(java.lang.String mname,
                                    java.lang.String[] body,
                                    JavaClassWriter writer)
                             throws java.io.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:
java.io.IOException - if writer fails to add a field.

addGenericMethod

public static void addGenericMethod(java.lang.String mname,
                                    java.lang.String type,
                                    java.lang.String[] body,
                                    JavaClassWriter writer)
                             throws java.io.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:
java.io.IOException - if writer fails to add a field.

addGenericMethod

public static void addGenericMethod(java.lang.String mname,
                                    int modifiers,
                                    java.lang.String[] body,
                                    JavaClassWriter writer)
                             throws java.io.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:
java.io.IOException - if writer fails to add a field.

addGenericMethod

public static void addGenericMethod(java.lang.String mname,
                                    int modifiers,
                                    java.lang.String type,
                                    java.lang.String[] body,
                                    JavaClassWriter writer)
                             throws java.io.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:
java.io.IOException - if writer fails to add a field.

addGenericMethod

public static void addGenericMethod(java.lang.reflect.Method m,
                                    java.lang.String mname,
                                    java.lang.String mtype,
                                    java.lang.String body,
                                    JavaClassWriter writer)
                             throws java.io.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:
java.io.IOException - if writer fails to add a field.

getTypeRepr

public static java.lang.String getTypeRepr(java.lang.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.