Package com.fizzed.rocker.compiler
Class JavaGenerator
- java.lang.Object
-
- com.fizzed.rocker.compiler.JavaGenerator
-
public class JavaGenerator extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private RockerConfigurationconfigurationstatic java.lang.StringCRLFprivate static org.slf4j.Loggerlogstatic intPLAIN_TEXT_CHUNK_LENGTHprivate PlainTextStrategyplainTextStrategystatic java.lang.StringTAB
-
Constructor Summary
Constructors Constructor Description JavaGenerator(RockerConfiguration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendArgumentMembers(TemplateModel model, java.io.Writer w, java.lang.String access, boolean finalModifier, int indent)voidappendCommentAndSourcePositionUpdate(java.io.Writer w, int tab, TemplateUnit unit)private voidcreateSourceTemplate(TemplateModel model, java.io.Writer w)java.io.Filegenerate(TemplateModel model)RockerConfigurationgetConfiguration()PlainTextStrategygetPlainTextStrategy()booleanisForIteratorType(java.lang.String type)private TemplateModelpostProcess(TemplateModel templateModel)Execute allTemplateModelPostProcessors as they were configured globally through Maven's pom.xml, and through a per-template option.voidsetPlainTextStrategy(PlainTextStrategy plainTextStrategy)java.lang.StringsourceRef(TemplateUnit unit)java.lang.StringsourceRefLineCommaPosInLine(TemplateUnit unit)java.io.Writertab(java.io.Writer w, int count)
-
-
-
Field Detail
-
log
private static final org.slf4j.Logger log
-
CRLF
public static final java.lang.String CRLF
- See Also:
- Constant Field Values
-
TAB
public static final java.lang.String TAB
- See Also:
- Constant Field Values
-
PLAIN_TEXT_CHUNK_LENGTH
public static final int PLAIN_TEXT_CHUNK_LENGTH
- See Also:
- Constant Field Values
-
configuration
private final RockerConfiguration configuration
-
plainTextStrategy
private PlainTextStrategy plainTextStrategy
-
-
Constructor Detail
-
JavaGenerator
public JavaGenerator(RockerConfiguration configuration)
-
-
Method Detail
-
getConfiguration
public RockerConfiguration getConfiguration()
-
getPlainTextStrategy
public PlainTextStrategy getPlainTextStrategy()
-
setPlainTextStrategy
public void setPlainTextStrategy(PlainTextStrategy plainTextStrategy)
-
generate
public java.io.File generate(TemplateModel model) throws GeneratorException, java.io.IOException
- Throws:
GeneratorExceptionjava.io.IOException
-
tab
public java.io.Writer tab(java.io.Writer w, int count) throws java.io.IOException- Throws:
java.io.IOException
-
sourceRef
public java.lang.String sourceRef(TemplateUnit unit)
-
sourceRefLineCommaPosInLine
public java.lang.String sourceRefLineCommaPosInLine(TemplateUnit unit)
-
appendCommentAndSourcePositionUpdate
public void appendCommentAndSourcePositionUpdate(java.io.Writer w, int tab, TemplateUnit unit) throws java.io.IOException- Throws:
java.io.IOException
-
isForIteratorType
public boolean isForIteratorType(java.lang.String type)
-
appendArgumentMembers
public void appendArgumentMembers(TemplateModel model, java.io.Writer w, java.lang.String access, boolean finalModifier, int indent) throws java.io.IOException
- Throws:
java.io.IOException
-
createSourceTemplate
private void createSourceTemplate(TemplateModel model, java.io.Writer w) throws GeneratorException, java.io.IOException
- Throws:
GeneratorExceptionjava.io.IOException
-
postProcess
private TemplateModel postProcess(TemplateModel templateModel) throws PostProcessorException
Execute allTemplateModelPostProcessors as they were configured globally through Maven's pom.xml, and through a per-template option. If both were given, execute the global post-processors first, and then the per-template post-processors. Generation of Java code will continue with the TemplateModel returned by the last post-processor in the chain.- Parameters:
templateModel- theTemplateModelto run the post-processing on.- Returns:
- a
TemplateModelwith all post-processing transformations applied. Only this resulting TemplateModel will be used for further Java-code generation. - Throws:
PostProcessorException- if a post-processor cannot be instantiated, or if any of the post-processors throws an exception during processing of the model.
-
-