1 5 6 32 package xeus.bottomline.util; 33 34 import java.util.Collections ; 35 import java.util.HashMap ; 36 import java.util.Map ; 37 38 import xeus.bottomline.exception.BottomlineException; 39 40 44 public class JdbcUrl { 45 46 private String absoluteUrl; 47 private Map queryMap; 48 private String url; 49 50 private JdbcUrl() { 51 } 52 53 58 public static synchronized JdbcUrl parse(String absoluteUrl) 59 throws BottomlineException { 60 Map query = Collections.synchronizedMap(new HashMap ()); 61 62 String lquery; 63 64 String urlParts[] = absoluteUrl.split("\\?"); 65 66 String url = urlParts[0]; 67 68 if (urlParts.length > 1) { 69 70 if (urlParts.length != 2) 71 throw new BottomlineException("Malformed Connection URL"); 72 73 lquery = urlParts[1]; 74 75 String params[] = lquery.split("&"); 76 77 for (int i = 0; i < params.length; i++) { 78 String keyVal[] = params[i].split("="); 79 80 if (keyVal.length == 2) 81 query.put(keyVal[0], keyVal[1]); 82 else 83 query.put(keyVal[0], null); 84 } 85 } 86 87 JdbcUrl jurl = new JdbcUrl(); 88 jurl.setAbsoluteUrl(absoluteUrl); 89 jurl.setQueryMap(query); 90 jurl.setUrl(url); 91 92 return jurl; 93 } 94 95 98 public String getAbsoluteUrl() { 99 return absoluteUrl; 100 } 101 102 105 public void setAbsoluteUrl(String absoluteUrl) { 106 this.absoluteUrl = absoluteUrl; 107 } 108 109 112 public Map getQueryMap() { 113 return queryMap; 114 } 115 116 119 public void setQueryMap(Map queryMap) { 120 this.queryMap = queryMap; 121 } 122 123 126 public String getUrl() { 127 return url; 128 } 129 130 133 public void setUrl(String url) { 134 this.url = url; 135 } 136 } 137 | Popular Tags |