Top Description Inners Fields Constructors Methods
org.python.jsr223

public final Class PyScriptEngineScope

extends PyObject
Class Inheritance
Annotations
@Untraversable
@ExposedType
name:scope
isBaseType:false
Imports
java.util.HashMap, .List, .Map, javax.script.Bindings, .ScriptContext, .ScriptEngine, org.python.core.Py, .PyDictionary, .PyIterator, .PyList, .PyObject, .PyString, .PyType, .Visitproc, .Untraversable, org.python.expose.ExposedType, .ExposedGet, .ExposedMethod

JSR 223 does not map well to Jython's concept of "locals" and "globals". Instead, SimpleScriptContext provides ENGINE_SCOPE and GLOBAL_SCOPE, each with its own bindings. We adapt this multi-scope object for use as both a local and global dictionary.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class

Field Summary

Modifier and TypeField and Description
private final ScriptContext
private final ScriptEngine
public static final PyType
Inherited from org.python.core.PyObject:
attributesgcMonitorGlobalobjtype

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
__contains__(PyObject
the element to search for in this container.
obj
)

Overrides org.python.core.PyObject.__contains__.

Equivalent to the standard Python __contains__ method.

public void
__delitem__(PyObject
the key to be removed from the container
key
)

Overrides org.python.core.PyObject.__delitem__.

Equivalent to the standard Python __delitem__ method.

public void
__delitem__(String
the key who will be removed - must be an interned string .
key
)

Overrides org.python.core.PyObject.__delitem__.

A variant of the __delitem__ method which accepts a String as the key.

public PyObject
__finditem__(PyObject
the key to lookup in this container
key
)

Overrides org.python.core.PyObject.__finditem__.

Very similar to the standard Python __getitem__ method.

public PyObject
__finditem__(String
the key to lookup in this sequence - must be an interned string .
key
)

Overrides org.python.core.PyObject.__finditem__.

A variant of the __finditem__ method which accepts a Java String as the key.

public PyObject
__getitem__(PyObject
the key to lookup in this container.
key
)

Overrides org.python.core.PyObject.__getitem__.

Equivalent to the standard Python __getitem__ method.

public PyObject
__iter__()

Overrides org.python.core.PyObject.__iter__.

Return an iterator that is used to iterate the element of this sequence.

public void
__setitem__(PyObject
the key whose value will be set
key
,
PyObject
the value to set this key to
value
)

Overrides org.python.core.PyObject.__setitem__.

Equivalent to the standard Python __setitem__ method.

public void
__setitem__(String
the key whose value will be set - must be an interned string .
key
,
PyObject
the value to set this key to
value
)

Overrides org.python.core.PyObject.__setitem__.

A variant of the __setitem__ method which accepts a String as the key.

private PyDictionary
private Map<PyObject, PyObject>
public PyObject
public PyObject
pack-priv final boolean
pack-priv final PyObject
scope_get(PyObject keyObj, PyObject defaultObj)

pack-priv final boolean
public PyObject
pack-priv final PyObject
public String
toString()

Overrides org.python.core.PyObject.toString.

Returns a string representation of the object.

Inherited from org.python.core.PyObject:
__abs____add____and____call____call____call____call____call____call____call____call____call____call____call____call____call____call____call____call____cmp____coerce____coerce_ex____complex____delattr____delattr____delete____delslice____delslice____dir____div____divmod____ensure_finalizer____eq____findattr____findattr____findattr_ex____finditem____float____floordiv____format____ge____get____getattr____getattr____getitem____getnewargs____getslice____getslice____gt____hash____hex____iadd____iand____idiv____idivmod____ifloordiv____ilshift____imod____imul____index____int____invert____ior____ipow____irshift____isub____iternext____itruediv____ixor____le____len____long____lshift____lt____mod____mul____ne____neg____nonzero____not____oct____or____pos____pow____pow____radd____rand____rawdir____rdiv____rdivmod____reduce____reduce_ex____reduce_ex____repr____rfloordiv____rlshift____rmod____rmul____ror____rpow____rrshift____rshift____rsub____rtruediv____rxor____set____setattr____setattr____setitem____setslice____setslice____str____sub____tojava____truediv____trunc____unicode____xor___add_and_callextra_cmp_div_divmod_doget_doget_doset_eq_floordiv_ge_gt_iadd_iand_idiv_idivmod_ifloordiv_ilshift_imod_imul_in_ior_ipow_irshift_is_isnot_isub_itruediv_ixor_jcall_jcallexc_jthrow_le_lshift_lt_mod_mul_ne_notin_or_pow_rshift_sub_truediv_unsupportedop_xoradaptToCoerceTupleasDoubleasIndexasIndexasIntasIntasIterableasLongasLongasNameasNameasStringasStringasStringOrNullasStringOrNullbit_lengthconjugatedelDictdelTypedispatch__init__equalsfastGetClassfastGetDictfinalizegetDictgetJavaProxygetTypehashCodeimpAttrimplementsDescrDeleteimplementsDescrGetimplementsDescrSetinvokeinvokeinvokeinvokeinvokeinvokeisCallableisDataDescrisIndexisIntegerisMappingTypeisNumberTypeisSequenceTypemergeClassDictmergeDictAttrmergeListAttrnoAttributeErrorobject___subclasshook__readonlyAttributeErrorrunsupportedopMessagesetDictsetTypeunsupportedopMessage

Field Detail

contextback to summary
private final ScriptContext context
engineback to summary
private final ScriptEngine engine
TYPEback to summary
public static final PyType TYPE

Hides org.python.core.PyObject.TYPE.

Constructor Detail

PyScriptEngineScopeback to summary
pack-priv PyScriptEngineScope(ScriptEngine engine, ScriptContext context)

Method Detail

__contains__back to summary
public boolean __contains__(PyObject obj)

Overrides org.python.core.PyObject.__contains__.

Doc from org.python.core.PyObject.__contains__.

Equivalent to the standard Python __contains__ method.

Parameters
obj:PyObject

the element to search for in this container.

Returns:boolean

the result of the search.

Annotations
@Override

__delitem__back to summary
public void __delitem__(PyObject key)

Overrides org.python.core.PyObject.__delitem__.

Doc from org.python.core.PyObject.__delitem__.

Equivalent to the standard Python __delitem__ method.

Parameters
key:PyObject

the key to be removed from the container

Annotations
@ExposedMethod
@Override
__delitem__back to summary
public void __delitem__(String key)

Overrides org.python.core.PyObject.__delitem__.

Doc from org.python.core.PyObject.__delitem__.

A variant of the __delitem__ method which accepts a String as the key. This String must be interned. By default, this will call __delitem__(PyObject key) with the appropriate args. The only reason to override this method is for performance.

Parameters
key:String

the key who will be removed - must be an interned string .

Annotations
@Override
__finditem__back to summary
public PyObject __finditem__(PyObject key)

Overrides org.python.core.PyObject.__finditem__.

Doc from org.python.core.PyObject.__finditem__.

Very similar to the standard Python __getitem__ method. Instead of throwing a KeyError if the item isn't found, this just returns null. Classes that wish to implement __getitem__ should override this method instead (with the appropriate semantics.

Parameters
key:PyObject

the key to lookup in this container

Returns:PyObject

the value corresponding to key or null if key is not found

Annotations
@Override

__finditem__back to summary
public PyObject __finditem__(String key)

Overrides org.python.core.PyObject.__finditem__.

Doc from org.python.core.PyObject.__finditem__.

A variant of the __finditem__ method which accepts a Java String as the key. By default, this method will call __finditem__(PyObject key) with the appropriate args. The only reason to override this method is for performance.

Warning

key must be an interned string!!!!!!!!

Parameters
key:String

the key to lookup in this sequence - must be an interned string .

Returns:PyObject

the value corresponding to key or null if key is not found.

Annotations
@Override

__getitem__back to summary
public PyObject __getitem__(PyObject key)

Overrides org.python.core.PyObject.__getitem__.

Doc from org.python.core.PyObject.__getitem__.

Equivalent to the standard Python __getitem__ method. This method should not be overridden. Override the __finditem__ method instead.

Parameters
key:PyObject

the key to lookup in this container.

Returns:PyObject

the value corresponding to that key.

Annotations
@ExposedMethod
@Override

__iter__back to summary
public PyObject __iter__()

Overrides org.python.core.PyObject.__iter__.

Doc from org.python.core.PyObject.__iter__.

Return an iterator that is used to iterate the element of this sequence. From version 2.2, this method is the primary protocol for looping over sequences.

If a PyObject subclass should support iteration based in the __finditem__() method, it must supply an implementation of __iter__() like this:

public PyObject __iter__() {
    return new PySequenceIter(this);
}
When iterating over a python sequence from java code, it should be done with code like this:
for (PyObject item : seq.asIterable()) {
    // Do something with item
}
Annotations
@ExposedMethod
@Override
__setitem__back to summary
public void __setitem__(PyObject key, PyObject value)

Overrides org.python.core.PyObject.__setitem__.

Doc from org.python.core.PyObject.__setitem__.

Equivalent to the standard Python __setitem__ method.

Parameters
key:PyObject

the key whose value will be set

value:PyObject

the value to set this key to

Annotations
@ExposedMethod
@Override
__setitem__back to summary
public void __setitem__(String key, PyObject value)

Overrides org.python.core.PyObject.__setitem__.

Doc from org.python.core.PyObject.__setitem__.

A variant of the __setitem__ method which accepts a String as the key. This String must be interned. By default, this will call __setitem__(PyObject key, PyObject value) with the appropriate args. The only reason to override this method is for performance.

Parameters
key:String

the key whose value will be set - must be an interned string .

value:PyObject

the value to set this key to

Annotations
@Override
getDictionaryback to summary
private PyDictionary getDictionary()
getMapback to summary
private Map<PyObject, PyObject> getMap()
pyGetContextback to summary
public PyObject pyGetContext()
Annotations
@ExposedGet
name:context
pyGetEngineback to summary
public PyObject pyGetEngine()
Annotations
@ExposedGet
name:engine
scope___contains__back to summary
pack-priv final boolean scope___contains__(PyObject obj)
Annotations
@ExposedMethod
scope_getback to summary
pack-priv final PyObject scope_get(PyObject keyObj, PyObject defaultObj)
Annotations
@ExposedMethod
defaults:Py.None
scope_has_keyback to summary
pack-priv final boolean scope_has_key(PyObject key)
Annotations
@ExposedMethod
scope_keysback to summary
public PyObject scope_keys()
Annotations
@ExposedMethod
scope_setdefaultback to summary
pack-priv final PyObject scope_setdefault(PyObject keyObj, PyObject failObj)
Annotations
@ExposedMethod
defaults:Py.None
toStringback to summary
public String toString()

Overrides org.python.core.PyObject.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override

org.python.jsr223 back to summary

public Class PyScriptEngineScope.ScopeIterator

extends PyIterator
Class Inheritance

Field Summary

Modifier and TypeField and Description
private int
private PyObject
private int
Inherited from org.python.core.PyIterator:
__doc__nextstopException

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public PyObject
__iternext__()

Implements abstract org.python.core.PyIterator.__iternext__.

Return the next element of the sequence that this is an iterator for.

public boolean
public int
size()

public int
traverse(Visitproc visit, Object arg)

Overrides org.python.core.PyIterator.traverse.

Implements org.python.core.Traverseproc.traverse.

Traverses all directly contained PyObjects.

Inherited from org.python.core.PyIterator:
__iter____tojava__doNextiteratornext

Field Detail

_indexback to summary
private int _index
_keysback to summary
private PyObject _keys
_sizeback to summary
private int _size

Constructor Detail

ScopeIteratorback to summary
pack-priv ScopeIterator(PyScriptEngineScope scope)

Method Detail

__iternext__back to summary
public PyObject __iternext__()

Implements abstract org.python.core.PyIterator.__iternext__.

Doc from org.python.core.PyObject.__iternext__.

Return the next element of the sequence that this is an iterator for. Returns null when the end of the sequence is reached.

Annotations
@Override
refersDirectlyToback to summary
public boolean refersDirectlyTo(PyObject ob)

Overrides org.python.core.PyIterator.refersDirectlyTo.

Implements org.python.core.Traverseproc.refersDirectlyTo.

Doc from org.python.core.Traverseproc.refersDirectlyTo.

Optional operation. Should only be implemented if it is more efficient than calling traverse(Visitproc, Object) with a visitproc that just watches out for ob. Must return false if ob is null.

Annotations
@Override
sizeback to summary
public int size()
traverseback to summary
public int traverse(Visitproc visit, Object arg)

Overrides org.python.core.PyIterator.traverse.

Implements org.python.core.Traverseproc.traverse.

Doc from org.python.core.Traverseproc.traverse.

Traverses all directly contained PyObjects. Like in CPython, arg must be passed unmodified to visit as its second parameter. If Visitproc#visit(PyObject, Object) returns nonzero, this return value must be returned immediately by traverse. Visitproc#visit(PyObject, Object) must not be called with a null PyObject-argument.

Annotations
@Override