org.python.core

Class PyDictionary

Implemented Interfaces:
java.io.Serializable
Known Direct Subclasses:
PyDictionaryDerived

public class PyDictionary
extends PyObject

A builtin python dictionary.
See Also:
Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class org.python.core.PyObject

PyObject.ConversionException

Field Summary

static String
exposed_name

Fields inherited from class org.python.core.PyObject

exposed_name

Constructor Summary

PyDictionary()
Create an empty dictionary.
PyDictionary(Hashtable t)
Create an new dictionary which is based on the hashtable.
PyDictionary(elements[] )
Create a new dictionary with the element as content.
PyDictionary(PyType subtype)
For derived types

Method Summary

int
__cmp__(PyObject ob_other)
boolean
__contains__(PyObject o)
void
__delitem__(PyObject key)
PyObject
__eq__(PyObject ob_other)
PyObject
__finditem__(int index)
PyObject
__finditem__(PyObject key)
PyObject
__iter__()
int
__len__()
PyObject
__ne__(PyObject ob_other)
boolean
__nonzero__()
void
__setitem__(PyObject key, PyObject value)
void
clear()
Remove all items from the dictionary.
PyDictionary
copy()
Return a shallow copy of the dictionary.
static PyObject
fromkeys(PyObject keys)
static PyObject
fromkeys(PyObject keys, PyObject value)
PyObject
get(PyObject key)
Return this[key] if the key exists in the mapping, None is returned otherwise.
PyObject
get(PyObject key, PyObject default_object)
Return this[key] if the key exists in the mapping, default_object is returned otherwise.
boolean
has_key(PyObject key)
Return true if the key exist in the dictionary.
int
hashCode()
boolean
isSequenceType()
PyList
items()
Return a copy of the dictionarys list of (key, value) tuple pairs.
PyObject
iteritems()
Return an interator over (key, value) pairs.
PyObject
iterkeys()
Return an interator over (key, value) pairs.
PyObject
itervalues()
Return an interator over (key, value) pairs.
PyList
keys()
Return a copy of the dictionarys list of keys.
PyObject
pop(PyObject key)
Return a value based on key from the dictionary.
PyObject
pop(PyObject key, PyObject defaultValue)
Return a value based on key from the dictionary or default if that key is not found.
PyObject
popitem()
Return a random (key, value) tuple pair and remove the pair from the dictionary.
PyObject
setdefault(PyObject key)
Return this[key] if the key exist, otherwise insert key with a None value and return None.
PyObject
setdefault(PyObject key, PyObject failobj)
Return this[key] if the key exist, otherwise insert key with the value of failobj and return failobj
String
toString()
static void
typeSetup(PyObject dict, PyType.Newstyle marker)
void
update(PyObject d)
Insert all the key:value pairs from d into this dictionary.
PyList
values()
Return a copy of the dictionarys list of values.

Methods inherited from class org.python.core.PyObject

__abs__, __add__, __and__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __cmp__, __coerce__, __coerce_ex__, __complex__, __contains__, __delattr__, __delattr__, __delete__, __delitem__, __delitem__, __delslice__, __delslice__, __dir__, __div__, __divmod__, __eq__, __findattr__, __findattr__, __finditem__, __finditem__, __finditem__, __float__, __floordiv__, __ge__, __get__, __getattr__, __getattr__, __getitem__, __getitem__, __getnewargs__, __getslice__, __getslice__, __gt__, __hash__, __hex__, __iadd__, __iand__, __idiv__, __idivmod__, __ifloordiv__, __ilshift__, __imod__, __imul__, __int__, __invert__, __ior__, __ipow__, __irshift__, __isub__, __iter__, __iternext__, __itruediv__, __ixor__, __le__, __len__, __long__, __lshift__, __lt__, __mod__, __mul__, __ne__, __neg__, __nonzero__, __not__, __oct__, __or__, __pos__, __pow__, __pow__, __radd__, __rand__, __rdiv__, __rdivmod__, __reduce__, __repr__, __rfloordiv__, __rlshift__, __rmod__, __rmul__, __ror__, __rpow__, __rrshift__, __rshift__, __rsub__, __rtruediv__, __rxor__, __set__, __setattr__, __setattr__, __setitem__, __setitem__, __setitem__, __setslice__, __setslice__, __str__, __sub__, __tojava__, __truediv__, __unicode__, __xor__, _add, _and, _callextra, _cmp, _div, _divmod, _doget, _doget, _doset, _eq, _floordiv, _ge, _gt, _in, _is, _isnot, _jcall, _jcallexc, _jthrow, _le, _lshift, _lt, _mod, _mul, _ne, _notin, _or, _pow, _rshift, _sub, _truediv, _xor, asInt, asLong, asName, asString, asStringOrNull, delDict, delType, dispatch__init__, equals, fastGetClass, fastGetDict, getDict, getDoc, getType, hashCode, implementsDescrDelete, implementsDescrSet, invoke, invoke, invoke, invoke, invoke, isCallable, isDataDescr, isMappingType, isNumberType, isSequenceType, noAttributeError, readonlyAttributeError, safeRepr, setDict, setType, toString, typeSetup

Field Details

exposed_name

public static final String exposed_name

Constructor Details

PyDictionary

public PyDictionary()
Create an empty dictionary.

PyDictionary

public PyDictionary(Hashtable t)
Create an new dictionary which is based on the hashtable.
Parameters:
t - the hashtable used. The supplied hashtable is used as is and must only contain PyObject key:value pairs.

PyDictionary

public PyDictionary(elements[] )
Create a new dictionary with the element as content.
Parameters:

PyDictionary

public PyDictionary(PyType subtype)
For derived types
Parameters:
subtype -

Method Details

__cmp__

public int __cmp__(PyObject ob_other)
Overrides:
__cmp__ in interface PyObject

__contains__

public boolean __contains__(PyObject o)
Overrides:
__contains__ in interface PyObject

__delitem__

public void __delitem__(PyObject key)
Overrides:
__delitem__ in interface PyObject

__eq__

public PyObject __eq__(PyObject ob_other)
Overrides:
__eq__ in interface PyObject

__finditem__

public PyObject __finditem__(int index)
Overrides:
__finditem__ in interface PyObject

__finditem__

public PyObject __finditem__(PyObject key)
Overrides:
__finditem__ in interface PyObject

__iter__

public PyObject __iter__()
Overrides:
__iter__ in interface PyObject

__len__

public int __len__()
Overrides:
__len__ in interface PyObject

__ne__

public PyObject __ne__(PyObject ob_other)
Overrides:
__ne__ in interface PyObject

__nonzero__

public boolean __nonzero__()
Overrides:
__nonzero__ in interface PyObject

__setitem__

public void __setitem__(PyObject key,
                        PyObject value)
Overrides:
__setitem__ in interface PyObject

clear

public void clear()
Remove all items from the dictionary.

copy

public PyDictionary copy()
Return a shallow copy of the dictionary.

fromkeys

public static PyObject fromkeys(PyObject keys)

fromkeys

public static PyObject fromkeys(PyObject keys,
                                PyObject value)

get

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 dictionary.

get

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 dictionary.
default_object - the value to return if the key does not exists in the mapping.

has_key

public boolean has_key(PyObject key)
Return true if the key exist in the dictionary.

hashCode

public int hashCode()
Overrides:
hashCode in interface PyObject

isSequenceType

public boolean isSequenceType()
Overrides:
isSequenceType in interface PyObject

items

public PyList items()
Return a copy of the dictionarys list of (key, value) tuple pairs.

iteritems

public PyObject iteritems()
Return an interator over (key, value) pairs.

iterkeys

public PyObject iterkeys()
Return an interator over (key, value) pairs.

itervalues

public PyObject itervalues()
Return an interator over (key, value) pairs.

keys

public PyList keys()
Return a copy of the dictionarys list of keys.

pop

public PyObject pop(PyObject key)
Return a value based on key from the dictionary.

pop

public PyObject pop(PyObject key,
                    PyObject defaultValue)
Return a value based on key from the dictionary or default if that key is not found.

popitem

public PyObject popitem()
Return a random (key, value) tuple pair and remove the pair from the dictionary.

setdefault

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 dictionary.

setdefault

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 dictionary.
failobj - the default value to insert in the dictionary if key does not already exist.

toString

public String toString()
Overrides:
toString in interface PyObject

typeSetup

public static void typeSetup(PyObject dict,
                             PyType.Newstyle marker)
Overrides:
typeSetup in interface PyObject

update

public void update(PyObject d)
Insert all the key:value pairs from d into this dictionary.

values

public PyList values()
Return a copy of the dictionarys list of values.

Jython homepage