Created
September 2, 2011 11:58
-
-
Save jldupont/1188437 to your computer and use it in GitHub Desktop.
GWT Map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Map | |
* | |
* @author jldupont | |
*/ | |
package com.cdf.front.types.client; | |
import java.util.Iterator; | |
import java.util.Set; | |
import com.google.gwt.json.client.JSONObject; | |
import com.google.gwt.json.client.JSONString; | |
public class Map { | |
JSONObject jso=new JSONObject(); | |
public Map() {} | |
public void putFromJso(JSONObject jso) { | |
Set<String> keys=jso.keySet(); | |
Iterator<String> it=keys.iterator(); | |
while(it.hasNext()) { | |
String key=it.next(); | |
this.store(key, jso.get(key).toString()); | |
} | |
} | |
public void store(String key, String value) { | |
jso.put(key, new JSONString(value)); | |
} | |
public String retrieve(String key) { | |
return jso.get(key).isString().stringValue(); | |
} | |
/* | |
* @todo write native method | |
*/ | |
public final void iterate(IMapVisitor<String> visitor) { | |
Set<String> keys=jso.keySet(); | |
Iterator<String> it=keys.iterator(); | |
while (it.hasNext()) { | |
String key=it.next(); | |
visitor.visit(key, this.retrieve(key)); | |
} | |
} | |
}/// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks :)