public final class WebKitPresenter extends java.lang.Object implements Fn.Presenter, Fn.KeepAlive, java.util.concurrent.Executor
Modifier and Type | Class and Description |
---|---|
class |
WebKitPresenter.FnCallback |
Constructor and Description |
---|
WebKitPresenter()
Default constructor.
|
WebKitPresenter(boolean headless)
Visible or invisible presenter.
|
Modifier and Type | Method and Description |
---|---|
Fn |
defineFn(java.lang.String code,
java.lang.String... names)
Creates new function with given parameter names and provided body.
|
Fn |
defineFn(java.lang.String code,
java.lang.String[] names,
boolean[] keepAlive)
Creates new function with given parameter names and provided body.
|
void |
displayPage(java.net.URL page,
java.lang.Runnable onPageLoad)
Opens the browser, loads provided page and when the
page is ready, it calls back to the provider runnable.
|
void |
execute(java.lang.Runnable command) |
void |
loadScript(java.io.Reader code)
Loads a script into the browser JavaScript interpreter and
executes it.
|
public WebKitPresenter()
BrowserBuilder
API.public WebKitPresenter(boolean headless)
finalWebKitPresenter
headlessPresenter = newWebKitPresenter
(true); finalBrowserBuilder
bb =BrowserBuilder
.newBrowser(headlessPresenter). loadFinished(onPageLoaded). loadPage("empty.html");
headless
- true
if the presenter shall run headlesspublic Fn defineFn(java.lang.String code, java.lang.String... names)
Fn.Presenter
defineFn
in interface Fn.Presenter
code
- the body of the function. Can refer to variables named
as names
names
- names of parameters of the function - these will be
available when the code
body executespublic Fn defineFn(java.lang.String code, java.lang.String[] names, boolean[] keepAlive)
Fn.KeepAlive
defineFn
in interface Fn.KeepAlive
code
- the body of the function. Can refer to variables named
as names
names
- names of parameters of the function - these will be
available when the code
body executeskeepAlive
- array of booleans describing for each parameter
whether it should be kept alive or not. Length of the array
must be the same as length of names
array. The
array may be null
to signal that all parameters
should be kept alive.public void displayPage(java.net.URL page, java.lang.Runnable onPageLoad)
Fn.Presenter
displayPage
in interface Fn.Presenter
page
- the URL for the page to displayonPageLoad
- callback when the page is readypublic void loadScript(java.io.Reader code) throws java.lang.Exception
Fn.Presenter
loadScript
in interface Fn.Presenter
code
- the script to executejava.lang.Exception
- if something goes wrong, throw an exceptionpublic void execute(java.lang.Runnable command)
execute
in interface java.util.concurrent.Executor
Copyright © 2021 The Apache Software Foundation. All rights reserved.