Issue1816103

classification
Title: org.python.core.PyDictionary should implement java.util.Map
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: byronf, cgroves, hdiwan650, thobes
Priority: normal Keywords:

Created on 2007-10-18.20:18:55 by hdiwan650, last changed 2007-12-12.09:49:59 by cgroves.

Files
File name Uploaded Description Edit Remove
jythonDictMap.pat hdiwan650, 2007-10-18.21:18:22 Complete Implementation
Messages
msg1983 (view) Author: Hasan Diwan (hdiwan650) Date: 2007-10-18.20:18:55
The attached patch adds methods to make org.python.core.PyDictionary a drop-in for wherever java.util.Map is required.
msg1984 (view) Author: Hasan Diwan (hdiwan650) Date: 2007-10-18.21:06:42
Complete implementation
File Added: jythonDictMap.pat
msg1985 (view) Author: Hasan Diwan (hdiwan650) Date: 2007-10-18.21:18:22
Oops! putAll was missing -- added it in. This is the last update for today, I promise.
File Added: jythonDictMap.pat
msg1986 (view) Author: Tobias Ivarsson (thobes) Date: 2007-10-19.17:08:36
Some comments on the patch.
I think that it is a great idea to make the jython types more compatible with the common java types. This could be targeted in jython 2.5+, but it will probably follow with a number of other changes.


Some comments on the implementation in this patch:

This patch changes more than it is supposed to implement. What is the motivation behind making all parameters final?

containsValue : should, as the name implies, check if the Map contains a mapping with the argument as value, i.e. not as key, which is was __contains__ checks for.

entrySet : should return a set of Map.Entry objects, that is objects that contains both the key and the value. So we will probably use a loop to create these, or return our own specific set that creates these objects on the fly.

keySet : should return a set of the keys in the Map, the same as dict.keys() in python.

put: should return the old value associated with the key, so you'll need to __getitem__ it before you invoke __setitem__

putAll : this is actually quite simple to implement just iterate over arg0.entrySet() and add the key mapped to the value for each entry in that set.

remove : should remove the binding associated with the key, not associate it with null. Use __delitem__ here instead.

msg1987 (view) Author: Byron Foster (byronf) Date: 2007-10-20.10:26:02
Another issue is that the Map methods do not correctly convert null values to Py.None.
msg1988 (view) Author: Byron Foster (byronf) Date: 2007-10-22.02:14:45
I've created a patch that addresses these issues here:
https://sourceforge.net/tracker/index.php?func=detail&aid=1817565&group_id=12867&atid=312867
msg1989 (view) Author: Charlie Groves (cgroves) Date: 2007-12-12.09:49:59
Byron's patch was applied in r3802.
History
Date User Action Args
2007-10-18 20:18:55hdiwan650create