Fields Summary |
---|
public static final String | javaExtension_ |
public static final String | void_ |
public static final String | boolean_ |
public static final String | byte_ |
public static final String | byteArray_ |
public static final String | param_ |
public static final String | param0_ |
public static final String | null_ |
public static final String | home_ |
public static final String | delim_ |
public static final String | paramInitializer_ |
public static final String | paramSeparator_ |
public static final String | paramList_ |
public static final String | paramConcatenator_ |
public static final String | space_ |
public static final String | none_ |
public static final String | escapedEmptyString_ |
public static final String | dot_ |
public static final String | parenleft_ |
public static final String | parenright_ |
public static final String | parenthesis_ |
public static final String | new_ |
public static final String | endLine_ |
public static final String | true_ |
public static final String | false_ |
public static final String | Collection_ |
public static final String | Set_ |
public static final String | PersistenceCapable_ |
public static final String | brackets_ |
public static final String | get_ |
public static final String | set_ |
public static final String | Oid_ |
public static final String | Helper_ |
public static final String | returnNull_ |
public static final String | fileName_ |
public static final String | int_ |
public static final String | String_ |
public static final String | Class_ |
public static final String | Date_ |
public static final String | SqlDate_ |
public static final String | SqlTime_ |
public static final String | SqlTimestamp_ |
public static final String | Object_ |
public static final String[] | super_ |
private static final String[] | indentation_ |
Methods Summary |
---|
public static void | addFields(java.lang.String prop, int modifiers, JavaClassWriter writer)Adds fields to a class parsing the multi-String property.
String[] v = getBodyAsStrings(prop);
for (int i = 0; i < v.length; i++) {
StringTokenizer st = new StringTokenizer(v[i], space_);
String type = st.nextToken();
String name = st.nextToken();
StringBuffer value = new StringBuffer();
while(st.hasMoreTokens())
value.append(st.nextToken() + space_);
int l = value.length();
value.deleteCharAt(l - 1); // last space
writer.addField(name, // name
modifiers, // modifiers
type, // type
value.toString(), // value,
null); // comments
}
|
public 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.
addGenericMethod(mname, void_, body, writer);
|
public 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.
addGenericMethod(mname, Modifier.PRIVATE, type, body, writer);
|
public 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.
addGenericMethod(mname, modifiers, void_, body, writer);
|
public 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.
writer.addMethod(mname, // name
modifiers, // modifiers
type, // returnType
null, // parameterNames
null,// parameterTypes
null,// exceptions
body, // body
null);// comments
|
public 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.
Class[] types = m.getParameterTypes();
int count = types.length;
String[] parameterTypes = new String[count];
String[] parameterNames = new String[count];
for (int ii = 0; ii < count; ii++) {
parameterTypes[ii] = getTypeRepr(types[ii]);
parameterNames[ii] = param_ + ii;
}
String[] exceptionTypes = getExceptionNames(m);
int modifiers = m.getModifiers();
if (Modifier.isAbstract(modifiers))
modifiers -= Modifier.ABSTRACT;
writer.addMethod(mname, // name
modifiers, // modifiers
mtype, // returnType
parameterNames, // parameterNames
parameterTypes,// parameterTypes
exceptionTypes,// exceptions
getBodyAsStrings(body), // body
null);// comments
|
public static void | addPrivateField(java.lang.String prop, int modifiers, JavaClassWriter writer)Adds private fields to a class parsing the multi-String property.
addFields(prop, Modifier.PRIVATE + modifiers, writer);
|
public static java.lang.String[] | getBodyAsStrings(java.lang.String body)Converts method body into String array. // NOI18N
StringTokenizer st = new StringTokenizer(body, endLine_);
String[] rc = new String[st.countTokens()];
int ii = 0;
while(st.hasMoreTokens()) {
String s = st.nextToken();
int i = s.lastIndexOf('\t");
if (i > -1)
rc[ii] = indentation_[i] + s.substring(i + 1);
else
rc[ii] = s;
ii++;
}
return rc;
|
public static java.lang.String[] | getExceptionNames(java.lang.reflect.Method m)Returns exception type names as String[].
Class[] cls = m.getExceptionTypes();
String[] rc = new String[cls.length];
for (int ii = 0; ii < cls.length; ii++) {
rc[ii] = cls[ii].getName();
}
return rc;
|
public static java.lang.String | getParameterTypesList(java.lang.reflect.Method m)Returns list of method parameter types in format
type0[,type1[,...]]
if (m == null)
return none_;
StringBuffer buf = new StringBuffer();
Class[] paramTypes = m.getParameterTypes();
for (int i = 0; i < paramTypes.length; i++) {
if (i > 0)
buf.append(paramList_);
buf.append(getTypeRepr(paramTypes[i]));
}
return buf.toString();
|
public static java.lang.String | getParametersList(java.lang.reflect.Method m)Returns list of method parameters in format
param0[, param1[,...]]
return getParametersListWithSeparator(m, paramSeparator_);
|
public static java.lang.String | getParametersListWithSeparator(java.lang.reflect.Method m, java.lang.String sep)Returns list of method parameters delimited by specified
separator
int count = m.getParameterTypes().length;
StringBuffer rc = new StringBuffer();
for (int ii = 0; ii < count; ii++) {
if (ii > 0)
rc.append(sep);
rc.append(param_ + ii);
}
return rc.toString();
|
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.
String rc = getPrimitiveName(cls);
if (rc == null) { // not an Object
rc = cls.getName();
}
return rc;
|
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 [].
return (clazz.isArray() ?
getTypeRepr(clazz.getComponentType()) + brackets_ :
clazz.getName());
|
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()".
return primitiveType.getName() + "Value()"; //NOI18N
|
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.
StringBuffer wrapped = new StringBuffer();
wrapped.append(new_);
wrapped.append(space_);
wrapped.append(getWrapperType(exprType).getName());
wrapped.append(parenleft_);
wrapped.append(expr);
wrapped.append(parenright_);
return wrapped.toString();
|
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.
Class rc = getWrapperClass(cls);
if (rc == null) { // not a primitive
rc = cls;
}
return rc;
|