Class BaseScriptingEnvironment

java.lang.Object
org.apache.batik.bridge.BaseScriptingEnvironment
Direct Known Subclasses:
ScriptingEnvironment

public class BaseScriptingEnvironment extends Object
This class is the base class for SVG scripting.
Version:
$Id: BaseScriptingEnvironment.java 1851346 2019-01-15 13:41:00Z ssteiner $
  • Field Details

    • INLINE_SCRIPT_DESCRIPTION

      public static final String INLINE_SCRIPT_DESCRIPTION
      Constant used to describe inline scripts.
       {0} - URL of document containing script.
       {1} - Element tag
       {2} - line number of element.
       
      See Also:
    • EVENT_SCRIPT_DESCRIPTION

      public static final String EVENT_SCRIPT_DESCRIPTION
      Constant used to describe inline scripts.
       {0} - URL of document containing script.
       {1} - Event attribute name
       {2} - line number of element.
       
      See Also:
    • EVENT_NAME

      protected static final String EVENT_NAME
      See Also:
    • ALTERNATE_EVENT_NAME

      protected static final String ALTERNATE_EVENT_NAME
      See Also:
    • APPLICATION_ECMASCRIPT

      protected static final String APPLICATION_ECMASCRIPT
      The 'application/ecmascript' MIME type.
      See Also:
    • bridgeContext

      protected BridgeContext bridgeContext
      The bridge context.
    • userAgent

      protected UserAgent userAgent
      The user-agent.
    • document

      protected Document document
      The document to manage.
    • docPURL

      protected ParsedURL docPURL
      The URL of the document ot manage
    • languages

      protected Set languages
    • interpreter

      protected Interpreter interpreter
      The default Interpreter for the document
    • windowObjects

      protected Map windowObjects
      Map of Interpreter to Window objects.
    • executedScripts

      protected WeakHashMap executedScripts
      Set of <script> elements that have already been executed.
  • Constructor Details

    • BaseScriptingEnvironment

      public BaseScriptingEnvironment(BridgeContext ctx)
      Creates a new BaseScriptingEnvironment.
      Parameters:
      ctx - the bridge context
  • Method Details

    • isDynamicDocument

      public static boolean isDynamicDocument(BridgeContext ctx, Document doc)
      Tells whether the given SVG document is dynamic.
    • isDynamicElement

      public static boolean isDynamicElement(BridgeContext ctx, Element elt)
    • isDynamicElement

      public static boolean isDynamicElement(Element elt, BridgeContext ctx, List bridgeExtensions)
      Tells whether the given SVG element is dynamic.
    • getWindow

      public Window getWindow(Interpreter interp, String lang)
      Returns the Window object for the specified Interpreter.
    • getWindow

      public Window getWindow()
      Returns the Window object for scripting languages that have no Interpreter object.
    • createWindow

      protected Window createWindow(Interpreter interp, String lang)
      Creates a new Window object.
    • getInterpreter

      public Interpreter getInterpreter()
      Returns the default Interpreter for this document.
    • getInterpreter

      public Interpreter getInterpreter(String lang)
    • initializeEnvironment

      public void initializeEnvironment(Interpreter interp, String lang)
      Initializes the environment of the given interpreter.
    • loadScripts

      public void loadScripts()
      Loads the scripts contained in the <script> elements.
    • loadScript

      protected void loadScript(AbstractElement script)
      Executes the specified <script> element, if it hasn't been executed already.
    • checkCompatibleScriptURL

      protected void checkCompatibleScriptURL(String scriptType, ParsedURL scriptPURL)
      Checks that the script URLs and the document url are compatible. A SecurityException is thrown if loading the script is not allowed.
    • dispatchSVGLoadEvent

      public void dispatchSVGLoadEvent()
      Recursively dispatch the SVG 'onload' event.
    • dispatchSVGLoad

      protected void dispatchSVGLoad(Element elt, boolean checkCanRun, String lang)
      Auxiliary method for dispatchSVGLoad.
    • dispatchSVGZoomEvent

      protected void dispatchSVGZoomEvent()
      Method to dispatch SVG Zoom event.
    • dispatchSVGScrollEvent

      protected void dispatchSVGScrollEvent()
      Method to dispatch SVG Scroll event.
    • dispatchSVGResizeEvent

      protected void dispatchSVGResizeEvent()
      Method to dispatch SVG Resize event.
    • dispatchSVGDocEvent

      protected void dispatchSVGDocEvent(String eventType)
    • handleInterpreterException

      protected void handleInterpreterException(InterpreterException ie)
      Handles the given exception.
    • handleSecurityException

      protected void handleSecurityException(SecurityException se)
      Handles the given exception.