Class STCodeGenerator

    • 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_RENDERERS  
      static org.antlr.stringtemplate.StringTemplateErrorListener ERROR_LISTENER  
      static int errorCount  
      static java.util.regex.Pattern FORMAT_DELIM  
      static org.antlr.stringtemplate.CommonGroupLoader GROUP_LOADER  
      protected java.lang.String id  
      static org.antlr.stringtemplate.AttributeRenderer STRING_ATTRIBUTE_RENDERER  
      static java.lang.String TEMPLATE_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.String chainedFormat​(java.lang.String str, java.lang.String[] formats)
      Formats the string n times.
      protected void collect​(ProtoModule module, Proto proto, java.util.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 java.lang.String format​(java.lang.String str, java.lang.String formatName)
      Formats the string str using the format formatName.
      java.lang.String getOutputId()
      The unique id that basically is the target output.
      static org.antlr.stringtemplate.StringTemplate getST​(java.lang.String groupName, java.lang.String name)  
      static org.antlr.stringtemplate.StringTemplateGroup getSTG​(java.lang.String groupName)  
      protected static boolean override​(ProtoModule module, Proto proto)  
      protected static Proto parseProto​(java.io.File file, ProtoModule module)  
      protected static void postCompile​(ProtoModule module, Proto proto)  
      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.
      static boolean setFormatter​(java.lang.String name, Formatter f)
      Returns true if there was no previous formatter with the same name.
      static void setGroupLoader​(org.antlr.stringtemplate.StringTemplateGroupLoader loader)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • 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
    • Constructor Detail

      • STCodeGenerator

        public STCodeGenerator​(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 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​(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: ProtoCompiler
        The unique id that basically is the target output.
        Specified by:
        getOutputId in interface ProtoCompiler
      • compile

        public void compile​(ProtoModule module)
                     throws java.io.IOException
        Description copied from interface: ProtoCompiler
        Compiles the proto configured/encapsulated in the module.
        Specified by:
        compile in interface ProtoCompiler
        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