Class Guise


  • public final class Guise
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String GUISE_ASSETS_BASE_KEY
      The base key to Guise assets bundled in the Guise distributable.
      static java.lang.String GUISE_NAME
      The name of Guise.
      static java.net.URI GUISE_WEB_URI
      The web address of Guise.
      static java.net.URI NAMESPACE
      The URI to the Guise ontology namespace.
      static java.lang.String NAMESPACE_PREFIX
      The recommended prefix to the Guise ontology namespace.
      static java.net.URI THEME_URI_PROPERTY_TAG
      The property indicating the URI of the theme of a resource.
    • Field Detail

      • GUISE_NAME

        public static final java.lang.String GUISE_NAME
        The name of Guise.
        See Also:
        Constant Field Values
      • GUISE_WEB_URI

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

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

        public static final java.lang.String NAMESPACE_PREFIX
        The recommended prefix to the Guise ontology namespace.
        See Also:
        Constant Field Values
      • NAMESPACE

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

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

      • getVersion

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

        public static com.globalmentor.iso.datetime.ISODate 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​(java.lang.String guiseAssetKey)
                             throws java.io.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:
        java.lang.IllegalArgumentException - if the asset key does not begin with "assets/".
        java.io.IOException - if there is an error loading the asset.
        See Also:
        GUISE_ASSETS_BASE_KEY
      • hasAsset

        public boolean hasAsset​(java.lang.String guiseAssetKey)
                         throws java.io.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:
        java.lang.IllegalArgumentException - if the asset key does not begin with "assets/".
        java.io.IOException - if there is an error accessing the asset.
        See Also:
        GUISE_ASSETS_BASE_KEY
      • getAssetURL

        public java.net.URL getAssetURL​(java.lang.String guiseAssetKey)
                                 throws java.io.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:
        java.lang.IllegalArgumentException - if the asset key does not begin with "assets/".
        java.io.IOException - if there is an error loading the asset.
        See Also:
        GUISE_ASSETS_BASE_KEY
      • getAssetInputStream

        public java.io.InputStream getAssetInputStream​(java.lang.String guiseAssetKey)
                                                throws java.io.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:
        java.lang.IllegalArgumentException - if the asset key does not begin with "assets/".
        java.io.IOException - if there is an error loading the asset.
        See Also:
        GUISE_ASSETS_BASE_KEY
      • 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:
        java.lang.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:
        java.lang.IllegalStateException - if the current thread is not associated with any Guise session.