|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjep.Jep
Jep.java - Embeds CPython in Java. Copyright (c) 2004, 2005 Mike Johnson. This file is licenced under the the zlib/libpng License. This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Created: Fri Apr 30 10:35:03 2004
Constructor Summary | |
Jep()
Creates a new Jep instance. |
|
Jep(boolean interactive)
Creates a new Jep instance. |
|
Jep(boolean interactive,
java.lang.String includePath)
Creates a new Jep instance. |
|
Jep(boolean interactive,
java.lang.String includePath,
java.lang.ClassLoader cl)
Creates a new Jep instance. |
Method Summary | |
void |
close()
Shutdown python interpreter. |
boolean |
eval(java.lang.String str)
Evaluate python statements. |
protected void |
finalize()
Describe finalize method here. |
java.lang.Object |
getValue(java.lang.String str)
Retrieves a value from python. |
boolean |
isInteractive()
get interactive |
void |
runScript(java.lang.String script)
run a python script. |
void |
runScript(java.lang.String script,
java.lang.ClassLoader cl)
run a python script. |
void |
set(java.lang.String name,
boolean v)
Describe set method here. |
void |
set(java.lang.String name,
byte b)
Describe set method here. |
void |
set(java.lang.String name,
char v)
Describe set method here. |
void |
set(java.lang.String name,
char[] v)
Describe set method here. |
void |
set(java.lang.String name,
double v)
Describe set method here. |
void |
set(java.lang.String name,
float v)
Describe set method here. |
void |
set(java.lang.String name,
int v)
Describe set method here. |
void |
set(java.lang.String name,
long v)
Describe set method here. |
void |
set(java.lang.String name,
java.lang.Object v)
Describe set method here. |
void |
set(java.lang.String name,
short v)
Describe set method here. |
void |
set(java.lang.String name,
java.lang.String v)
Describe set method here. |
void |
setClassLoader(java.lang.ClassLoader cl)
set default classloader |
void |
setInteractive(boolean v)
changes behavior of eval() |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Jep() throws JepException
Jep
instance.
JepException
- if an error occurspublic Jep(boolean interactive) throws JepException
Jep
instance.
interactive
- a boolean
value
JepException
- if an error occurspublic Jep(boolean interactive, java.lang.String includePath) throws JepException
Jep
instance.
interactive
- a boolean
valueincludePath
- a ':' delimited String
of directories
JepException
- if an error occurspublic Jep(boolean interactive, java.lang.String includePath, java.lang.ClassLoader cl) throws JepException
Jep
instance.
interactive
- a boolean
valueincludePath
- a String
valuecl
- a ClassLoader
value
JepException
- if an error occursMethod Detail |
public void runScript(java.lang.String script) throws JepException
script
- a String
absolute path to script file.
JepException
- if an error occurspublic void runScript(java.lang.String script, java.lang.ClassLoader cl) throws JepException
script
- a String
absolute path to script file.cl
- a ClassLoader
value, may be null.
JepException
- if an error occurspublic boolean eval(java.lang.String str) throws JepException
Evaluate python statements. In interactive mode, Jep may not immediately execute the given lines of code. In that case, eval() returns false and the statement is remembered and is appended to the next incoming string. If you're running an unknown number of statements, finish witheval(null)
to flush the statement buffer. Interactive mode is slower than a straight eval call since it has to compile the code strings to detect the end of the block. Non-interactive mode is faster, but code blocks must be complete. For Example:eval("if(Test):\n\tprint 'w00t'")This is a limitation on the Python interpreter and unlikely to change. Also, Python does not readly return object values from eval(). UsegetValue(java.lang.String)
instead.
str
- a String
value
JepException
- if an error occurspublic java.lang.Object getValue(java.lang.String str) throws JepException
Retrieves a value from python. If the result is not a java object, the implementation currently returns a String. Python is pretty picky about what it excepts here. The general syntax:eval("a = 5") String a = (String) getValue("a")will work.
str
- a String
value
Object
value
JepException
- if an error occurspublic void setClassLoader(java.lang.ClassLoader cl)
cl
- a ClassLoader
valuepublic void setInteractive(boolean v)
v
- a boolean
valuepublic boolean isInteractive()
boolean
valuepublic void set(java.lang.String name, java.lang.Object v) throws JepException
set
method here.
name
- a String
valuev
- an Object
value
JepException
- if an error occurspublic void set(java.lang.String name, java.lang.String v) throws JepException
set
method here.
name
- a String
valuev
- a String
value
JepException
- if an error occurspublic void set(java.lang.String name, boolean v) throws JepException
set
method here.
name
- a String
valuev
- a boolean
value
JepException
- if an error occurspublic void set(java.lang.String name, int v) throws JepException
set
method here.
name
- a String
valuev
- an int
value
JepException
- if an error occurspublic void set(java.lang.String name, short v) throws JepException
set
method here.
name
- a String
valuev
- an int
value
JepException
- if an error occurspublic void set(java.lang.String name, char[] v) throws JepException
set
method here.
name
- a String
valuev
- a char[]
value
JepException
- if an error occurspublic void set(java.lang.String name, char v) throws JepException
set
method here.
name
- a String
valuev
- a char
value
JepException
- if an error occurspublic void set(java.lang.String name, byte b) throws JepException
set
method here.
name
- a String
valueb
- a byte
value
JepException
- if an error occurspublic void set(java.lang.String name, long v) throws JepException
set
method here.
name
- a String
valuev
- a long
value
JepException
- if an error occurspublic void set(java.lang.String name, double v) throws JepException
set
method here.
name
- a String
valuev
- a double
value
JepException
- if an error occurspublic void set(java.lang.String name, float v) throws JepException
set
method here.
name
- a String
valuev
- a float
value
JepException
- if an error occurspublic void close()
protected void finalize()
finalize
method here.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |