Methods Summary |
---|
void | addInterfaces()Add interfaces to the class declarations.
super.addInterfaces();
jdoHelperWriter.addInterface(CMP11TemplateFormatter.helper11Interface_);
|
void | generateFields()Generates required internal variables.
super.generateFields();
CMP11TemplateFormatter.addPrivateField(
CMP11TemplateFormatter.one_oneVariablesTemplate,
0, concreteImplWriter);
|
void | generateKnownMethods(AbstractMethodHelper methodHelper)Adds other known required methods identified by properties that do
not need formatting but differ between CMP types.
CMP11TemplateFormatter.otherPublicMethods_ differ between CMP types.
super.generateKnownMethods(methodHelper);
String[] exc = null;
String[] st = CMP11TemplateFormatter.otherPublicMethodsArray;
for (int i = 0; i < st.length; i++) {
String mname = st[i];
exc = getExceptionList(methodHelper, mname);
String body = CMPROTemplateFormatter.updateNotAllowedTemplate;
// Only ejbLoad from this list doesn't differ for read-only beans.
if (isUpdateable || mname.equals(CMPTemplateFormatter.ejbLoad_)) {
body = CMP11TemplateFormatter.helpers.getProperty(
mname + "1_1"); // NOI18N
} else if (mname.equals(CMPTemplateFormatter.jdoCleanAllRefs_)) {
body = CMPROTemplateFormatter.jdoCleanAllRefsTemplate;
}
concreteImplWriter.addMethod(mname, // name
Modifier.PUBLIC, // modifiers
CMP11TemplateFormatter.void_, // returnType
null, // parameterNames
null,// parameterTypes
exc,// exceptions
CMP11TemplateFormatter.getBodyAsStrings(body), // body
null);// comments
}
|
void | generateLoadStoreMethods(PersistenceFieldElement[] fields)Adds jdoLoadFields/jdoStoreFields for CMP1.1
int i, count = ((fields != null) ? fields.length : 0);
StringBuffer lbody = new StringBuffer();
StringBuffer sbody = new StringBuffer(CMPTemplateFormatter.none_);
for (i = 0; i < count; i++) {
PersistenceFieldElement pfe = fields[i];
if (PersistenceFieldElement.PERSISTENT == pfe.getPersistenceType()) {
FieldInfo fieldInfo = new FieldInfo(model, nameMapper, pfe, beanName, pcname);
if (fieldInfo.isGeneratedField) {
// Skip generated fields as they are not present in the bean class.
// A field is generated for the unknown PK class or version consistency.
// There are no relationship fields in CMP1.1 beans.
if (fieldInfo.isKey) {
// This is an extra field for the unknown PK class.
// PK setter name is used to generate the line for ejbCreate
// to set the PK value in _JDOState.
setPKField = fieldInfo.setter;
}
continue;
}
// Add code to load non-DFG field if necessary.
loadNonDFGField(fieldInfo);
if( fieldInfo.isByteArray) {
// A byte[] CMP field should have copy-in, copy-out semantics
// via System.arraycopy.
twoParams[0] = fieldInfo.name;
twoParams[1] = fieldInfo.getter;
lbody.append(CMP11TemplateFormatter.l11arrayformatter.format(twoParams));
if (isUpdateable) {
threeParams[0] = fieldInfo.getter;
threeParams[1] = fieldInfo.name;
threeParams[2] = fieldInfo.setter;
sbody.append(CMP11TemplateFormatter.s11arrayformatter.format(threeParams));
}
} else if( fieldInfo.isSerializable ) {
// A special case for a Serializable CMP field (but not byte[]) -
// it should be serialized to/from a byte[] in PC instance.
fourParams[0] = fieldInfo.name;
fourParams[1] = fieldInfo.getter;
fourParams[2] = fieldInfo.type;
fourParams[3] = concreteImplName;
lbody.append(CMP11TemplateFormatter.l11Serializableformatter.format(fourParams));
if (isUpdateable) {
fourParams[0] = fieldInfo.getter;
fourParams[1] = fieldInfo.name;
fourParams[2] = fieldInfo.setter;
fourParams[3] = concreteImplName;
sbody.append(CMP11TemplateFormatter.s11Serializableformatter.format(fourParams));
}
} else if (fieldInfo.requireCloneOnGetAndSet) {
threeParams[0] = fieldInfo.getter;
threeParams[1] = fieldInfo.type;
threeParams[2] = fieldInfo.name;
lbody.append(CMP11TemplateFormatter.l11copyformatter.format(threeParams));
if (isUpdateable) {
fourParams[0] = fieldInfo.getter;
fourParams[1] = fieldInfo.name;
fourParams[2] = fieldInfo.setter;
fourParams[3] = fieldInfo.type;
if (!pfe.isKey()) {
sbody.append(CMP11TemplateFormatter.s11copyformatter.format(fourParams));
} else {
twoParams[0] = concreteImplName;
twoParams[1] = fieldInfo.name;
sbody.append(CMP11TemplateFormatter.assertpks11formatter.format(twoParams)).
append(CMP11TemplateFormatter.pkcopy11formatter.format(fourParams));
}
}
} else {
twoParams[0] = fieldInfo.name;
twoParams[1] = fieldInfo.getter;
lbody.append(CMP11TemplateFormatter.l11formatter.format(twoParams));
if (isUpdateable) {
threeParams[0] = fieldInfo.getter;
threeParams[1] = fieldInfo.name;
threeParams[2] = fieldInfo.setter;
if (!pfe.isKey()) {
sbody.append(CMP11TemplateFormatter.s11formatter.format(threeParams));
} else {
if (!fieldInfo.isPrimitive) {
twoParams[0] = concreteImplName;
twoParams[1] = fieldInfo.name;
sbody.append(
CMP11TemplateFormatter.assertpks11formatter.format(twoParams));
}
sbody.append(requireTrimOnSet(fieldInfo.type) ?
CMP11TemplateFormatter.pkstring11formatter.format(threeParams) :
CMP11TemplateFormatter.pks11formatter.format(threeParams));
}
}
}
}
}
// Add jdoLoadFields
CMPTemplateFormatter.addGenericMethod(
CMP11TemplateFormatter.loadFields1_1_,
CMP11TemplateFormatter.getBodyAsStrings(lbody.toString()),
concreteImplWriter);
// Add jdoStoreFields
CMPTemplateFormatter.addGenericMethod(
CMP11TemplateFormatter.storeFields1_1_,
CMP11TemplateFormatter.getBodyAsStrings(sbody.toString()),
concreteImplWriter);
|
java.lang.String | generateQueryIgnoreCache()Generates a setIgnoreCache(true) call for a JDOQL query,
in the case of a EJB 1.1 finder.
oneParam[0] = CMP11TemplateFormatter.true_;
return CMP11TemplateFormatter.querysetignorecacheformatter.format(oneParam);
|
void | generateTypeSpecificMethods(PersistenceFieldElement[] allFields, AbstractMethodHelper methodHelper)Generate CMP1.1 specific methods.
super.generateTypeSpecificMethods(allFields, methodHelper);
generateLoadStoreMethods(allFields);
|
java.lang.String | getEJBCreateMethodBody(java.lang.String createName, java.lang.String[] exc, java.lang.String parametersList, java.lang.String parametersListWithSeparator)Returns method body for EJBCreate method.
// For read-only beans it will throw an exception on access.
// For updateable beans it will be generated to do the create.
String body = CMPROTemplateFormatter.accessNotAllowedTemplate;
if (isUpdateable) {
// no suffixes in ejbCreate for CMP1.1 beans but we need to check what
// exception is available.
if (pkClass.equals(Object.class.getName())) {
fiveParams[0] = pcname;
fiveParams[1] = parametersList;
fiveParams[2] = setPKField;
fiveParams[3] = concreteImplName;
fiveParams[4] = parametersListWithSeparator;
body = CMP11TemplateFormatter.c11unpkformatter.format(fiveParams);
} else {
sixParams[0] = pcname;
sixParams[1] = parametersList;
sixParams[2] = pkClass;
sixParams[3] = concreteImplName;
String s = getException(exc, CMP11TemplateFormatter.DuplicateKeyException_,
CMP11TemplateFormatter.CreateException_);
int l = s.lastIndexOf(CMP11TemplateFormatter.dot_);
sixParams[4] = (l > 0)? s.substring(l + 1) : s;
sixParams[5] = parametersListWithSeparator;
body = CMP11TemplateFormatter.c11formatter.format(sixParams);
}
}
return body;
|
java.lang.String | getEJBPostCreateMethodBody(java.lang.String postCreateName, java.lang.String parametersList, java.lang.String parametersListWithSeparator)Returns method body for EJBPostCreate method.
// For read-only beans it will be a no-op. For updateable
// beans it will be generated.
String body = CMPTemplateFormatter.none_;
if (isUpdateable) {
twoParams[0] = parametersList;
twoParams[1] = parametersListWithSeparator;
body = CMP11TemplateFormatter.postc11formatter.format(twoParams);
}
return body;
|
java.lang.String | getEJBRemoveMethodBody()Returns method body for EJBRemove method.
// For read-only beans it will throw an exception on access.
// For updateable beans it will be generated.
String body = CMPROTemplateFormatter.updateNotAllowedTemplate;
if (isUpdateable) {
// CMP1.1 does not need any variables to substitute.
body = CMP11TemplateFormatter.ejbRemove1_1Template;
}
return body;
|
com.sun.jdo.spi.persistence.support.ejb.ejbqlc.JDOQLElements | getJDOQLElements(java.lang.reflect.Method m, AbstractMethodHelper methodHelper)Returns JDOQLElements instance for this finder method.
// CMP11 : get JDO query settings from DD
return getJDOQLElementsForCMP11(m, methodHelper);
|
private com.sun.jdo.spi.persistence.support.ejb.ejbqlc.JDOQLElements | getJDOQLElementsForCMP11(java.lang.reflect.Method m, AbstractMethodHelper methodHelper)Creating a JDOQLElements object for CMP11 support. For CMP11 there is no
EJBQL, thus we get the filter expression and parameter declaration from
the DD.
String params = methodHelper.getJDOParameterDeclaration(m);
String variables = methodHelper.getJDOVariableDeclaration(m);
String filter = methodHelper.getJDOFilterExpression(m);
String ordering = methodHelper.getJDOOrderingSpecification(m);
return new JDOQLElements(
pcname, // use the pc class for this bean as candidateClass
params, // JDO parameter declarations from DD
variables, // JDO variables declarations from DD
filter, // JDO filter expression from DD
ordering, // JDO ordering expression from DD
"this", // finders return PK instances =>
// Project this to prevent generation of distinct
pcname, // finders return PK instances =>
// the jdo query returns a set of pc instances
true, // JDO query returns candidate class instances =>
// isPCResult = true
false, // not associate to aggregate function
null // not available and not supported for 1.1 finder
);
|
java.lang.String | getSignaturesOfGeneratorClasses()Returns the signatures of the classes and properties which are
involved in the codegen.
StringBuffer signatures = new StringBuffer().
// adding signature of JDOConcreteBeanGenerator
append(super.getSignaturesOfGeneratorClasses()).
append(CMPTemplateFormatter.signatureDelimiter_).
// adding signature of JDOConcreteBean11Generator
append(JDOConcreteBean11Generator.SIGNATURE).
append(CMPTemplateFormatter.signatureDelimiter_).
// adding signature of CMP11Templates.properties
append(CMP11TemplateFormatter.signature1_1Template);
return signatures.toString();
|
boolean | isFinderReturningEnumeration(java.lang.reflect.Method finder)Checks if the finder returns an Enumeration (for CMP1.1)
return (finder.getReturnType().equals(java.util.Enumeration.class));
|
void | setHelperSuperclass()Set super class for the helper class.
jdoHelperWriter.setSuperclass(CMP11TemplateFormatter.helper11Impl_);
|