Package io.protostuff.compiler
Class STCodeGenerator
- java.lang.Object
-
- io.protostuff.compiler.STCodeGenerator
-
- All Implemented Interfaces:
ProtoCompiler
- Direct Known Subclasses:
PluginProtoCompiler,ProtoToGwtOverlayCompiler,ProtoToJavaBeanCompiler,ProtoToJavaBeanMeCompiler,ProtoToJavaBeanModelCompiler,ProtoToJavaV2ProtocSchemaCompiler,ProtoToProtoCompiler
public abstract class STCodeGenerator extends java.lang.Object implements ProtoCompiler
Base class for code generators using StringTemplate.
-
-
Field Summary
Fields Modifier and Type Field Description private static org.antlr.stringtemplate.StringTemplateGroupLoader__loader(package private) static java.util.concurrent.ConcurrentHashMap<java.lang.String,Formatter>DEFAULT_FORMATTERS(package private) static java.util.concurrent.ConcurrentHashMap<java.lang.Class<?>,org.antlr.stringtemplate.AttributeRenderer>DEFAULT_RENDERERSstatic org.antlr.stringtemplate.StringTemplateErrorListenerERROR_LISTENERstatic interrorCountstatic java.util.regex.PatternFORMAT_DELIMstatic org.antlr.stringtemplate.CommonGroupLoaderGROUP_LOADERprotected java.lang.Stringidstatic org.antlr.stringtemplate.AttributeRendererSTRING_ATTRIBUTE_RENDERERstatic java.lang.StringTEMPLATE_BASE
-
Constructor Summary
Constructors Constructor Description STCodeGenerator(java.lang.String id)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static java.lang.StringchainedFormat(java.lang.String str, java.lang.String[] formats)Formats the string n times.protected voidcollect(ProtoModule module, Proto proto, java.util.List<Proto> overridden, boolean compile)voidcompile(ProtoModule module)Compiles the proto configured/encapsulated in the module.protected abstract voidcompile(ProtoModule module, Proto proto)protected voidcompile(ProtoModule module, Proto proto, boolean compileImports, boolean recursive)static java.lang.Stringformat(java.lang.String str, java.lang.String formatName)Formats the stringstrusing the formatformatName.java.lang.StringgetOutputId()The unique id that basically is the target output.static org.antlr.stringtemplate.StringTemplategetST(java.lang.String groupName, java.lang.String name)static org.antlr.stringtemplate.StringTemplateGroupgetSTG(java.lang.String groupName)protected static booleanoverride(ProtoModule module, Proto proto)protected static ProtoparseProto(java.io.File file, ProtoModule module)protected static voidpostCompile(ProtoModule module, Proto proto)static booleansetAttributeRenderer(java.lang.Class<?> typeClass, org.antlr.stringtemplate.AttributeRenderer ar)Returns true if there was no previous attribute renderer with the same class.static booleansetFormatter(java.lang.String name, Formatter f)Returns true if there was no previous formatter with the same name.static voidsetGroupLoader(org.antlr.stringtemplate.StringTemplateGroupLoader loader)
-
-
-
Field Detail
-
TEMPLATE_BASE
public static final java.lang.String TEMPLATE_BASE
- See Also:
- Constant Field Values
-
FORMAT_DELIM
public static final java.util.regex.Pattern FORMAT_DELIM
-
DEFAULT_RENDERERS
static final java.util.concurrent.ConcurrentHashMap<java.lang.Class<?>,org.antlr.stringtemplate.AttributeRenderer> DEFAULT_RENDERERS
-
DEFAULT_FORMATTERS
static final java.util.concurrent.ConcurrentHashMap<java.lang.String,Formatter> DEFAULT_FORMATTERS
-
errorCount
public static int errorCount
-
ERROR_LISTENER
public static final org.antlr.stringtemplate.StringTemplateErrorListener ERROR_LISTENER
-
GROUP_LOADER
public static final org.antlr.stringtemplate.CommonGroupLoader GROUP_LOADER
-
STRING_ATTRIBUTE_RENDERER
public static final org.antlr.stringtemplate.AttributeRenderer STRING_ATTRIBUTE_RENDERER
-
__loader
private static org.antlr.stringtemplate.StringTemplateGroupLoader __loader
-
id
protected final java.lang.String id
-
-
Method Detail
-
chainedFormat
public static java.lang.String chainedFormat(java.lang.String str, java.lang.String[] formats)Formats the string n times.For example: input = "some_foo" formatters = ["PCS", "UPPER"] Output: 1st pass: "Some Foo" 2nd pass: "SOME FOO"
-
format
public static java.lang.String format(java.lang.String str, java.lang.String formatName)Formats the stringstrusing the formatformatName.If the formatter with the name does not exist, the input string will be appended with the formatName.
-
setAttributeRenderer
public static boolean setAttributeRenderer(java.lang.Class<?> typeClass, org.antlr.stringtemplate.AttributeRenderer ar)Returns true if there was no previous attribute renderer with the same class.
-
setFormatter
public static boolean setFormatter(java.lang.String name, Formatter f)Returns true if there was no previous formatter with the same name.
-
getSTG
public static org.antlr.stringtemplate.StringTemplateGroup getSTG(java.lang.String groupName)
-
getST
public static org.antlr.stringtemplate.StringTemplate getST(java.lang.String groupName, java.lang.String name)
-
setGroupLoader
public static void setGroupLoader(org.antlr.stringtemplate.StringTemplateGroupLoader loader)
-
getOutputId
public java.lang.String getOutputId()
Description copied from interface:ProtoCompilerThe unique id that basically is the target output.- Specified by:
getOutputIdin interfaceProtoCompiler
-
compile
public void compile(ProtoModule module) throws java.io.IOException
Description copied from interface:ProtoCompilerCompiles the proto configured/encapsulated in the module.- Specified by:
compilein interfaceProtoCompiler- Throws:
java.io.IOException
-
parseProto
protected static Proto parseProto(java.io.File file, ProtoModule module)
-
compile
protected void compile(ProtoModule module, Proto proto, boolean compileImports, boolean recursive) throws java.io.IOException
- Throws:
java.io.IOException
-
collect
protected void collect(ProtoModule module, Proto proto, java.util.List<Proto> overridden, boolean compile) throws java.io.IOException
- Throws:
java.io.IOException
-
override
protected static boolean override(ProtoModule module, Proto proto)
-
postCompile
protected static void postCompile(ProtoModule module, Proto proto)
-
compile
protected abstract void compile(ProtoModule module, Proto proto) throws java.io.IOException
- Throws:
java.io.IOException
-
-