Class HrefService

  • All Implemented Interfaces:
    HrefHandler

    public class HrefService
    extends Service
    implements HrefHandler
    A class to handle all href related actions in an XFA based form.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int CACHE_SIZE
      The default cache size, in bytes.
    • Constructor Summary

      Constructors 
      Constructor Description
      HrefService​(Node contextNode, int nHrefCacheSize)
      Instantiates a new HrefService using a specified contextNode as the context for resolving relative references.
      HrefService​(java.lang.String sConfigSchemaName, int nHrefCacheSize)
      Instantiates a new HrefService using the configuration to determine the node that will service as the context for resolving relative references.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearCache()
      Clears the cache.
      java.lang.String getAlternativeUrl()
      Gets the alternate URL that relative hrefs will be resolved against.
      java.lang.String getBaseUrl()
      Gets the base URL that relative hrefs will be resolved against.
      int getCacheSize()
      Gets the size of the cache in bytes.
      java.lang.String getConfigSchemaName()
      Gets the configuration schema name associated with this service.
      Node getContextNode()
      Gets the context node associated with this service.
      int getCurrentCacheSize()
      Gets the current size of the cache in bytes.
      Model getDocument​(AppModel appModel)
      Gets the TemplateModel associated with the given AppModel.
      boolean isTrusted()
      Get the trustiness of absolute URLs.
      void isTrusted​(boolean bTrusted)
      Sets the trustiness of absolute urls.
      AppModel loadFragment​(AppModel appModel, java.lang.String sUrl)
      Resolves a URL and loads the reference XFA document into a new AppModel.
      AppModel loadFragment​(ProtoableNode protoableNode)
      Resolves the usehref attribute in the given ProtoableNode and loads the referenced document into a new AppModel.
      void setAlternativeUrl​(java.lang.String sAltUrl)
      Sets the alternate URL that relative hrefs will be resolved against.
      void setBaseUrl​(java.lang.String sBaseUrl)
      Sets the base URL that relative hrefs will be resolved against.
      void setContextNode​(Node contextNode)
      Sets the context node associated with this service.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CACHE_SIZE

        public static final int CACHE_SIZE
        The default cache size, in bytes.
        See Also:
        Constant Field Values
    • Constructor Detail

      • HrefService

        public HrefService​(Node contextNode,
                           int nHrefCacheSize)
        Instantiates a new HrefService using a specified contextNode as the context for resolving relative references.
        Parameters:
        contextNode - the context node for resolving relative references.
        nHrefCacheSize - the maximum size of the cache of URL bytes. If negative, no caching is done. If zero, CACHE_SIZE is used.
      • HrefService

        public HrefService​(java.lang.String sConfigSchemaName,
                           int nHrefCacheSize)
        Instantiates a new HrefService using the configuration to determine the node that will service as the context for resolving relative references.
        Parameters:
        sConfigSchemaName - the name of the configuration element containing the template.base and template.uri elements that describe how relative references are to be resolved.
        nHrefCacheSize - the maximum size of the cache of URL bytes. If negative, no caching is done. If zero, CACHE_SIZE is used.
    • Method Detail

      • getContextNode

        public final Node getContextNode()
        Gets the context node associated with this service.
        Returns:
        the context node associated with this service.
      • getConfigSchemaName

        public final java.lang.String getConfigSchemaName()
        Gets the configuration schema name associated with this service.
        Returns:
        the configuration schema name associated with this service.
      • setContextNode

        public final void setContextNode​(Node contextNode)
        Sets the context node associated with this service.
        Parameters:
        contextNode - the context node.
      • isTrusted

        public final boolean isTrusted()
        Get the trustiness of absolute URLs.
        Returns:
        the trustiness. When true, absolute hrefs are allowed.
      • isTrusted

        public final void isTrusted​(boolean bTrusted)
        Sets the trustiness of absolute urls. Trust implies that absolute hrefs are allowed.
        Parameters:
        bTrusted - allow absolute URLs when true.
      • getCacheSize

        public final int getCacheSize()
        Gets the size of the cache in bytes.
        Returns:
        the size of the cache in bytes.
      • clearCache

        public final void clearCache()
        Clears the cache. Removes all hrefs from the cache.
      • getCurrentCacheSize

        public final int getCurrentCacheSize()
        Gets the current size of the cache in bytes.
        Returns:
        the current size of the cache in bytes.
      • loadFragment

        public AppModel loadFragment​(ProtoableNode protoableNode)
        Resolves the usehref attribute in the given ProtoableNode and loads the referenced document into a new AppModel. Any fragment identifier in the URL is ignored.
        Specified by:
        loadFragment in interface HrefHandler
        Parameters:
        protoableNode - a ProtoableNode with a usehref attribute.
        Returns:
        the newly created AppModel containing the document loaded from the referenced location, or null upon error.
      • loadFragment

        public AppModel loadFragment​(AppModel appModel,
                                     java.lang.String sUrl)
        Resolves a URL and loads the reference XFA document into a new AppModel. Any fragment identifier in the URL is ignored.
        Specified by:
        loadFragment in interface HrefHandler
        Parameters:
        appModel - the AppModel containing the URL
        sUrl - the URL that references the external XFA document
        Returns:
        the newly created AppModel containing the document loaded from the referenced location.
      • getDocument

        public Model getDocument​(AppModel appModel)
        Gets the TemplateModel associated with the given AppModel.
        Specified by:
        getDocument in interface HrefHandler
        Parameters:
        appModel - an AppModel
        Returns:
        the TemplateModel from appModel or null if there is no TemplateModel.
      • getBaseUrl

        public final java.lang.String getBaseUrl()
        Gets the base URL that relative hrefs will be resolved against.
        Returns:
        a URL to resolve relative hrefs against.
      • setBaseUrl

        public final void setBaseUrl​(java.lang.String sBaseUrl)
        Sets the base URL that relative hrefs will be resolved against.
        Parameters:
        sBaseUrl - a URL to resolve relative hrefs against.
      • getAlternativeUrl

        public final java.lang.String getAlternativeUrl()
        Gets the alternate URL that relative hrefs will be resolved against.
        Returns:
        a URL to resolve relative hrefs against.
      • setAlternativeUrl

        public final void setAlternativeUrl​(java.lang.String sAltUrl)
        Sets the alternate URL that relative hrefs will be resolved against.
        Parameters:
        sAltUrl - a URL to resolve relative hrefs against.