Class HrefService

java.lang.Object
com.adobe.xfa.service.Service
com.adobe.xfa.service.href.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 final int
    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(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

    Modifier and Type
    Method
    Description
    final void
    Clears the cache.
    final String
    Gets the alternate URL that relative hrefs will be resolved against.
    final String
    Gets the base URL that relative hrefs will be resolved against.
    final int
    Gets the size of the cache in bytes.
    final String
    Gets the configuration schema name associated with this service.
    final Node
    Gets the context node associated with this service.
    final int
    Gets the current size of the cache in bytes.
    Gets the TemplateModel associated with the given AppModel.
    final boolean
    Get the trustiness of absolute URLs.
    final void
    isTrusted(boolean bTrusted)
    Sets the trustiness of absolute urls.
    loadFragment(AppModel appModel, String sUrl)
    Resolves a URL and loads the reference XFA document into a new AppModel.
    loadFragment(ProtoableNode protoableNode)
    Resolves the usehref attribute in the given ProtoableNode and loads the referenced document into a new AppModel.
    final void
    Sets the alternate URL that relative hrefs will be resolved against.
    final void
    setBaseUrl(String sBaseUrl)
    Sets the base URL that relative hrefs will be resolved against.
    final void
    setContextNode(Node contextNode)
    Sets the context node associated with this service.

    Methods inherited from class com.adobe.xfa.service.Service

    setOption

    Methods inherited from class java.lang.Object

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

    • CACHE_SIZE

      public static final int CACHE_SIZE
      The default cache size, in bytes.
      See Also:
  • Constructor Details

    • 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(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 Details

    • getContextNode

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

      public final 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, 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 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(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 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(String sAltUrl)
      Sets the alternate URL that relative hrefs will be resolved against.
      Parameters:
      sAltUrl - a URL to resolve relative hrefs against.