KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scriptella > configuration > ConnectionEl


1 /*
2  * Copyright 2006-2007 The Scriptella Project Team.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package scriptella.configuration;
17
18 import java.util.Map JavaDoc;
19
20 /**
21  * Connection configuration element.
22  *
23  * @author Fyodor Kupolov
24  * @version 1.0
25  */

26 public class ConnectionEl extends XmlConfigurableBase {
27     private String JavaDoc id;
28     private String JavaDoc url;
29     private String JavaDoc driver;
30     private String JavaDoc user;
31     private String JavaDoc password;
32     private String JavaDoc catalog;
33     private String JavaDoc schema;
34     private String JavaDoc classpath;
35     private PropertiesEl properties;
36     private boolean lazyInit;
37
38     public ConnectionEl() {
39     }
40
41     public String JavaDoc getId() {
42         return id;
43     }
44
45     public void setId(final String JavaDoc id) {
46         this.id = id;
47     }
48
49     public String JavaDoc getUrl() {
50         return url;
51     }
52
53     public void setUrl(final String JavaDoc url) {
54         this.url = url;
55     }
56
57     public String JavaDoc getDriver() {
58         return driver;
59     }
60
61     public void setDriver(final String JavaDoc driver) {
62         this.driver = driver;
63     }
64
65     public String JavaDoc getUser() {
66         return user;
67     }
68
69     public void setUser(final String JavaDoc user) {
70         this.user = user;
71     }
72
73     public String JavaDoc getPassword() {
74         return password;
75     }
76
77     public void setPassword(final String JavaDoc password) {
78         this.password = password;
79     }
80
81     public String JavaDoc getCatalog() {
82         return catalog;
83     }
84
85     public void setCatalog(final String JavaDoc catalog) {
86         this.catalog = catalog;
87     }
88
89     public String JavaDoc getSchema() {
90         return schema;
91     }
92
93     public void setSchema(final String JavaDoc schema) {
94         this.schema = schema;
95     }
96
97     public String JavaDoc getClasspath() {
98         return classpath;
99     }
100
101     public void setClasspath(String JavaDoc classpath) {
102         this.classpath = classpath;
103     }
104
105     public boolean isLazyInit() {
106         return lazyInit;
107     }
108
109     public void setLazyInit(boolean lazyInit) {
110         this.lazyInit = lazyInit;
111     }
112
113     /**
114      * @return Map of properties for this connection.
115      */

116     public Map JavaDoc<String JavaDoc, ?> getProperties() {
117         return properties.getMap();
118     }
119
120
121     public void configure(final XmlElement element) {
122         setProperty(element, "id");
123         setProperty(element, "url");
124         setRequiredProperty(element, "driver");
125         setProperty(element, "user");
126         setProperty(element, "password");
127         setProperty(element, "catalog");
128         setProperty(element, "schema");
129         setProperty(element, "classpath");
130         lazyInit = element.getBooleanAttribute("lazy-init", false);
131         setProperty(element, "classpath");
132         properties = new PropertiesEl(element);
133     }
134
135     public String JavaDoc toString() {
136         StringBuilder JavaDoc res = new StringBuilder JavaDoc("Connection{driver='").append(driver).append('\'');
137
138         res.append("properties=").append(properties);
139         if (classpath != null) {
140             res.append(", classpath='").append(classpath).append('\'');
141         }
142         if (schema != null) {
143             res.append(", schema='").append(schema).append('\'');
144         }
145         if (catalog != null) {
146             res.append(", catalog='").append(catalog).append('\'');
147         }
148         if (password != null) {
149             res.append(", password='").append(password).append('\'');
150         }
151         if (user != null) {
152             res.append(", user='").append(user).append('\'');
153         }
154         if (url != null) {
155             res.append(", url='").append(url).append('\'');
156         }
157         if (id != null) {
158             res.append(", id='").append(id).append('\'' + '}');
159         }
160
161         return res.toString();
162     }
163 }
164
Popular Tags