|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectst.extreme.jython.util.JyClass
public class JyClass
Utility class to:
forScript(String, Class), and
newInstance(Class) afterwards.
| Method Summary | ||
|---|---|---|
static javax.script.CompiledScript |
compile(java.lang.String script,
javax.script.Bindings bindings)
Compile a script. |
|
static JyClass |
forScript(java.lang.String script,
java.lang.Class targetClass)
Create a JyClass out of a script. |
|
static
|
newCompiledInstance(java.lang.Class<T> clazz,
javax.script.CompiledScript compiledScript,
javax.script.Bindings bindings,
java.lang.String varName)
Create a compiled instance of a class implemented by a compiled script. |
|
static
|
newCompiledInstance(java.lang.Class<T> clazz,
javax.script.CompiledScript compiledScript,
java.lang.String varName)
Create a compiled instance of a class implemented by a compiled script. |
|
|
newInstance(java.lang.Class<T> clazz)
Create a new instance. |
|
|
newInstance(java.lang.Class<T> clazz,
java.lang.Object... params)
Create a new instance. |
|
static
|
newInterpretedInstance(java.lang.Class<I> interfaze,
java.lang.String script,
javax.script.Bindings bindings,
java.lang.String varName)
Create an interpreted instance of a class implementing a given interface. |
|
static
|
newInterpretedInstance(java.lang.Class<I> interfaze,
java.lang.String script,
java.lang.String varName)
Create an interpreted instance of a class implementing a given interface. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <I> I newInterpretedInstance(java.lang.Class<I> interfaze,
java.lang.String script,
java.lang.String varName)
throws javax.script.ScriptException
For a more detailed description, see overloaded method.
null if no instance found
javax.script.ScriptExceptionnewInterpretedInstance(Class, String, Bindings, String)
public static <I> I newInterpretedInstance(java.lang.Class<I> interfaze,
java.lang.String script,
javax.script.Bindings bindings,
java.lang.String varName)
throws javax.script.ScriptException
The script is parsed, compiled and executed every time this method is called.
Example:
from java.awt import Color
from st.extreme.jython import SecondHand
class MySimpleSecondHand(SecondHand):
def getColor(self):
return Color.RED
# caller expects a variable named 'secondHand':
secondHand = MySimpleSecondHand()
interfaze - The expected interface - it has to be an interfacescript - The script defining and instantiating the classbindings - The Bindings if present,
null otherwisevarName - The name of the variable designating the instance
null if no instance found
javax.script.ScriptExceptionInvocable.getInterface(Object, Class)
public static javax.script.CompiledScript compile(java.lang.String script,
javax.script.Bindings bindings)
throws javax.script.ScriptException
A compiled script is only parsed and compiled once.
script - The scriptbindings - The Bindings
javax.script.ScriptExceptionnewCompiledInstance(Class, CompiledScript, String)
public static <T> T newCompiledInstance(java.lang.Class<T> clazz,
javax.script.CompiledScript compiledScript,
java.lang.String varName)
throws javax.script.ScriptException
For a more detailed description, see overloaded method.
javax.script.ScriptExceptionnewCompiledInstance(Class, CompiledScript, Bindings, String)
public static <T> T newCompiledInstance(java.lang.Class<T> clazz,
javax.script.CompiledScript compiledScript,
javax.script.Bindings bindings,
java.lang.String varName)
throws javax.script.ScriptException
A compiled script is only parsed and compiled once.
Example:
from java.awt import Color
from st.extreme.jython import SecondHand
class MySimpleSecondHand(SecondHand):
def getColor(self):
return Color.RED
# caller expects a variable named 'secondHand':
secondHand = MySimpleSecondHand()
clazz - The expected ClasscompiledScript - The compiled script defining and instantiating the classbindings - The Bindings if present,
null otherwisevarName - The name of the variable designating the instance
null if no instance found
javax.script.ScriptException
public static JyClass forScript(java.lang.String script,
java.lang.Class targetClass)
throws javax.script.ScriptException
JyClass out of a script.
The script is assumed to hold a class declaration only.
Multiple instances can be created afterwards, using the
newInstance(Class) or
newInstance(Class, Object[]) member methods. These
instances will share the same Java class inside the JVM.
Example (no instantiation at the end):
from java.awt import Color
from st.extreme.jython import SecondHand
class MySimpleSecondHand(SecondHand):
def getColor(self):
return Color.RED
script - The script defining the classtargetClass - The Java class implemented in this script
newInstance()
upon.
javax.script.ScriptExceptionnewInstance(Class),
newInstance(Class, Object[])
public <T> T newInstance(java.lang.Class<T> clazz)
throws javax.script.ScriptException
For a more detailed description, see overloaded method.
javax.script.ScriptExceptionnewInstance(Class, Object[])
public <T> T newInstance(java.lang.Class<T> clazz,
java.lang.Object... params)
throws javax.script.ScriptException
JyClass is assumed to be created using
forScript(String, Class).
clazz - The target Java class. This can be the class used when
creating with forScript(String, Class), or a
superclass of it.params - Parameters necessary for creating the instance. Can be
null.
javax.script.ScriptExceptionforScript(String, Class)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||