KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > engine > clock > TimeZonesMap


1 package org.objectweb.petals.engine.clock;
2
3 import java.io.BufferedReader JavaDoc;
4 import java.io.IOException JavaDoc;
5 import java.io.InputStream JavaDoc;
6 import java.io.InputStreamReader JavaDoc;
7 import java.util.HashMap JavaDoc;
8
9 public class TimeZonesMap {
10     private HashMap JavaDoc<String JavaDoc,Integer JavaDoc> data;
11     
12     public TimeZonesMap(InputStream JavaDoc in) throws IOException JavaDoc{
13         BufferedReader JavaDoc reader = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(in));
14         while(reader.ready()){
15             String JavaDoc line=reader.readLine();
16             int separatorIdx=line.indexOf(':');
17             String JavaDoc city=line.substring(0,separatorIdx-1);
18             Integer JavaDoc timeZone=Integer.parseInt(line.substring(separatorIdx+1));
19             data.put(city,timeZone);
20         }
21     }
22
23     public HashMap JavaDoc<String JavaDoc, Integer JavaDoc> getData() {
24         return data;
25     }
26     
27     public void addTimeZone(String JavaDoc city, Integer JavaDoc timeZone) {
28         data.put(city,timeZone);
29     }
30     
31     public Integer JavaDoc getTimeZone(String JavaDoc city){
32         return data.get(city);
33     }
34     
35 }
36
Popular Tags