public String generateDefaultConstructorString(GenerationContext generationContext, DataObject dataObject) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("currentDataObject", dataObject); return generateSubTemplateString(generationContext, "java_default_constructor"); }
public String generateEqualsString(GenerationContext generationContext, DataObject dataObject) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("currentDataObject", dataObject); return generateSubTemplateString(generationContext, "java_equals2"); }
public String generateAllFieldsConstructorString(GenerationContext generationContext, DataObject dataObject) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("currentDataObject", dataObject); return generateSubTemplateString(generationContext, "java_allfields_constructor"); }
public String generateKeyFieldsConstructorString(GenerationContext generationContext, DataObject dataObject) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("currentDataObject", dataObject); return generateSubTemplateString(generationContext, "java_keyfields_constructor"); }
public String generateAnnotationString(GenerationContext generationContext, Annotation annotation) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("annotation", annotation); return generateSubTemplateString(generationContext, "java_annotation"); }
public String generateHashCodeString(GenerationContext generationContext, DataObject dataObject) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("currentDataObject", dataObject); return generateSubTemplateString(generationContext, "java_hashCode2"); }
public String generatePositionFieldsConstructorString(GenerationContext generationContext, DataObject dataObject) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("currentDataObject", dataObject); return generateSubTemplateString(generationContext, "java_positionfields_constructor"); }
public String generateNestedClassString(GenerationContext generationContext, JavaClass javaClass) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("attr", javaClass); return generateSubTemplateString(generationContext, "java_nested_class"); }
public String generateFieldGetterString(GenerationContext generationContext, ObjectProperty attribute) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("attr", attribute); return generateSubTemplateString(generationContext, "java_getter"); }
public String generateMethodString(GenerationContext generationContext, Method method) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("attr", method); return generateSubTemplateString(generationContext, "java_method"); }
public String generateFieldString(GenerationContext generationContext, ObjectProperty attribute) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("attr", attribute); return generateSubTemplateString(generationContext, "java_attribute_2"); }
public String generateFieldSetterString(GenerationContext generationContext, ObjectProperty attribute) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("attr", attribute); return generateSubTemplateString(generationContext, "java_setter"); }
/** * Generate the complete java class code */ // TODO indentation public String generateJavaClassString(GenerationContext generationContext, DataObject dataObject) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("currentDataObject", dataObject); return generateSubTemplateString(generationContext, "java_class2"); }
/** * Runs the code adf. * * @param generationContext Context information for the adf. * * @throws Exception * */ public void generate(GenerationContext generationContext) throws Exception { VelocityContext context = buildContext(generationContext); String templatesPath = generationContext.getTemplatesPath(); String initialTemplate = generationContext.getInitialTemplate(); if (logger.isDebugEnabled()) { logger.debug("Starting code adf with templatesPath: " + templatesPath + ", initialTemplate: " + initialTemplate); } // Always start by the initial template String templatePath = getFullVelocityPath(templatesPath, initialTemplate); if (logger.isDebugEnabled()) logger.debug("Initial templatePath: " + templatePath); StringWriter writer = new StringWriter(); Template t = velocityEngine.getTemplate(templatePath); t.merge(context, writer); }
/** * Generate all annotations for a specific element (field, class, or method) */ public String generateAllAnnotationsString(GenerationContext generationContext, HasAnnotations hasAnnotations, String indent) throws Exception { VelocityContext vc = buildContext(generationContext); StringBuilder sb = new StringBuilder(); List<Annotation> annotations = ( (GenerationTools) vc.get( "nameTool" ) ).sortedAnnotations( hasAnnotations ); boolean isFirst = true; for ( Annotation a : annotations) { if (!isFirst) { sb.append( GenerationTools.EOL ); } isFirst = false; sb.append( generateAnnotationString( generationContext, a ) ); } return indentLines( sb.toString(), indent ); }
VelocityContext context = buildContext(generationContext);