Package org.apache.batik.bridge
Class BaseScriptingEnvironment
- java.lang.Object
-
- org.apache.batik.bridge.BaseScriptingEnvironment
-
- Direct Known Subclasses:
ScriptingEnvironment
public class BaseScriptingEnvironment extends java.lang.ObjectThis class is the base class for SVG scripting.- Version:
- $Id: BaseScriptingEnvironment.java 1851346 2019-01-15 13:41:00Z ssteiner $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classBaseScriptingEnvironment.WindowRepresents the window object of this environment.
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringALTERNATE_EVENT_NAMEprotected static java.lang.StringAPPLICATION_ECMASCRIPTThe 'application/ecmascript' MIME type.protected BridgeContextbridgeContextThe bridge context.protected ParsedURLdocPURLThe URL of the document ot manageprotected org.w3c.dom.DocumentdocumentThe document to manage.protected static java.lang.StringEVENT_NAMEstatic java.lang.StringEVENT_SCRIPT_DESCRIPTIONConstant used to describe inline scripts.protected java.util.WeakHashMapexecutedScriptsSet of <script> elements that have already been executed.static java.lang.StringINLINE_SCRIPT_DESCRIPTIONConstant used to describe inline scripts.protected InterpreterinterpreterThe default Interpreter for the documentprotected java.util.Setlanguagesprotected UserAgentuserAgentThe user-agent.protected java.util.MapwindowObjectsMap ofInterpretertoWindowobjects.
-
Constructor Summary
Constructors Constructor Description BaseScriptingEnvironment(BridgeContext ctx)Creates a new BaseScriptingEnvironment.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckCompatibleScriptURL(java.lang.String scriptType, ParsedURL scriptPURL)Checks that the script URLs and the document url are compatible.protected WindowcreateWindow(Interpreter interp, java.lang.String lang)Creates a new Window object.protected voiddispatchSVGDocEvent(java.lang.String eventType)protected voiddispatchSVGLoad(org.w3c.dom.Element elt, boolean checkCanRun, java.lang.String lang)Auxiliary method for dispatchSVGLoad.voiddispatchSVGLoadEvent()Recursively dispatch the SVG 'onload' event.protected voiddispatchSVGResizeEvent()Method to dispatch SVG Resize event.protected voiddispatchSVGScrollEvent()Method to dispatch SVG Scroll event.protected voiddispatchSVGZoomEvent()Method to dispatch SVG Zoom event.InterpretergetInterpreter()Returns the default Interpreter for this document.InterpretergetInterpreter(java.lang.String lang)WindowgetWindow()Returns the Window object for scripting languages that have noInterpreterobject.WindowgetWindow(Interpreter interp, java.lang.String lang)Returns the Window object for the specifiedInterpreter.protected voidhandleInterpreterException(InterpreterException ie)Handles the given exception.protected voidhandleSecurityException(java.lang.SecurityException se)Handles the given exception.voidinitializeEnvironment(Interpreter interp, java.lang.String lang)Initializes the environment of the given interpreter.static booleanisDynamicDocument(BridgeContext ctx, org.w3c.dom.Document doc)Tells whether the given SVG document is dynamic.static booleanisDynamicElement(BridgeContext ctx, org.w3c.dom.Element elt)static booleanisDynamicElement(org.w3c.dom.Element elt, BridgeContext ctx, java.util.List bridgeExtensions)Tells whether the given SVG element is dynamic.protected voidloadScript(AbstractElement script)Executes the specified <script> element, if it hasn't been executed already.voidloadScripts()Loads the scripts contained in the <script> elements.
-
-
-
Field Detail
-
INLINE_SCRIPT_DESCRIPTION
public static final java.lang.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:
- Constant Field Values
-
EVENT_SCRIPT_DESCRIPTION
public static final java.lang.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:
- Constant Field Values
-
EVENT_NAME
protected static final java.lang.String EVENT_NAME
- See Also:
- Constant Field Values
-
ALTERNATE_EVENT_NAME
protected static final java.lang.String ALTERNATE_EVENT_NAME
- See Also:
- Constant Field Values
-
APPLICATION_ECMASCRIPT
protected static final java.lang.String APPLICATION_ECMASCRIPT
The 'application/ecmascript' MIME type.- See Also:
- Constant Field Values
-
bridgeContext
protected BridgeContext bridgeContext
The bridge context.
-
userAgent
protected UserAgent userAgent
The user-agent.
-
document
protected org.w3c.dom.Document document
The document to manage.
-
docPURL
protected ParsedURL docPURL
The URL of the document ot manage
-
languages
protected java.util.Set languages
-
interpreter
protected Interpreter interpreter
The default Interpreter for the document
-
windowObjects
protected java.util.Map windowObjects
Map ofInterpretertoWindowobjects.
-
executedScripts
protected java.util.WeakHashMap executedScripts
Set of <script> elements that have already been executed.
-
-
Constructor Detail
-
BaseScriptingEnvironment
public BaseScriptingEnvironment(BridgeContext ctx)
Creates a new BaseScriptingEnvironment.- Parameters:
ctx- the bridge context
-
-
Method Detail
-
isDynamicDocument
public static boolean isDynamicDocument(BridgeContext ctx, org.w3c.dom.Document doc)
Tells whether the given SVG document is dynamic.
-
isDynamicElement
public static boolean isDynamicElement(BridgeContext ctx, org.w3c.dom.Element elt)
-
isDynamicElement
public static boolean isDynamicElement(org.w3c.dom.Element elt, BridgeContext ctx, java.util.List bridgeExtensions)Tells whether the given SVG element is dynamic.
-
getWindow
public Window getWindow(Interpreter interp, java.lang.String lang)
Returns the Window object for the specifiedInterpreter.
-
getWindow
public Window getWindow()
Returns the Window object for scripting languages that have noInterpreterobject.
-
createWindow
protected Window createWindow(Interpreter interp, java.lang.String lang)
Creates a new Window object.
-
getInterpreter
public Interpreter getInterpreter()
Returns the default Interpreter for this document.
-
getInterpreter
public Interpreter getInterpreter(java.lang.String lang)
-
initializeEnvironment
public void initializeEnvironment(Interpreter interp, java.lang.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(java.lang.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(org.w3c.dom.Element elt, boolean checkCanRun, java.lang.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(java.lang.String eventType)
-
handleInterpreterException
protected void handleInterpreterException(InterpreterException ie)
Handles the given exception.
-
handleSecurityException
protected void handleSecurityException(java.lang.SecurityException se)
Handles the given exception.
-
-