001: /*
002: * Copyright (c) 2001 Silvere Martin-Michiellot All Rights Reserved.
003: *
004: * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
005: * royalty free, license to use, modify and redistribute this
006: * software in source and binary code form,
007: * provided that i) this copyright notice and license appear on all copies of
008: * the software; and ii) Licensee does not utilize the software in a manner
009: * which is disparaging to Silvere Martin-Michiellot.
010: *
011: * This software is provided "AS IS," without a warranty of any kind. ALL
012: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
013: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
014: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
015: * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
016: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
017: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
018: * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
019: * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
020: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
021: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
022: * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
023: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
024: *
025: * This software is not designed or intended for use in on-line control of
026: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
027: * the design, construction, operation or maintenance of any nuclear
028: * facility. Licensee represents and warrants that it will not use or
029: * redistribute the Software for such purposes.
030: *
031: * @Author: Silvere Martin-Michiellot
032: *
033: */
034:
035: package com.db.server;
036:
037: import java.lang.IllegalArgumentException;
038: import java.security.PublicKey;
039: import java.util.*;
040: import javax.media.j3d.*;
041:
042: /**
043: */
044:
045: public class WorldSpotBasicInformation {
046:
047: private final static String STRING_DATE = "Date";
048: private final static String STRING_CREATOR_NAME = "Creator Name";
049: private final static String STRING_CREATOR_E_MAIL = "Creator e-mail";
050: private final static String STRING_CREATOR_PUBLIC_KEY = "Creator Public Key";
051: private final static String STRING_NAME = "Name";
052: private final static String STRING_VERSION = "Version";
053:
054: private Bounds bounds;
055: private Avatar ruler;
056: private Hashtable information;
057:
058: public WorldSpotBasicInformation(Avatar ruler, Bounds bounds,
059: Hashtable information) {
060:
061: this .bounds = bounds;
062: this .ruler = ruler;
063: this .information = information;
064:
065: }
066:
067: public final Bounds getBounds() {
068:
069: return this .bounds;
070:
071: }
072:
073: public final void setBounds(Bounds bounds) {
074:
075: this .bounds = bounds;
076:
077: }
078:
079: public final Avatar getRuler() {
080:
081: return this .ruler;
082:
083: }
084:
085: public final void setRuler(Avatar ruler) {
086:
087: this .ruler = ruler;
088:
089: }
090:
091: public final Hashtable getInformation() {
092:
093: information.put(WorldSpotBasicInformation.STRING_DATE, this
094: .getDate());
095: information.put(WorldSpotBasicInformation.STRING_CREATOR_NAME,
096: this .getCreatorName());
097: information.put(
098: WorldSpotBasicInformation.STRING_CREATOR_E_MAIL, this
099: .getCreatorEMail());
100: information.put(
101: WorldSpotBasicInformation.STRING_CREATOR_PUBLIC_KEY,
102: this .getCreatorPublicKey());
103: information.put(WorldSpotBasicInformation.STRING_NAME, this
104: .getName());
105: information.put(WorldSpotBasicInformation.STRING_VERSION, this
106: .getVersion());
107:
108: return information;
109:
110: }
111:
112: public final Object getInformation(String key) {
113:
114: return information.get(key);
115:
116: }
117:
118: public final Date getDate() {
119:
120: return (Date) this
121: .getInformation(WorldSpotBasicInformation.STRING_DATE);
122:
123: }
124:
125: public final String getCreatorName() {
126:
127: return (String) this
128: .getInformation(WorldSpotBasicInformation.STRING_CREATOR_NAME);
129:
130: }
131:
132: public final String getCreatorEMail() {
133:
134: return (String) this
135: .getInformation(WorldSpotBasicInformation.STRING_CREATOR_E_MAIL);
136:
137: }
138:
139: public final PublicKey getCreatorPublicKey() {
140:
141: return (PublicKey) this
142: .getInformation(WorldSpotBasicInformation.STRING_CREATOR_PUBLIC_KEY);
143:
144: }
145:
146: public final String getName() {
147:
148: return (String) this
149: .getInformation(WorldSpotBasicInformation.STRING_NAME);
150:
151: }
152:
153: public final String getVersion() {
154:
155: return (String) this
156: .getInformation(WorldSpotBasicInformation.STRING_VERSION);
157:
158: }
159:
160: public final void setDate(Date date) {
161:
162: this .addInformation(WorldSpotBasicInformation.STRING_DATE, date
163: .toString());
164:
165: }
166:
167: public final void setCreatorName(String name) {
168:
169: this .addInformation(
170: WorldSpotBasicInformation.STRING_CREATOR_NAME, name);
171:
172: }
173:
174: public final void setCreatorEMail(String eMail) {
175:
176: this .addInformation(
177: WorldSpotBasicInformation.STRING_CREATOR_E_MAIL, eMail);
178:
179: }
180:
181: public final void setCreatorPublicKey(PublicKey publicKey) {
182:
183: this .addInformation(
184: WorldSpotBasicInformation.STRING_CREATOR_PUBLIC_KEY,
185: publicKey.toString());
186:
187: }
188:
189: public final void setName(String name) {
190:
191: this
192: .addInformation(WorldSpotBasicInformation.STRING_NAME,
193: name);
194:
195: }
196:
197: public final void setVersion(String version) {
198:
199: this .addInformation(WorldSpotBasicInformation.STRING_VERSION,
200: version);
201:
202: }
203:
204: //obliterates every previously stored information including reserved fields
205: public final void setInformation(Hashtable information) {
206:
207: this .information = information;
208:
209: }
210:
211: //use the corresponding method to set the individual default fields
212: public final void addInformation(String key, String keyValue) {
213:
214: //check if it is a reserved field or not
215: if ((key != WorldSpotBasicInformation.STRING_DATE)
216: && (key != WorldSpotBasicInformation.STRING_CREATOR_NAME)
217: && (key != WorldSpotBasicInformation.STRING_CREATOR_E_MAIL)
218: && (key != WorldSpotBasicInformation.STRING_CREATOR_PUBLIC_KEY)
219: && (key != WorldSpotBasicInformation.STRING_NAME)
220: && (key != WorldSpotBasicInformation.STRING_VERSION)) {
221: this .information.put(key, keyValue);
222: } else {
223: throw new IllegalArgumentException(
224: "You can't add directly Information on the restricted fields.");
225: }
226:
227: }
228:
229: public final void removeInformation(String key) {
230:
231: //check if it is a reserved field or not
232: if ((key != WorldSpotBasicInformation.STRING_DATE)
233: && (key != WorldSpotBasicInformation.STRING_CREATOR_NAME)
234: && (key != WorldSpotBasicInformation.STRING_CREATOR_E_MAIL)
235: && (key != WorldSpotBasicInformation.STRING_CREATOR_PUBLIC_KEY)
236: && (key != WorldSpotBasicInformation.STRING_NAME)
237: && (key != WorldSpotBasicInformation.STRING_VERSION)) {
238: this .information.remove(key);
239: } else {
240: throw new IllegalArgumentException(
241: "You can't remove directly Information on the restricted fields.");
242: }
243:
244: }
245:
246: }
|