001: /*
002: * Copyright 2006-2007 The Scriptella Project Team.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package scriptella.configuration;
017:
018: import java.util.Map;
019:
020: /**
021: * Connection configuration element.
022: *
023: * @author Fyodor Kupolov
024: * @version 1.0
025: */
026: public class ConnectionEl extends XmlConfigurableBase {
027: private String id;
028: private String url;
029: private String driver;
030: private String user;
031: private String password;
032: private String catalog;
033: private String schema;
034: private String classpath;
035: private PropertiesEl properties;
036: private boolean lazyInit;
037:
038: public ConnectionEl() {
039: }
040:
041: public String getId() {
042: return id;
043: }
044:
045: public void setId(final String id) {
046: this .id = id;
047: }
048:
049: public String getUrl() {
050: return url;
051: }
052:
053: public void setUrl(final String url) {
054: this .url = url;
055: }
056:
057: public String getDriver() {
058: return driver;
059: }
060:
061: public void setDriver(final String driver) {
062: this .driver = driver;
063: }
064:
065: public String getUser() {
066: return user;
067: }
068:
069: public void setUser(final String user) {
070: this .user = user;
071: }
072:
073: public String getPassword() {
074: return password;
075: }
076:
077: public void setPassword(final String password) {
078: this .password = password;
079: }
080:
081: public String getCatalog() {
082: return catalog;
083: }
084:
085: public void setCatalog(final String catalog) {
086: this .catalog = catalog;
087: }
088:
089: public String getSchema() {
090: return schema;
091: }
092:
093: public void setSchema(final String schema) {
094: this .schema = schema;
095: }
096:
097: public String getClasspath() {
098: return classpath;
099: }
100:
101: public void setClasspath(String 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<String, ?> getProperties() {
117: return properties.getMap();
118: }
119:
120: public void configure(final XmlElement element) {
121: setProperty(element, "id");
122: setProperty(element, "url");
123: setRequiredProperty(element, "driver");
124: setProperty(element, "user");
125: setProperty(element, "password");
126: setProperty(element, "catalog");
127: setProperty(element, "schema");
128: setProperty(element, "classpath");
129: lazyInit = element.getBooleanAttribute("lazy-init", false);
130: setProperty(element, "classpath");
131: properties = new PropertiesEl(element);
132: }
133:
134: public String toString() {
135: StringBuilder res = new StringBuilder("Connection{driver='")
136: .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: }
|