import java.util.*; import java.io.*; /* * This class serves a data repository for the pdf/xml tag pairs: * the file that is read in must be in the format: * name:NAME * product ID:PROD_ID * ... * Where everything on the left side of the colon (:) is the pdf tag * and everything on the right side of the colon to the end of line * is the corresponding xml tag */ public class Plug_n_PlayMap{ public Plug_n_PlayMap(String filename){ // open a file and fill the hashtable with the data. myTags = new Hashtable (); try{ BufferedReader br = new BufferedReader(new FileReader(filename)); StringTokenizer st; String line; String currentToken= ""; while((line = br.readLine())!=null) { st = new StringTokenizer(line, ":"); while(st.hasMoreTokens()) { String key = st.nextToken(); String val = st.nextToken(); myTags.put(key, val); } } br.close(); } catch (Exception e) { System.err.println(e.getMessage()); } } /* * This method gets the xml tag that is associated with the pdf template tag */ public Object get(Object pdf){ return myTags.get(pdf); } private Hashtable myTags; }