Class DirectoryCodeResolver

java.lang.Object
gg.jte.resolve.DirectoryCodeResolver
All Implemented Interfaces:
CodeResolver

public class DirectoryCodeResolver extends Object implements CodeResolver
Resolves template code within a given root directory.
  • Field Details

    • root

      private final Path root
  • Constructor Details

    • DirectoryCodeResolver

      public DirectoryCodeResolver(Path root)
  • Method Details

    • resolve

      public String resolve(String name)
      Description copied from interface: CodeResolver
      Resolves the code of a template.
      Specified by:
      resolve in interface CodeResolver
      Parameters:
      name - The name of the template, e.g. "tag/util/card.jte".
      Returns:
      The code of the resolved template, or null if no template with this name exists.
    • resolveRequired

      public String resolveRequired(String name) throws TemplateNotFoundException
      Description copied from interface: CodeResolver
      Resolves the code of a template, which is required to exist.
      Specified by:
      resolveRequired in interface CodeResolver
      Parameters:
      name - The name of the template, e.g. "tag/util/card.jte".
      Returns:
      The code of the resolved template, this is never null.
      Throws:
      TemplateNotFoundException - if no template with this name exists. Implementations that have better knowledge why the loading failed, are expected to override this method and provide information about the problem in the thrown exception message.
    • exists

      public boolean exists(String name)
      Description copied from interface: CodeResolver
      Checks if a template with this name exists.
      Specified by:
      exists in interface CodeResolver
      Parameters:
      name - The name of the template, e.g. "tag/util/card.jte".
      Returns:
      true if a template with this name exists, otherwise false.
    • getLastModified

      public long getLastModified(String name)
      Description copied from interface: CodeResolver
      Resolves the last modification time of a template.
      Specified by:
      getLastModified in interface CodeResolver
      Parameters:
      name - The name of the template, e.g. "tag/util/card.jte".
      Returns:
      The last modification time of this template in milliseconds, or 0L if no template with this name exists. In case this CodeResolver does not support modification times 0L should be returned.
    • getLastModified

      private long getLastModified(Path file)
    • resolveAllTemplateNames

      public List<String> resolveAllTemplateNames()
      Description copied from interface: CodeResolver
      Resolves all template names this CodeResolver can resolve.
      Specified by:
      resolveAllTemplateNames in interface CodeResolver
      Returns:
      A list of all existing templates.
    • getRoot

      public Path getRoot()