001: /*
002: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
007: *
008: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
009: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
010: * the license for the specific language governing your rights and limitations.
011: *
012: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
013: */
014: package org.pentaho.reportdesigner.crm.report.datasetplugin.multidataset;
015:
016: import org.gjt.xpp.XmlPullNode;
017: import org.gjt.xpp.XmlPullParserException;
018: import org.jetbrains.annotations.NotNull;
019: import org.jetbrains.annotations.Nullable;
020: import org.pentaho.reportdesigner.crm.report.PropertyKeys;
021: import org.pentaho.reportdesigner.lib.common.xml.XMLContext;
022: import org.pentaho.reportdesigner.lib.common.xml.XMLExternalizable;
023: import org.pentaho.reportdesigner.lib.common.xml.XMLWriter;
024:
025: import java.io.IOException;
026:
027: /**
028: * User: Martin
029: * Date: 21.07.2006
030: * Time: 12:54:42
031: */
032: public class JNDISource implements XMLExternalizable {
033: @NotNull
034: private String jndiName;
035: @NotNull
036: private String driverClass;
037: @NotNull
038: private String connectionString;
039: @NotNull
040: private String username;
041: @NotNull
042: private String password;
043:
044: public JNDISource() {
045: jndiName = "";
046: driverClass = "";
047: connectionString = "";
048: username = "";
049: password = "";
050: }
051:
052: public JNDISource(@NotNull
053: String jndiName, @NotNull
054: String driverClass, @NotNull
055: String connectionString, @NotNull
056: String username, @NotNull
057: String password) {
058: this .jndiName = jndiName;
059: this .driverClass = driverClass;
060: this .connectionString = connectionString;
061: this .username = username;
062: this .password = password;
063: }
064:
065: @NotNull
066: public String getConnectionString() {
067: return connectionString;
068: }
069:
070: public void setConnectionString(@NotNull
071: String connectionString) {
072: this .connectionString = connectionString;
073: }
074:
075: @NotNull
076: public String getDriverClass() {
077: return driverClass;
078: }
079:
080: public void setDriverClass(@NotNull
081: String driverClass) {
082: this .driverClass = driverClass;
083: }
084:
085: @NotNull
086: public String getJndiName() {
087: return jndiName;
088: }
089:
090: public void setJndiName(@NotNull
091: String jndiName) {
092: this .jndiName = jndiName;
093: }
094:
095: @NotNull
096: public String getPassword() {
097: return password;
098: }
099:
100: public void setPassword(@NotNull
101: String password) {
102: this .password = password;
103: }
104:
105: @NotNull
106: public String getUsername() {
107: return username;
108: }
109:
110: public void setUsername(@NotNull
111: String username) {
112: this .username = username;
113: }
114:
115: public boolean equals(@Nullable
116: Object o) {
117: if (this == o)
118: return true;
119: if (o == null || getClass() != o.getClass())
120: return false;
121:
122: final JNDISource that = (JNDISource) o;
123:
124: return jndiName.equals(that.jndiName);
125: }
126:
127: public int hashCode() {
128: return jndiName.hashCode();
129: }
130:
131: public void externalizeObject(@NotNull
132: XMLWriter xmlWriter, @NotNull
133: XMLContext xmlContext) throws IOException {
134: xmlWriter.writeAttribute(PropertyKeys.JNDI_NAME, jndiName);
135: xmlWriter
136: .writeAttribute(PropertyKeys.DRIVER_CLASS, driverClass);
137: xmlWriter.writeAttribute(PropertyKeys.CONNECTION_STRING,
138: connectionString);
139: xmlWriter.writeAttribute(PropertyKeys.USER_NAME, username);
140: xmlWriter.writeAttribute(PropertyKeys.PASSWORD, password);
141: }
142:
143: public void readObject(@NotNull
144: XmlPullNode node, @NotNull
145: XMLContext xmlContext) throws IOException, XmlPullParserException {
146: jndiName = node
147: .getAttributeValueFromRawName(PropertyKeys.JNDI_NAME);
148: driverClass = node
149: .getAttributeValueFromRawName(PropertyKeys.DRIVER_CLASS);
150: connectionString = node
151: .getAttributeValueFromRawName(PropertyKeys.CONNECTION_STRING);
152: username = node
153: .getAttributeValueFromRawName(PropertyKeys.USER_NAME);
154: password = node
155: .getAttributeValueFromRawName(PropertyKeys.PASSWORD);
156:
157: }
158: }
|