Class Guise

java.lang.Object
io.guise.framework.Guise

public final class Guise extends Object
The singleton Guise class. There will only be one instance of Guise per JVM.

This class depends on a properties file resource.

Author:
Garret Wilson
  • Field Details

    • GUISE_NAME

      public static final String GUISE_NAME
      The name of Guise.
      See Also:
    • GUISE_WEB_URI

      public static final URI GUISE_WEB_URI
      The web address of Guise.
    • GUISE_ASSETS_BASE_KEY

      public static final String GUISE_ASSETS_BASE_KEY
      The base key to Guise assets bundled in the Guise distributable.
      See Also:
    • NAMESPACE_PREFIX

      public static final String NAMESPACE_PREFIX
      The recommended prefix to the Guise ontology namespace.
      See Also:
    • NAMESPACE

      public static final URI NAMESPACE
      The URI to the Guise ontology namespace.
    • THEME_URI_PROPERTY_TAG

      public static final URI THEME_URI_PROPERTY_TAG
      The property indicating the URI of the theme of a resource.
  • Method Details

    • getVersion

      public static String getVersion()
      Returns:
      The version of Guise.
    • getBuildDate

      public static LocalDate getBuildDate()
      Returns:
      The build date of Guise.
    • getInstance

      public static Guise getInstance()
      Returns:
      The singleton instance of Guise.
    • isLicensed

      public boolean isLicensed()
      Returns:
      Whether this deployment of Guise is licensed.
    • getGuiseAsset

      public byte[] getGuiseAsset(String guiseAssetKey) throws IOException
      Retrieves a Guise asset keyed to its location. Assets are cached for quick future retrieval. Due to race conditions, an asset may initially be loaded more than once in this implementation before its final value is placed in the cache.
      Parameters:
      guiseAssetKey - The location of the asset.
      Returns:
      The asset, or null if there is no such asset.
      Throws:
      IllegalArgumentException - if the asset key does not begin with "assets/".
      IOException - if there is an error loading the asset.
      See Also:
    • hasAsset

      public boolean hasAsset(String guiseAssetKey) throws IOException
      Determines if a specified Guise asset exists. This version delegates to getAssetURL(String).
      Parameters:
      guiseAssetKey - The location of the asset.
      Returns:
      true if the URL references an existing Guise asset, else false.
      Throws:
      IllegalArgumentException - if the asset key does not begin with "assets/".
      IOException - if there is an error accessing the asset.
      See Also:
    • getAssetURL

      public URL getAssetURL(String guiseAssetKey) throws IOException
      Retrieves a URL to a Guise asset keyed to its location. The URL allows connections to the asset. The returned URL represents internal access to the asset and should normally not be presented to users.
      Parameters:
      guiseAssetKey - The location of the asset.
      Returns:
      A URL to the asset, or null if there is no such asset.
      Throws:
      IllegalArgumentException - if the asset key does not begin with "assets/".
      IOException - if there is an error loading the asset.
      See Also:
    • getAssetInputStream

      public InputStream getAssetInputStream(String guiseAssetKey) throws IOException
      Retrieves an input stream to a Guise asset keyed to its location. This method will use cached assets if possible, but will not cache new assets.
      Parameters:
      guiseAssetKey - The location of the asset.
      Returns:
      An input stream to an asset, or null if there is no such asset.
      Throws:
      IllegalArgumentException - if the asset key does not begin with "assets/".
      IOException - if there is an error loading the asset.
      See Also:
    • getThreadGroup

      public final GuiseSessionThreadGroup getThreadGroup(GuiseSession guiseSession)
      Determines the thread group to use for the given session. This method must not be called for a session that has not yet been added.
      Parameters:
      guiseSession - The session for which a thread group is requested.
      Returns:
      The thread group to use for the given session.
      Throws:
      IllegalStateException - if the given session has not yet been associated with a thread group because it has not yet been added.
    • getGuiseSession

      public final GuiseSession getGuiseSession()
      Retrieves the Guise session information for the current thread. This method calls getGuiseSession(Thread) with the current thread.
      Returns:
      The Guise session for the current thread.
      Throws:
      IllegalStateException - if the current thread is not associated with any Guise session.