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 Object implements ProtoCompiler
Base class for code generators using StringTemplate.
  • Field Details

    • TEMPLATE_BASE

      public static final String TEMPLATE_BASE
      See Also:
    • FORMAT_DELIM

      public static final Pattern FORMAT_DELIM
    • DEFAULT_RENDERERS

      static final ConcurrentHashMap<Class<?>,org.antlr.stringtemplate.AttributeRenderer> DEFAULT_RENDERERS
    • DEFAULT_FORMATTERS

      static final ConcurrentHashMap<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 String id
  • Constructor Details

    • STCodeGenerator

      public STCodeGenerator(String id)
  • Method Details

    • chainedFormat

      public static String chainedFormat(String str, 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 String format(String str, String formatName)
      Formats the string str using the format formatName.

      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

      public static boolean setFormatter(String name, Formatter f)
      Returns true if there was no previous formatter with the same name.
    • getSTG

      public static org.antlr.stringtemplate.StringTemplateGroup getSTG(String groupName)
    • getST

      public static org.antlr.stringtemplate.StringTemplate getST(String groupName, String name)
    • setGroupLoader

      public static void setGroupLoader(org.antlr.stringtemplate.StringTemplateGroupLoader loader)
    • getOutputId

      public String getOutputId()
      Description copied from interface: ProtoCompiler
      The unique id that basically is the target output.
      Specified by:
      getOutputId in interface ProtoCompiler
    • compile

      public void compile(ProtoModule module) throws IOException
      Description copied from interface: ProtoCompiler
      Compiles the proto configured/encapsulated in the module.
      Specified by:
      compile in interface ProtoCompiler
      Throws:
      IOException
    • parseProto

      protected static Proto parseProto(File file, ProtoModule module)
    • 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

      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 IOException
      Throws:
      IOException