Interface Resource

All Known Implementing Classes:
FileResource, JarResource, StringCachingResource, StringResource

public interface Resource
Interface for accessing plugin resources in jar or plugin files.
  • Method Details

    • getResourceName

      String getResourceName()
      Get the name of this Resource.
      Returns:
      Relative file path given to PlanFiles.
    • asBytes

      byte[] asBytes() throws IOException
      Throws:
      IOException
    • asInputStream

      InputStream asInputStream() throws IOException
      Get the resource as an InputStream.
      Returns:
      InputStream of the resource, not closed automatically.
      Throws:
      IOException - If the resource is unavailable.
    • asLines

      List<String> asLines() throws IOException
      Get the resource as lines.
      Returns:
      Lines of the resource file.
      Throws:
      IOException - If the resource is unavailable.
    • asString

      String asString() throws IOException
      Get the resource as a String with each line separated by CRLF newline characters \r\n.
      Returns:
      Flat string with each line separated by \r\n.
      Throws:
      IOException - If the resource is unavailable.
    • asParsed

      default <T> T asParsed(com.google.gson.Gson gson, com.google.gson.reflect.TypeToken<T> token) throws IOException
      Throws:
      IOException
    • asWebResource

      default WebResource asWebResource()
      Map to a WebResource used by ResourceService APIs.
      Returns:
      The resource
      Throws:
      UncheckedIOException - if fails to read the file.
    • isTextResource

      static boolean isTextResource(String resourceName)
      Check if a resource is a text based file.
      Parameters:
      resourceName - Name of the resource
      Returns:
      true if the resource is text based.