Class STGroupDir

java.lang.Object
org.stringtemplate.v4.STGroup
org.stringtemplate.v4.STGroupDir
Direct Known Subclasses:
STRawGroupDir

public class STGroupDir extends STGroup
A directory or directory tree full of templates and/or group files. We load files on-demand. Dir search path: current working dir then CLASSPATH (as a resource). Do not look for templates outside of this dir subtree (except via imports).
  • Field Details

    • groupDirName

      public String groupDirName
    • root

      public URL root
  • Constructor Details

    • STGroupDir

      public STGroupDir(String dirName)
    • STGroupDir

      public STGroupDir(URL root)
    • STGroupDir

      public STGroupDir(String dirName, char delimiterStartChar, char delimiterStopChar)
    • STGroupDir

      public STGroupDir(String dirName, String encoding)
    • STGroupDir

      public STGroupDir(String dirName, String encoding, char delimiterStartChar, char delimiterStopChar)
    • STGroupDir

      public STGroupDir(URL root, String encoding, char delimiterStartChar, char delimiterStopChar)
  • Method Details

    • importTemplates

      public void importTemplates(org.antlr.runtime.Token fileNameToken)
      Description copied from class: STGroup
      Import template files, directories, and group files. Priority is given to templates defined in the current group; this, in effect, provides inheritance. Polymorphism is in effect so that if an inherited template references template t() then we search for t() in the subgroup first.

      Templates are loaded on-demand from import dirs. Imported groups are loaded on-demand when searching for a template.

      The listener of this group is passed to the import group so errors found while loading imported element are sent to listener of this group.

      On unload imported templates are unloaded and removed from the imports list.

      This method is called when processing import statements specified in group files. Use STGroup.importTemplates(STGroup) to import templates 'programmatically'.

      Overrides:
      importTemplates in class STGroup
    • load

      protected CompiledST load(String name)
      Load a template from directory or group file. Group file is given precedence over directory with same name. name is always fully-qualified.
      Overrides:
      load in class STGroup
    • loadTemplateFile

      public CompiledST loadTemplateFile(String prefix, String unqualifiedFileName)
      Load .st as relative file name relative to root by prefix.
    • getName

      public String getName()
      Overrides:
      getName in class STGroup
    • getFileName

      public String getFileName()
      Overrides:
      getFileName in class STGroup
    • getRootDirURL

      public URL getRootDirURL()
      Description copied from class: STGroup
      Return root dir if this is group dir; return dir containing group file if this is group file. This is derived from original incoming dir or filename. If it was absolute, this should come back as full absolute path. If only a URL is available, return URL of one dir up.
      Overrides:
      getRootDirURL in class STGroup
    • normalizeURL

      public URL normalizeURL(URL url)
      verify there is no extra slash on the end of URL