Class Resources

Object
Resources

public class Resources extends Object
Accesses resource-files associated with this application.

When specifying paths to resources, one should avoid a leading / on the resource path as it uses a ClassLoader to load resources, which is different behavior to getClass().getResourceAsStream().

Author:
Owen Feehan
  • Constructor Details

    • Resources

      public Resources(ClassLoader classLoader, String pathVersionFooter, String pathMavenProperties, String pathUsageHeader, String pathUsageFooter, Optional<String> pathTasksFooter)
      Creates a new Resources instance.
      Parameters:
      classLoader - Which class-loader to use for loading resources.
      pathVersionFooter - Path to the footer-message that accompanies a version message.
      pathMavenProperties - Path to the maven-properties file (from which a version can be extracted).
      pathUsageHeader - Path to the header-message that describes usage.
      pathUsageFooter - Path to the footer-message that describes usage.
      pathTasksFooter - Path to the footer-message used after "show tasks"
  • Method Details

    • usageHeader

      public String usageHeader()
      Header-message that describes usage.
      Returns:
      the message
    • usageFooter

      public String usageFooter()
      Footer-message that describes usage.
      Returns:
      the message
    • tasksFooter

      public String tasksFooter()
      Footer-message used after "show tasks".
      Returns:
      the message if it exists, or else an empty string.
    • versionFooter

      public String versionFooter()
      Footer-message that accompanies a version message, if it exists.
      Returns:
      the message
    • versionFromMavenProperties

      public String versionFromMavenProperties() throws IOException
      Gets the current version of the software by reading a properties-file provided by the Maven build

      NOTE that this pom.proper

      Returns:
      string describing the current version number of anchor-launcher
      Throws:
      IOException - if the properties file cannot be read, or is missing the appropriate version key