1 30 package com.genimen.djeneric.tools.strongtyper; 31 32 public class ParentObjectGenerator extends Generator 33 { 34 public ParentObjectGenerator() 35 { 36 } 37 38 public String getClassName() 39 { 40 return getParentObjectClassName() + (isAbstract() ? getGeneratedSuffix() : ""); 41 } 42 43 public String getPackageName() 44 { 45 return getImplPackageName(); 46 } 47 48 public String getCode() throws Exception 49 { 50 StringBuffer code = new StringBuffer (5000); 51 if (getPackageName().trim().length() > 0) code.append("package " + getPackageName() + ";\n\n"); 52 53 code.append("import " + getItfPackageName() + ".*;\n"); 54 code.append("import com.genimen.djeneric.repository.*;\n"); 55 code.append("import com.genimen.djeneric.repository.rdbms.*;\n\n"); 56 code.append("import com.genimen.djeneric.repository.exceptions.*;\n\n"); 57 code.append(StrongTyper.getRegenerationTags(1)); 58 59 code.append("public class " + getClassName() + " extends RdbmsDjenericObject\n"); 60 code.append("{\n"); 61 62 code.append("\n protected " + getClassName() + "(DjSession session, DjExtent extent) throws DjenericException\n" 63 + " {\n" + " super(session, extent);\n" + " }\n\n" + " public boolean isMarkedForDestroy()\n" 64 + " {\n" + " return isMarkedForDelete();\n" + " }\n\n" + " public void destroy() throws " 65 + getExceptionClassName() + "\n" + " {\n" + " try { markForDelete();\n" + " }\n" 66 + " catch(Exception x)\n" + " { throw new " + getExceptionClassName() + "(x);\n" 67 + " }\n" + " } \n\n" + " public void checkRequired() throws " + getExceptionClassName() + "\n" 68 + " {\n" + " try { checkRequiredProperties();\n" + " }\n" + " catch(Exception x)\n" 69 + " { throw new " + getExceptionClassName() + "(x);\n" + " }\n" + " } \n\n" 70 + " public void reloadFromStore() throws " + getExceptionClassName() + "\n" + " {\n" 71 + " try { reload();\n" + " }\n" + " catch(Exception x)\n" + " { throw new " 72 + getExceptionClassName() + "(x);\n" + " }\n" + " } \n\n" 73 + " public void makeTransient() throws " + getExceptionClassName() + "\n" + " {\n" 74 + " try { setTransient(true);\n" + " }\n" + " catch(Exception x)\n" 75 + " { throw new " + getExceptionClassName() + "(x);\n" + " }\n" + " } \n\n"); 76 77 code.append(StrongTyper.getRegenerationTags(0)); 78 code.append("}\n"); 79 return code.toString(); 80 } 81 82 } | Popular Tags |