{
Class thisClass = this.getClass();
this.pool = TranslatorClassPool.getPool(thisClass.getClassLoader());
CtClass ctTranslatorClass = pool.get(thisClass.getName());
CtField adaptedField = new CtField(CtClass.booleanType, FIELD_ADAPTED, ctTranslatorClass);
ctTranslatorClass.addField(adaptedField);
//get the "inA" methods from the analysisClass
CtMethod[] analysisMethods = ctTranslatorClass.getMethods();
if (analysisMethods != null)
{
int methodNum = analysisMethods.length;
for (int ctr = 0; ctr < methodNum; ctr++)
{
CtMethod method = analysisMethods[ctr];
String methodName = method.getName();
if (methodName.startsWith(INA_PREFIX))
{
// add the new overriden "inA" methods
this.methods.put(method, this.getInAMethodBody(method));
}
else if (methodName.startsWith(OUTA_PREFIX))
{
// add the new overriden "outA" methods
this.methods.put(method, this.getOutAMethodBody(method));
}
else if (methodName.startsWith(CASE_PREFIX))
{
// add the new overridden "case" methods
this.methods.put(method, this.getCaseMethodBody(method));
}
}
//now add all the methods to the class
Iterator allMethods = this.methods.keySet().iterator();
while (allMethods.hasNext())
{
CtMethod method = (CtMethod)allMethods.next();
CtMethod newMethod = new CtMethod(method, ctTranslatorClass, null);
String methodBody = (String)this.methods.get(method);
newMethod.setBody(methodBody);
ctTranslatorClass.addMethod(newMethod);
}
}
this.writeAdaptedClass();
return ctTranslatorClass.toClass();
}