Class Page

java.lang.Object
org.knime.core.webui.page.Page
All Implemented Interfaces:
Resource

public final class Page extends Object implements Resource
A (html) page of an ui-extension, e.g. a node view, port view or node dialog.
Since:
4.5
Author:
Martin Horn, KNIME GmbH, Konstanz, Germany
  • Method Details

    • getResource

      public Optional<Resource> getResource(String relativePath)
      Additional resources required by the page.
      Parameters:
      relativePath - the relative path to get the resource for
      Returns:
      the resource for the given relative path or an empty optional if there isn't any
    • getRelativePath

      public String getRelativePath()
      Specified by:
      getRelativePath in interface Resource
      Returns:
      the resource's relative path (including the resource name itself, too)
    • getInputStream

      public InputStream getInputStream() throws IOException
      Specified by:
      getInputStream in interface Resource
      Returns:
      the actual resource content as InputStream
      Throws:
      IOException
    • isStatic

      public boolean isStatic()
      A static resource will never change at runtime and thus potentially be 're-used' between, e.g., multiple node instances. I.e. multiple node instances access a static resource at the very same URL which is independent from a specific node instance.
      Specified by:
      isStatic in interface Resource
      Returns:
      true if the resource is static and won't ever change at runtime, otherwise false
    • isCompletelyStatic

      public boolean isCompletelyStatic()
      A page is regarded completely static if the page itself and all associated resources are static.
      Returns:
      true if the page itself and all the associated resources are static (i.e. invariable)
    • getPageIdForReusablePage

      public Optional<String> getPageIdForReusablePage()
      Creates the page id for a re-usuable and completely static page. Will only return a page-id if the page is marked as re-usable (see FromFilePageBuilder.markAsReusable(String)).
      Returns:
      the page-id or an empty optional if the page is not marked as re-usable
      Throws:
      IllegalStateException - if the page is marked as re-usable but not completely static (see isCompletelyStatic()); or if 're-usability' is not supported for the page's Resource.ContentType.
    • getContentType

      public Resource.ContentType getContentType()
      Specified by:
      getContentType in interface Resource
      Returns:
      the content type of the resource
    • getCharset

      public Optional<Charset> getCharset()
      Specified by:
      getCharset in interface Resource
      Returns:
      the charset the resource uses; an empty optional if it's not a text-based resource or if it's using the default charset (i.e. Charset.defaultCharset()).
    • builder

      public static FromFilePageBuilder builder(Class<?> clazz, String basePath, String relativeFilePath)
      Creates a PageBuilder-instance to create a (static) page (and associated resources) from files.
      Parameters:
      clazz - a class which is part of the bundle where the references files are located
      basePath - the base part (beneath the bundle root)
      relativeFilePath - the file to get the page content from
      Returns:
      a new PageBuilder-instance
    • builder

      public static FromFilePageBuilder builder(String bundleID, String basePath, String relativeFilePath)
      Creates a PageBuilder-instance to create a (static) page (and associated resources) from files.
      Parameters:
      bundleID - the id of the bundle where the references files are located
      basePath - the base part (beneath the bundle root)
      relativeFilePath - the file to get the page content from
      Returns:
      a new PageBuilder-instance
    • builder

      public static PageBuilder builder(Page.InputStreamSupplier content, String relativePath)
      Creates a PageBuilder-instance to create a (dynamic) page (and associated resources) from an InputStream.
      Parameters:
      content - the page content supplier for lazy initialization
      relativePath - the relative path of the page (including the page resource name itself)
      Returns:
      a new PageBuilder-instance
    • builder

      public static PageBuilder builder(Page.StringSupplier content, String relativePath)
      Creates a PageBuilder-instance to create a (dynamic) page (and associated resources) from an InputStream.
      Parameters:
      content - the page content supplier for lazy initialization
      relativePath - the relative path of the page (including the page resource name itself)
      Returns:
      a new PageBuilder-instance