public class BrowserFunction
extends java.lang.Object
BrowserFunction
and
overriding its function(Object[])
method. This
method will be invoked whenever javascript running in the
Browser makes a call with the function's name.
Application code must explicitly invoke the
BrowserFunction.dispose()
method to release the
resources managed by each instance when those instances are no
longer required. Since there is usually a correlation between
the registering of BrowserFunction(s) in a Browser and the
loading of a page in the Browser that is aware of these
functions, the LocationListener.changed()
listener
is often a good place to do this.
Note that disposing a Browser automatically disposes all BrowserFunctions associated with it.
dispose()
,
function(Object[])
,
LocationListener.changed(LocationEvent)
Modifier and Type | Field and Description |
---|---|
(package private) Browser |
browser |
(package private) java.lang.String[] |
frameNames |
(package private) java.lang.String |
functionString |
(package private) int |
index |
(package private) boolean |
isEvaluate |
(package private) java.lang.String |
name |
(package private) java.lang.String |
token |
(package private) boolean |
top |
Constructor and Description |
---|
BrowserFunction(Browser browser,
java.lang.String name)
Constructs a new instance of this class, which will be invokable
by javascript running in the specified Browser.
|
BrowserFunction(Browser browser,
java.lang.String name,
boolean top,
java.lang.String[] frameNames)
Constructs a new instance of this class, which will be invokable
by javascript running in the specified Browser.
|
BrowserFunction(Browser browser,
java.lang.String name,
boolean top,
java.lang.String[] frameNames,
boolean create) |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Disposes of the resources associated with this BrowserFunction.
|
(package private) void |
dispose(boolean remove) |
java.lang.Object |
function(java.lang.Object[] arguments)
Subclasses should override this method.
|
Browser |
getBrowser()
Returns the Browser whose pages can invoke this BrowserFunction.
|
java.lang.String |
getName()
Returns the name that javascript can use to invoke this BrowserFunction.
|
boolean |
isDisposed()
Returns
true if this BrowserFunction has been disposed
and false otherwise. |
Browser browser
java.lang.String name
java.lang.String functionString
int index
boolean isEvaluate
boolean top
java.lang.String token
java.lang.String[] frameNames
public BrowserFunction(Browser browser, java.lang.String name)
BrowserFunction
constructor that accepts frame names
instead.
You must dispose the BrowserFunction when it is no longer required.
A common place to do this is in a LocationListener.changed()
listener.
browser
- the browser whose javascript can invoke this functionname
- the name that javascript will use to invoke this functionjava.lang.IllegalArgumentException
- SWTException
- dispose()
,
BrowserFunction(Browser, String, boolean, String[])
,
LocationListener.changed(LocationEvent)
public BrowserFunction(Browser browser, java.lang.String name, boolean top, java.lang.String[] frameNames)
top
and frameNames
arguments. To create a function that is globally accessible to
the top-level window and all child frames use the
BrowserFunction
constructor that does not accept frame
names instead.
You must dispose the BrowserFunction when it is no longer required.
A common place to do this is in a LocationListener.changed()
listener.
browser
- the browser whose javascript can invoke this functionname
- the name that javascript will use to invoke this functiontop
- true
if the function should be accessible to the
top-level window and false
otherwiseframeNames
- the names of the child frames that the function should
be accessible injava.lang.IllegalArgumentException
- SWTException
- dispose()
,
BrowserFunction(Browser, String)
,
LocationListener.changed(LocationEvent)
BrowserFunction(Browser browser, java.lang.String name, boolean top, java.lang.String[] frameNames, boolean create)
public void dispose()
Note that disposing a Browser automatically disposes all BrowserFunctions associated with it.
void dispose(boolean remove)
public java.lang.Object function(java.lang.Object[] arguments)
null
javascript number -> java.lang.Double
javascript string -> java.lang.String
javascript boolean -> java.lang.Boolean
javascript array whose elements are all of supported types -> java.lang.Object[]
If any of the javascript arguments are of unsupported types then the
function invocation will fail and this method will not be called.
This method must return a value with one of these supported java types to
the javascript caller. Note that null
values are converted
to javascript's null
value (not undefined
), and
instances of any java.lang.Number
subclass will be converted
to a javascript number.arguments
- the javascript arguments converted to java equivalentsSWTException
- public Browser getBrowser()
SWTException
- public java.lang.String getName()
SWTException
- public boolean isDisposed()
true
if this BrowserFunction has been disposed
and false
otherwise.
This method gets the dispose state for the BrowserFunction. When a BrowserFunction has been disposed it is an error to invoke any of its methods.
Note that disposing a Browser automatically disposes all BrowserFunctions associated with it.
true
if this BrowserFunction has been disposed
and false
otherwise