01: package com.calipso.reportgenerator.services;
02:
03: import java.util.*;
04:
05: /**
06: * Esta clase contine la información del Exernal Connection String del data source definition del data source
07: */
08:
09: 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(
18: "ExternalConnectionString").toString();
19: initValuesFromString();
20: }
21: }
22: if (this .connectionString.equals("")) {
23: getValues().putAll(values);
24: }
25:
26: }
27:
28: /**
29: * Carga los values parseando los valores del connectionString
30: */
31: private void initValuesFromString() {
32: String set;
33: String key;
34: String value;
35: int index;
36: StringTokenizer stringTokenizer = new StringTokenizer(
37: this .connectionString, ";");
38: for (int i = 0; stringTokenizer.hasMoreTokens(); i++) {
39: set = stringTokenizer.nextToken();
40: index = set.indexOf("=");
41: key = set.substring(0, index);
42: value = set.substring(index + 1, set.length());
43: getValues().put(key, value);
44: }
45:
46: }
47:
48: public Map getValues() {
49: if (values == null) {
50: values = new HashMap();
51: }
52: return values;
53: }
54:
55: /**
56: * Retorna el valor de una entrada
57: * @param key
58: * @return
59: */
60: public String getValue(String key) {
61: String returnString = "";
62: if (getValues().containsKey(key)) {
63: returnString = (String) getValues().get(key);
64: }
65: return returnString;
66: }
67: }
|