public abstract class Fn extends Object
Fn.Presenter.defineFn(java.lang.String, java.lang.String...)
.Modifier and Type | Class and Description |
---|---|
static interface |
Fn.FromJavaScript
Additional interface to be implemented by
Fn.Presenter s that
need to convert JavaScript object (usually array) to Java object
when calling back from JavaScript to Java. |
static interface |
Fn.KeepAlive
Additional interface to
Fn.Presenter to control more precisely
garbage collection behavior of individual parameters. |
static interface |
Fn.Presenter
The representation of a presenter - usually a browser window.
|
static interface |
Fn.ToJavaScript
Additional interface to be implemented by
Fn.Presenter s that
wish to control what objects are passed into the JavaScript virtual
machine. |
Modifier | Constructor and Description |
---|---|
protected |
Fn()
Deprecated.
Ineffective as of 0.6.
Provide a presenter via
Fn.Fn(org.netbeans.html.boot.spi.Fn.Presenter)
constructor |
protected |
Fn(Fn.Presenter presenter)
Creates new function object and associates it with given presenter.
|
Modifier and Type | Method and Description |
---|---|
static Closeable |
activate(Fn.Presenter p)
Activates given presenter.
|
static Fn.Presenter |
activePresenter()
The currently active presenter.
|
static Fn |
define(Class<?> caller,
boolean keepParametersAlive,
String code,
String... names)
Helper method to find current presenter and ask it to define new
function.
|
static Fn |
define(Class<?> caller,
String code,
String... names)
Helper method to find current presenter and ask it to define new
function by calling
Fn.Presenter.defineFn(java.lang.String, java.lang.String...) . |
abstract Object |
invoke(Object thiz,
Object... args)
Invokes the defined function with specified
this and
appropriate arguments. |
void |
invokeLater(Object thiz,
Object... args)
Invokes the defined function with specified
this and
appropriate arguments asynchronously. |
boolean |
isValid()
True, if currently active presenter is the same as presenter this
function has been created for via
Fn.Fn(org.netbeans.html.boot.spi.Fn.Presenter) . |
static boolean |
isValid(Fn fnOrNull)
Helper method to check if the provided instance is valid function.
|
static Fn |
preload(Fn fn,
Class<?> caller,
String resource)
Wraps function to ensure that the script represented by
resource
gets loaded into the browser environment before the function fn
is executed. |
protected Fn.Presenter |
presenter()
Provides the function implementation access to the presenter provided
in
the constructor . |
@Deprecated protected Fn()
Fn.Fn(org.netbeans.html.boot.spi.Fn.Presenter)
constructorprotected Fn(Fn.Presenter presenter)
presenter
- the browser presenter associated with this functionpublic final boolean isValid()
Fn.Fn(org.netbeans.html.boot.spi.Fn.Presenter)
.public static boolean isValid(Fn fnOrNull)
Fn.isValid()
check.fnOrNull
- function or null
public static Fn define(Class<?> caller, String code, String... names)
Fn.Presenter.defineFn(java.lang.String, java.lang.String...)
.caller
- the class who wishes to define the functioncode
- the body of the function (can reference this
and names
variables)names
- names of individual parametersinvoked
- can return null
if there is no presenter
public static Fn define(Class<?> caller, boolean keepParametersAlive, String code, String... names)
caller
- the class who wishes to define the functionkeepParametersAlive
- whether Java parameters should survive in JavaScript
after the method invocation is overcode
- the body of the function (can reference this
and names
variables)names
- names of individual parametersinvoked
- can return null
if there is no presenter
public static Fn preload(Fn fn, Class<?> caller, String resource)
resource
gets loaded into the browser environment before the function fn
is executed.fn
- original function to call (if null
returns null
)caller
- the class who wishes to define/call the functionresource
- resources (accessible via ClassLoader.getResource(java.lang.String)
)
with a JavaScript that is supposed to loaded into the browser
environmentfn
. Returns null
if the input fn
is nullpublic static Fn.Presenter activePresenter()
null
public static Closeable activate(Fn.Presenter p)
JavaScriptBody
annotation with certain presenter:
try (Closeable
c = Fn.activate(presenter)) {
doCallsInPresenterContext();
}
p
- the presenter that should be active until closable is closedpublic abstract Object invoke(Object thiz, Object... args) throws Exception
this
and
appropriate arguments.thiz
- the meaning of this
inside of the JavaScript
function - can be null
args
- arguments for the functionException
- if something goes wrong, as exception may be thrownpublic void invokeLater(Object thiz, Object... args) throws Exception
this
and
appropriate arguments asynchronously. The invocation may be
happen "later".thiz
- the meaning of this
inside of the JavaScript
function - can be null
args
- arguments for the functionException
- if something goes wrong, as exception may be thrownprotected final Fn.Presenter presenter()
the constructor
.null
)Copyright © 2018 NetBeans. All rights reserved.