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
Base class for code generators using StringTemplate.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static org.antlr.stringtemplate.StringTemplateGroupLoader
(package private) static final ConcurrentHashMap
<String, Formatter> (package private) static final ConcurrentHashMap
<Class<?>, org.antlr.stringtemplate.AttributeRenderer> static final org.antlr.stringtemplate.StringTemplateErrorListener
static int
static final Pattern
static final org.antlr.stringtemplate.CommonGroupLoader
protected final String
static final org.antlr.stringtemplate.AttributeRenderer
static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
chainedFormat
(String str, String[] formats) Formats the string n times.protected void
collect
(ProtoModule module, Proto proto, List<Proto> overridden, boolean compile) void
compile
(ProtoModule module) Compiles the proto configured/encapsulated in the module.protected abstract void
compile
(ProtoModule module, Proto proto) protected void
compile
(ProtoModule module, Proto proto, boolean compileImports, boolean recursive) static String
Formats the stringstr
using the formatformatName
.The unique id that basically is the target output.static org.antlr.stringtemplate.StringTemplate
static org.antlr.stringtemplate.StringTemplateGroup
protected static boolean
override
(ProtoModule module, Proto proto) protected static Proto
parseProto
(File file, ProtoModule module) protected static void
postCompile
(ProtoModule module, Proto proto) static boolean
setAttributeRenderer
(Class<?> typeClass, org.antlr.stringtemplate.AttributeRenderer ar) Returns true if there was no previous attribute renderer with the same class.static boolean
setFormatter
(String name, Formatter f) Returns true if there was no previous formatter with the same name.static void
setGroupLoader
(org.antlr.stringtemplate.StringTemplateGroupLoader loader)
-
Field Details
-
TEMPLATE_BASE
- See Also:
-
FORMAT_DELIM
-
DEFAULT_RENDERERS
static final ConcurrentHashMap<Class<?>,org.antlr.stringtemplate.AttributeRenderer> DEFAULT_RENDERERS -
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
-
-
Constructor Details
-
STCodeGenerator
-
-
Method Details
-
chainedFormat
Formats the string n times.For example: input = "some_foo" formatters = ["PCS", "UPPER"] Output: 1st pass: "Some Foo" 2nd pass: "SOME FOO"
-
format
Formats the stringstr
using 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(Class<?> typeClass, org.antlr.stringtemplate.AttributeRenderer ar) Returns true if there was no previous attribute renderer with the same class. -
setFormatter
Returns true if there was no previous formatter with the same name. -
getSTG
-
getST
-
setGroupLoader
public static void setGroupLoader(org.antlr.stringtemplate.StringTemplateGroupLoader loader) -
getOutputId
Description copied from interface:ProtoCompiler
The unique id that basically is the target output.- Specified by:
getOutputId
in interfaceProtoCompiler
-
compile
Description copied from interface:ProtoCompiler
Compiles the proto configured/encapsulated in the module.- Specified by:
compile
in interfaceProtoCompiler
- Throws:
IOException
-
parseProto
-
compile
protected void compile(ProtoModule module, Proto proto, boolean compileImports, boolean recursive) throws IOException - Throws:
IOException
-
collect
protected void collect(ProtoModule module, Proto proto, List<Proto> overridden, boolean compile) throws IOException - Throws:
IOException
-
override
-
postCompile
-
compile
- Throws:
IOException
-