Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.python.core.PyObject
org.python.core.PyStringMap
public class PyStringMap
extends PyObject
Nested Class Summary |
Nested classes/interfaces inherited from class org.python.core.PyObject | |
PyObject.ConversionException |
Field Summary |
Fields inherited from class org.python.core.PyObject | |
exposed_name |
Constructor Summary | |
| |
| |
|
Method Summary | |
int | |
void |
|
void |
|
PyObject |
|
PyObject |
|
PyObject |
|
int |
|
boolean |
|
void |
|
void |
|
void |
|
PyStringMap |
|
PyObject | |
PyObject | |
boolean | |
PyList |
|
PyObject |
|
PyObject |
|
PyObject |
|
PyList |
|
PyObject |
|
PyObject |
|
PyObject |
|
String |
|
void |
|
void |
|
PyList |
|
public PyStringMap()
The standard constructor for aPyObject
. It will set the__class__
field to correspond to the specific subclass ofPyObject
being instantiated.
public PyStringMap(elements[] )
public PyStringMap(int capacity)
public int __cmp__(PyObject other)
Equivalent to the standard Python __cmp__ method.
- Parameters:
other
- the object to compare this with.
- Returns:
- -1 if this <320; 0 if this == o; +1 if this > o; -2 if no comparison is implemented
public void __delitem__(String key)
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.
- Overrides:
- __delitem__ in interface PyObject
- Parameters:
key
- the key who will be removed - must be an interned string .
- See Also:
PyObject.__delitem__(PyObject)
public void __delitem__(PyObject key)
Equivalent to the standard Python __delitem__ method.
- Overrides:
- __delitem__ in interface PyObject
- Parameters:
key
- the key to be removed from the container
public PyObject __finditem__(String key)
A variant of the __finditem__ method which accepts a JavaString
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!!!!!!!!
- Overrides:
- __finditem__ in interface PyObject
- Parameters:
key
- the key to lookup in this sequence - must be an interned string .
- Returns:
- the value corresponding to key or null if key is not found.
- See Also:
PyObject.__finditem__(PyObject)
public PyObject __finditem__(PyObject key)
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.
- Overrides:
- __finditem__ in interface PyObject
- Parameters:
key
- the key to lookup in this container
- Returns:
- the value corresponding to key or null if key is not found
public 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:PyObject iter = seq.__iter__(); for (PyObject item; (item = iter.__iternext__()) != null;) { // Do somting with item }
- Since:
- 2.2
public int __len__()
Equivalent to the standard Python __len__ method. Part of the mapping discipline.
- Returns:
- the length of the object
public boolean __nonzero__()
Equivalent to the standard Python __nonzero__ method. Returns whether of not a givenPyObject
is considered true.
- Overrides:
- __nonzero__ in interface PyObject
public void __setitem__(String key, PyObject value)
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.
- Overrides:
- __setitem__ in interface PyObject
- Parameters:
key
- the key whose value will be set - must be an interned string .value
- the value to set this key to
public void __setitem__(PyObject key, PyObject value)
Equivalent to the standard Python __setitem__ method.
- Overrides:
- __setitem__ in interface PyObject
- Parameters:
key
- the key whose value will be setvalue
- the value to set this key to
public void clear()
Remove all items from the dictionary.
public PyObject get(PyObject key)
Return this[key] if the key exists in the mapping, None is returned otherwise.
- Parameters:
key
- the key to lookup in the mapping.
public PyObject get(PyObject key, PyObject default_object)
Return this[key] if the key exists in the mapping, default_object is returned otherwise.
- Parameters:
key
- the key to lookup in the mapping.default_object
- the value to return if the key does not exists in the mapping.
public PyObject popitem()
Return a random (key, value) tuple pair and remove the pair from the mapping.
public PyObject setdefault(PyObject key)
Return this[key] if the key exist, otherwise insert key with a None value and return None.
- Parameters:
key
- the key to lookup in the mapping.
public PyObject setdefault(PyObject key, PyObject failobj)
Return this[key] if the key exist, otherwise insert key with the value of failobj and return failobj
- Parameters:
key
- the key to lookup in the mapping.failobj
- the default value to insert in the mapping if key does not already exist.
public void update(PyDictionary dict)
Insert all the key:value pairs fromdict
into this mapping.
public void update(PyStringMap map)
Insert all the key:value pairs frommap
into this mapping.