Class STGroupFile

java.lang.Object
org.stringtemplate.v4.STGroup
org.stringtemplate.v4.STGroupFile

public class STGroupFile extends STGroup
The internal representation of a single group file (which must end in ".stg"). If we fail to find a group file, look for it via the CLASSPATH as a resource. Templates are only looked up in this file or an import.
  • Field Details

    • fileName

      public String fileName
      Just records how user "spelled" the file name they wanted to load. The url is the key field here for loading content. If they use ctor with URL arg, this field is null.
    • url

      public URL url
      Where to find the group file. NonNull.
    • alreadyLoaded

      protected boolean alreadyLoaded
  • Constructor Details

    • STGroupFile

      public STGroupFile(String fileName)
      Load a file relative to current directory or from root or via CLASSPATH.
    • STGroupFile

      public STGroupFile(String fileName, char delimiterStartChar, char delimiterStopChar)
    • STGroupFile

      public STGroupFile(String fullyQualifiedFileName, String encoding)
    • STGroupFile

      public STGroupFile(String fullyQualifiedFileName, String encoding, char delimiterStartChar, char delimiterStopChar)
    • STGroupFile

      public STGroupFile(URL url, String encoding, char delimiterStartChar, char delimiterStopChar)
      Pass in a URL with the location of a group file. E.g., STGroup g = new STGroupFile(loader.getResource("org/foo/templates/g.stg"), "UTF-8", 'invalid input: '<'', '>');
    • STGroupFile

      public STGroupFile(URL url)
      Convenience ctor
  • Method Details

    • isDictionary

      public boolean isDictionary(String name)
      Overrides:
      isDictionary in class STGroup
    • isDefined

      public boolean isDefined(String name)
      Description copied from class: STGroup
      Is this template defined in this group or from this group below? Names must be absolute, fully-qualified names like /a/b.
      Overrides:
      isDefined in class STGroup
    • unload

      public void unload()
      Description copied from class: STGroup
      Unload all templates, dictionaries and import relationships, but leave renderers and adaptors. This essentially forces the next call to STGroup.getInstanceOf(java.lang.String) to reload templates. Call unload() on each group in the STGroup.imports list, and remove all elements in STGroup.importsToClearOnUnload from STGroup.imports.
      Overrides:
      unload in class STGroup
    • load

      protected CompiledST load(String name)
      Description copied from class: STGroup
      Load st from disk if directory or load whole group file if .stg file (then return just one template). name is fully-qualified.
      Overrides:
      load in class STGroup
    • load

      public void load()
      Description copied from class: STGroup
      Force a load if it makes sense for the group.
      Overrides:
      load in class STGroup
    • show

      public String show()
      Overrides:
      show in class STGroup
    • 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