001: /*
002: * The contents of this file are subject to the Mozilla Public License
003: * Version 1.1 (the "License"); you may not use this file except in
004: * compliance with the License. You may obtain a copy of the License at
005: * http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
009: * License for the specific language governing rights and limitations
010: * under the License.
011: *
012: * The Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
013: *
014: * The Initial Developer of the Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
015: * Portions created by Mark A. Kobold are Copyright (C) 2000-2007. All Rights Reserved.
016: *
017: * Contributor(s):
018: * Mark A. Kobold [mkobold <at> isqlviewer <dot> com].
019: *
020: * If you didn't download this code from the following link, you should check
021: * if you aren't using an obsolete version: http://www.isqlviewer.com
022: */
023: package org.isqlviewer;
024:
025: import java.net.URL;
026: import java.util.Date;
027:
028: /**
029: * Lightweight object to refer to a service definition at runtime.
030: * <p>
031: * Service definitions within iSQL-Viewer can be and most often are heavy objects containing lots of information
032: * regarding how to connect to a specific JDBC resource. This class serves as a lightwieght reference containing only
033: * the basic information required to connect to the service, without having all the service connection information
034: * resident in memory.
035: * <p>
036: *
037: * @author Mark A. Kobold <mkobold at isqlviewer dot com>
038: * @version 1.0
039: */
040: public class ServiceReference {
041:
042: private long id = -1;
043: private String name = null;
044: private int order = -1;
045: private Date lastUsed = null;
046: private Date createdOn = null;
047: private URL resourceURL = null;
048:
049: /**
050: * Gets the unique identifier for this service reference.
051: * <p>
052: * Simply number that unique identifies this service reference within the iSQL-Viewer application. If the Id is -1
053: * or less than 0, then that indicates that this particular service reference instance is not registered within the
054: * application.
055: * <p>
056: * This value has no real value other than uniquely identifying this service.
057: *
058: * @return the id of this service reference.
059: */
060: public long getId() {
061:
062: return id;
063: }
064:
065: /**
066: * Sets the service reference identifier to the specified value.
067: * <p>
068: *
069: * @param id the id to set to uniquely identify this service.
070: */
071: public void setId(long id) {
072:
073: this .id = id;
074: }
075:
076: /**
077: * Gets the common service name for this reference.
078: * <p>
079: * This is the name set by the user when the service definition was created.
080: *
081: * @return the name of the service this instance refers to; can be null if not set.
082: */
083: public String getName() {
084:
085: return name;
086: }
087:
088: /**
089: * Sets the service name this instance refers to.
090: * <p>
091: *
092: * @param name to set as a logical reference for this instance.
093: * @throws NullPointerException if the given name is <tt>null</tt>.
094: * @throws IllegalArgumentException if the given name is blank.
095: */
096: public void setName(String name) {
097:
098: if (name == null) {
099: throw new NullPointerException("name");
100: } else if (name.trim().length() == 0) {
101: throw new IllegalArgumentException("name cannot be blank");
102: }
103: this .name = name;
104: }
105:
106: /**
107: * Gets the preferred order of this service.
108: * <p>
109: * The order refers to the order defined by the user as thier preferred order.
110: *
111: * @return the order of this service as determined by the user.
112: */
113: public int getOrder() {
114:
115: return order;
116: }
117:
118: /**
119: * Sets the order of this service reference.
120: * <p>
121: *
122: * @param order the order to set for this reference.
123: * @throws IllegalArgumentException if the given order is less than zero.
124: */
125: public void setOrder(int order) {
126:
127: this .order = order;
128: }
129:
130: /**
131: * Gets the resource URL containing the service information for this instance.
132: * <p>
133: * This points to the service file containing all the nessecary connection information used to make and configure
134: * JDBC connections made by iSQL-Viewer.
135: * <p>
136: * The idea for using URL versus local file is allow service defintions to be accessed via HTTP and other Java
137: * supported protocols.
138: *
139: * @return the resource URL containing the detailed service connection information.
140: */
141: public URL getResourceURL() {
142:
143: return resourceURL;
144: }
145:
146: /**
147: * Sets the resource URL for this service reference.
148: * <p>
149: *
150: * @param resourceURL to set for this reference.
151: * @throws NullPointerException if the given URL is null.
152: */
153: public void setResourceURL(URL resourceURL) {
154:
155: this .resourceURL = resourceURL;
156: }
157:
158: /**
159: * Gets the last time a connection was made to the referring service by iSQL-Viewer.
160: * <p>
161: *
162: * @return the date and time at which a connection was made to this service.
163: */
164: public Date getLastUsed() {
165:
166: return lastUsed;
167: }
168:
169: /**
170: * Sets the last time a connection was made to this service.
171: * <p>
172: *
173: * @param lastUsed the date and time at which a connection was successfull.
174: */
175: public void setLastUsed(Date lastUsed) {
176:
177: this .lastUsed = lastUsed;
178: }
179:
180: /**
181: * @return the createdOn
182: */
183: public Date getCreatedOn() {
184:
185: return createdOn;
186: }
187:
188: /**
189: * @param createdOn the createdOn to set
190: */
191: public void setCreatedOn(Date createdOn) {
192:
193: this.createdOn = createdOn;
194: }
195: }
|