1 package com.calipso.reportgenerator.services; 2 3 import java.util.*; 4 5 8 9 public class DataSourceDefinitionConnectionString { 10 11 private Map values; 12 private String connectionString=""; 13 14 public DataSourceDefinitionConnectionString(Map values) { 15 if (values.containsKey("ExternalConnectionString")){ 16 if ( values.get("ExternalConnectionString") != null){ 17 this.connectionString = values.get("ExternalConnectionString").toString(); 18 initValuesFromString(); 19 } 20 } 21 if (this.connectionString.equals("")){ 22 getValues().putAll(values); 23 } 24 25 } 26 27 30 private void initValuesFromString() { 31 String set; 32 String key; 33 String value; 34 int index; 35 StringTokenizer stringTokenizer = new StringTokenizer(this.connectionString,";"); 36 for(int i=0 ; stringTokenizer.hasMoreTokens() ; i++){ 37 set = stringTokenizer.nextToken(); 38 index = set.indexOf("="); 39 key = set.substring(0,index); 40 value = set.substring(index+1,set.length()); 41 getValues().put(key,value); 42 } 43 44 45 } 46 47 public Map getValues() { 48 if (values==null){ 49 values = new HashMap(); 50 } 51 return values; 52 } 53 54 59 public String getValue(String key){ 60 String returnString=""; 61 if (getValues().containsKey(key)){ 62 returnString = (String )getValues().get(key); 63 } 64 return returnString; 65 } 66 } 67 | Popular Tags |