KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > services > DataSourceDefinitionConnectionString


1 package com.calipso.reportgenerator.services;
2
3 import java.util.*;
4
5 /**
6  * Esta clase contine la información del Exernal Connection String del data source definition del data source
7  */

8
9 public class DataSourceDefinitionConnectionString {
10
11   private Map values;
12   private String JavaDoc 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   /**
28    * Carga los values parseando los valores del connectionString
29    */

30   private void initValuesFromString() {
31     String JavaDoc set;
32     String JavaDoc key;
33     String JavaDoc 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   /**
55    * Retorna el valor de una entrada
56    * @param key
57    * @return
58    */

59   public String JavaDoc getValue(String JavaDoc key){
60     String JavaDoc returnString="";
61     if (getValues().containsKey(key)){
62       returnString = (String JavaDoc)getValues().get(key);
63     }
64     return returnString;
65   }
66 }
67
Popular Tags