Title / Description
Code package kr.go.incheon.fire.erss.map; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; public class MapMgr { private ObjectMapper mapper; private HashMap<String, MapInfo> dataMap; private List<MapInfo> listMapSearchAll; public MapMgr() { mapper = new ObjectMapper(); } public MapMgr(String filePath) throws JsonParseException, JsonMappingException, IOException { mapper = new ObjectMapper(); mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); TypeReference<HashMap<String, MapInfo>> typeRef = new TypeReference<HashMap<String, MapInfo>>() {}; dataMap = mapper.readValue(new File(filePath), typeRef); } public void setMapDataSearchAllPath(String filePath) throws JsonParseException, JsonMappingException, IOException { TypeReference<ArrayList<MapInfo>> typeRef = new TypeReference<ArrayList<MapInfo>>() {}; listMapSearchAll = mapper.readValue(new File(filePath), typeRef); } public HashMap<String, MapInfo> getDataMap() { return this.dataMap; } public MapInfo getMap(String mapName) { if (dataMap.containsKey(mapName)) { return dataMap.get(mapName); } return null; } public boolean containsMap(String mapName) { return dataMap.containsKey(mapName) ? true : false; } public List<MapInfo> getListMapSearchALl() { List<MapInfo> alistRet = new ArrayList<MapInfo>(); alistRet.addAll(this.listMapSearchAll); return alistRet; } }
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code