/** * Return the necessary imports for the class. */ private String getImports() { Set pkgs = getImportPackages(); CodeFormat imports = newCodeFormat(); String base = Strings.getPackageName(_type); String pkg; for (Iterator itr = pkgs.iterator(); itr.hasNext();) { pkg = (String) itr.next(); if (pkg.length() > 0 && !"java.lang".equals(pkg) && !base.equals(pkg)) { if (imports.length() > 0) imports.endl(); imports.append("import ").append(pkg).append(".*;"); } } return imports.toString(); }
/** * Returns the Java declaration and access method code for all declared * fields. */ private String[] getFieldCode() { CodeFormat decs = newCodeFormat(); CodeFormat code = newCodeFormat(); FieldMetaData[] fields = _meta.getDeclaredFields(); for (int i = 0; i < fields.length; i++) appendFieldCode(fields[i], decs, code); fields = _meta.getDeclaredUnmanagedFields(); for (int i = 0; i < fields.length; i++) appendFieldCode(fields[i], decs, code); return new String[]{ decs.toString(), code.toString() }; }
/** * Write the generated code to the proper file. */ public void writeCode() throws IOException { if (_code == null) return; File file = getFile(); Files.backup(file, false); _code.write(file); }
String elementType = null; String paramType = ""; if (useGenericCollections()) { if (fmd.getDeclaredTypeCode() == JavaTypes.COLLECTION) { Class elmCls = fmd.getElement().getDeclaredType(); String fieldValue = getInitialValue(fmd); if (fieldValue == null) { if ("Set".equals(fieldType)) boolean fieldAccess = !usePropertyBasedAccess(); String custom = getDeclaration(fmd); if (decs.length() > 0) decs.endl(); } else { if (fieldAccess) writeAnnotations(decs, getFieldAnnotations(fmd), 1); decs.tab().append("private ").append(fieldType). append(paramType).append(" ").append(fieldName). custom = getFieldCode(fmd); if (code.length() > 0) code.afterSection(); writeAnnotations(code, getFieldAnnotations(fmd), 1); code.tab().append("public ").append(fieldType).append(paramType). append(" ");
String className, String extendsName, String constructor, String fieldDecs, String fieldCode) { CodeFormat code = newCodeFormat(); if (packageDec.length() > 0) code.append(packageDec).afterSection(); append(" */").endl(); writeAnnotations(code, getClassAnnotations(), 0); code.append("public class ").append(className); if (extendsName.length() > 0) code.extendsDec(1).append(" ").append(extendsName); openClassBrace(code); code.endl(); closeClassBrace(code);
String imports = getImports(); String[] fieldCode = getFieldCode(); String constructor = getConstructor(); String codeStr = getClassCode(); if (codeStr != null) { _code.append(codeStr); _code.setParameter("fieldCode", fieldCode[1]); } else _code.append(getClassCode(packageDec, imports, className, extendsName, constructor, fieldCode[0], fieldCode[1]));
/** * If there is an inner application identity class, then * add it to the bottom of the class code. */ protected void closeClassBrace(CodeFormat code) { if (_appid != null) { code.afterSection(); code.append(_appid.getCode()); code.endl(); } super.closeClassBrace(code); }
/** * Add the list of imports for any inner app id classes * * @return */ public Set getImportPackages() { Set pkgs = super.getImportPackages(); if (_appid != null) pkgs.addAll(_appid.getImportPackages()); return pkgs; }
String elementType = null; String paramType = ""; if (useGenericCollections()) { if (fmd.getDeclaredTypeCode() == JavaTypes.COLLECTION) { Class elmCls = fmd.getElement().getDeclaredType(); String fieldValue = getInitialValue(fmd); if (fieldValue == null) { if ("Set".equals(fieldType)) boolean fieldAccess = !usePropertyBasedAccess(); String custom = getDeclaration(fmd); if (decs.length() > 0) decs.endl(); } else { if (fieldAccess) writeAnnotations(decs, getFieldAnnotations(fmd), 1); decs.tab().append("private ").append(fieldType). append(paramType).append(" ").append(fieldName). custom = getFieldCode(fmd); if (code.length() > 0) code.afterSection(); writeAnnotations(code, getFieldAnnotations(fmd), 1); code.tab().append("public ").append(fieldType).append(paramType). append(" ");
String className, String extendsName, String constructor, String fieldDecs, String fieldCode) { CodeFormat code = newCodeFormat(); if (packageDec.length() > 0) code.append(packageDec).afterSection(); append(" */").endl(); writeAnnotations(code, getClassAnnotations(), 0); code.append("public class ").append(className); if (extendsName.length() > 0) code.extendsDec(1).append(" ").append(extendsName); openClassBrace(code); code.endl(); closeClassBrace(code);
String imports = getImports(); String[] fieldCode = getFieldCode(); String constructor = getConstructor(); String codeStr = getClassCode(); if (codeStr != null) { _code.append(codeStr); _code.setParameter("fieldCode", fieldCode[1]); } else _code.append(getClassCode(packageDec, imports, className, extendsName, constructor, fieldCode[0], fieldCode[1]));
/** * If there is an inner application identity class, then * add it to the bottom of the class code. */ protected void closeClassBrace(CodeFormat code) { if (_appid != null) { code.afterSection(); code.append(_appid.getCode()); code.endl(); } super.closeClassBrace(code); }
/** * Add the list of imports for any inner app id classes * * @return */ public Set getImportPackages() { Set pkgs = super.getImportPackages(); if (_appid != null) pkgs.addAll(_appid.getImportPackages()); return pkgs; }
String elementType = null; String paramType = ""; if (useGenericCollections()) { if (fmd.getDeclaredTypeCode() == JavaTypes.COLLECTION) { Class elmCls = fmd.getElement().getDeclaredType(); String fieldValue = getInitialValue(fmd); if (fieldValue == null) { if ("Set".equals(fieldType)) boolean fieldAccess = !usePropertyBasedAccess(); String custom = getDeclaration(fmd); if (decs.length() > 0) decs.endl(); } else { if (fieldAccess) writeAnnotations(decs, getFieldAnnotations(fmd), 1); decs.tab().append("private ").append(fieldType). append(paramType).append(" ").append(fieldName). custom = getFieldCode(fmd); if (code.length() > 0) code.afterSection(); writeAnnotations(code, getFieldAnnotations(fmd), 1); code.tab().append("public ").append(fieldType).append(paramType). append(" ");
String className, String extendsName, String constructor, String fieldDecs, String fieldCode) { CodeFormat code = newCodeFormat(); if (packageDec.length() > 0) code.append(packageDec).afterSection(); append(" */").endl(); writeAnnotations(code, getClassAnnotations(), 0); code.append("public class ").append(className); if (extendsName.length() > 0) code.extendsDec(1).append(" ").append(extendsName); openClassBrace(code); code.endl(); closeClassBrace(code);
String imports = getImports(); String[] fieldCode = getFieldCode(); String constructor = getConstructor(); String codeStr = getClassCode(); if (codeStr != null) { _code.append(codeStr); _code.setParameter("fieldCode", fieldCode[1]); } else _code.append(getClassCode(packageDec, imports, className, extendsName, constructor, fieldCode[0], fieldCode[1]));
/** * Return the necessary imports for the class. */ private String getImports() { Set pkgs = getImportPackages(); CodeFormat imports = newCodeFormat(); String base = Strings.getPackageName(_type); String pkg; for (Iterator itr = pkgs.iterator(); itr.hasNext();) { pkg = (String) itr.next(); if (pkg.length() > 0 && !"java.lang".equals(pkg) && !base.equals(pkg)) { if (imports.length() > 0) imports.endl(); imports.append("import ").append(pkg).append(".*;"); } } return imports.toString(); }
/** * Returns the Java declaration and access method code for all declared * fields. */ private String[] getFieldCode() { CodeFormat decs = newCodeFormat(); CodeFormat code = newCodeFormat(); FieldMetaData[] fields = _meta.getDeclaredFields(); for (int i = 0; i < fields.length; i++) appendFieldCode(fields[i], decs, code); fields = _meta.getDeclaredUnmanagedFields(); for (int i = 0; i < fields.length; i++) appendFieldCode(fields[i], decs, code); return new String[]{ decs.toString(), code.toString() }; }
/** * If there is an inner application identity class, then * add it to the bottom of the class code. */ protected void closeClassBrace(CodeFormat code) { if (_appid != null) { code.afterSection(); code.append(_appid.getCode()); code.endl(); } super.closeClassBrace(code); }
/** * Add the list of imports for any inner app id classes * * @return */ public Set getImportPackages() { Set pkgs = super.getImportPackages(); if (_appid != null) pkgs.addAll(_appid.getImportPackages()); return pkgs; }