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.util.*;
038: import javax.jdo.*;
039:
040: /**
041: */
042:
043: public abstract class GuideWorld extends ToolWorld {
044:
045: //please use the fields from this class and not the fields from toolWorld when a duplicate exists
046:
047: //copied from toolWorld: Start
048:
049: //Lords and self are always allowed full rights
050:
051: public final static int NO_CAPABILITY = 0;
052:
053: public final static int SALABLE = 1;
054: public final static int RESHAPEABLE = 2;
055: public final static int SOUNDALTERABLE = 4;
056: public final static int VISIBLE = 8;
057: public final static int SONORE = 16;
058: public final static int MOVABLE = 32;
059: public final static int COLLIDABLE = 64;
060: public final static int INVENTORIZABLE = 128;
061: public final static int ACCESSORY = 256;
062: public final static int CUTABLE = 512;
063: public final static int GLUABLE = 1024;
064: public final static int DUPLICABLE = 2048;
065: public final static int GENERIC = 4096;
066: public final static int HEADUP = 8192;
067: public final static int FERTILE = 16384;
068: public final static int MANIPULATES = 32768;
069: public final static int SUPPRESSOR = 65536;
070:
071: //copied from toolWorld: End
072:
073: public final static int REMOTEVIEW = 131072;
074:
075: //copied from toolWorld: Start
076:
077: private static int LAST_CAPABILITY = (GuideWorld.REMOTEVIEW * 2) - 1;
078:
079: public static int DEFAULT_DESIGNER_CAPABILITIES = GuideWorld.LAST_CAPABILITY;
080:
081: public final static int HIDDEN = 0;
082: public final static int READ = 1;
083: public final static int READ_WRITE = 2;
084:
085: //copied from toolWorld: End
086:
087: /**
088: *
089: * input access list (overridden description from tools): objects and tools of the World Spot library (can also be used by owner to
090: * restrict even more the rights of the guide to move through lands or the tools or objects that can be accessed)
091: * output access list (overridden description from tools): objects and tools of the World Spot library (can also be used by owner to
092: * restrict even more the rights of the guide to move through lands or the tools or objects that can be accessed)
093: * Capabilities (4 booleans grant access for invited lords, peers, peers vassals and vassals) existence locked by designer:
094: * remote view (an avatar can see through the eyes of this guide as if it was the guide using a specific tool)
095: * skin (joint and segments H-Anim)
096: * accessories (visible tools worn on the body but accessible from the inventory)
097: * verbals (words that can be pronounced by the guide's skin mouth as skin deformation and sound emission)
098: * movements (overall body movements)
099: * gestures (particular joint and segment combination movements without global movement)
100: * textual avatar information (how the owner perceives its guide, sex, age, v-e-mail, v-address, v-phone in an hashtable with
101: * empty fields)
102: * inventory (this inventory is specific to the guide but can be accessed by its owner)
103: */
104:
105: public final static String STRING_GUIDE_NAME = "V-Name";
106: public final static String STRING_GUIDE_FIRSTNAME = "V-Firstname";
107: public final static String STRING_GUIDE_SEX = "V-Sex";
108: public final static String STRING_GUIDE_AGE = "V-Age";
109: public final static String STRING_GUIDE_E_MAIL = "V-e-mail";
110: public final static String STRING_GUIDE_ADDRESS = "V-Address";
111: public final static String STRING_GUIDE_PHONE = "V-Phone";
112:
113: private Skin skin;
114: private HashSet inventory;
115:
116: //not a real extension of constructor
117: public GuideWorld(UniverseServer universeServer, Avatar userOwner) {
118:
119: super (universeServer, userOwner);
120: inventory = new HashSet();
121:
122: }
123:
124: //every "get" or "set" or "add" or "remove" call assumes valid user's rights (depending on who calls)
125: //otherwise the server returns a request refused message
126:
127: // guide name, firstame, sex, age, e-mail, address, phone
128: // be cautious with this method as it obliterates the avatar name, firstame, sex, age, e-mail, address, phone
129: //obliterates every previously stored information including reserved fields
130: public final void setInformation(Hashtable information) {
131:
132: super .setInformation(information);
133:
134: }
135:
136: //use the corresponding method to set the individual default fields
137: public final void addInformation(String key, String keyValue) {
138:
139: //check if it is a reserved field or not
140: if ((key != VirtualElement.STRING_DATE)
141: && (key != VirtualElement.STRING_AUTHOR_NAME)
142: && (key != VirtualElement.STRING_AUTHOR_E_MAIL)
143: && (key != VirtualElement.STRING_AUTHOR_PUBLIC_KEY)
144: && (key != VirtualElement.STRING_NAME)
145: && (key != VirtualElement.STRING_VERSION)
146: && (key != GuideWorld.STRING_GUIDE_NAME)
147: && (key != GuideWorld.STRING_GUIDE_FIRSTNAME)
148: && (key != GuideWorld.STRING_GUIDE_SEX)
149: && (key != GuideWorld.STRING_GUIDE_AGE)
150: && (key != GuideWorld.STRING_GUIDE_E_MAIL)
151: && (key != GuideWorld.STRING_GUIDE_ADDRESS)
152: && (key != GuideWorld.STRING_GUIDE_PHONE)) {
153: this .information.put(key, keyValue);
154: this .setDirty();
155: this .doInformationChanged();
156: } else {
157: throw new IllegalArgumentException(
158: "You can't add directely Information on the restricted fields.");
159: }
160:
161: }
162:
163: public final void removeInformation(String key) {
164:
165: //check if it is a reserved field or not
166: if ((key != VirtualElement.STRING_DATE)
167: && (key != VirtualElement.STRING_AUTHOR_NAME)
168: && (key != VirtualElement.STRING_AUTHOR_E_MAIL)
169: && (key != VirtualElement.STRING_AUTHOR_PUBLIC_KEY)
170: && (key != VirtualElement.STRING_NAME)
171: && (key != VirtualElement.STRING_VERSION)
172: && (key != GuideWorld.STRING_GUIDE_NAME)
173: && (key != GuideWorld.STRING_GUIDE_FIRSTNAME)
174: && (key != GuideWorld.STRING_GUIDE_SEX)
175: && (key != GuideWorld.STRING_GUIDE_AGE)
176: && (key != GuideWorld.STRING_GUIDE_E_MAIL)
177: && (key != GuideWorld.STRING_GUIDE_ADDRESS)
178: && (key != GuideWorld.STRING_GUIDE_PHONE)) {
179: this .information.remove(key);
180: this .setDirty();
181: this .doInformationChanged();
182: } else {
183: throw new IllegalArgumentException(
184: "You can't remove directely Information on the restricted fields.");
185: }
186:
187: }
188:
189: //uses the key V-Name
190: public String getGuideName() {
191:
192: return (String) this
193: .getInformation(GuideWorld.STRING_GUIDE_NAME);
194:
195: }
196:
197: //uses the key V-Name
198: public void setGuideName(String name) {
199:
200: this .addInformation(GuideWorld.STRING_GUIDE_NAME, name);
201: this .setDirty();
202: this .doInformationChanged();
203:
204: }
205:
206: //uses the key V-Firstname
207: public String getGuideFirstname() {
208:
209: return (String) this
210: .getInformation(GuideWorld.STRING_GUIDE_FIRSTNAME);
211:
212: }
213:
214: //uses the key V-Firstname
215: public void setGuideFirstname(String firstname) {
216:
217: this .addInformation(GuideWorld.STRING_GUIDE_FIRSTNAME,
218: firstname);
219: this .setDirty();
220: this .doInformationChanged();
221:
222: }
223:
224: //uses the key V-Sex (should be either male, female, other)
225: public String getGuideSex() {
226:
227: return (String) this
228: .getInformation(GuideWorld.STRING_GUIDE_SEX);
229:
230: }
231:
232: //uses the key V-Sex (should be either male, female, other)
233: public void setGuideSex(String sex) {
234:
235: this .addInformation(GuideWorld.STRING_GUIDE_SEX, sex);
236: this .setDirty();
237: this .doInformationChanged();
238:
239: }
240:
241: //uses the key V-Age (this is a String with numerical caracters only)
242: public String getGuideAge() {
243:
244: return (String) this
245: .getInformation(GuideWorld.STRING_GUIDE_AGE);
246:
247: }
248:
249: //uses the key V-Age (this is a String with numerical caracters only)
250: public void setGuideAge(String age) {
251:
252: this .addInformation(GuideWorld.STRING_GUIDE_AGE, age);
253: this .setDirty();
254: this .doInformationChanged();
255:
256: }
257:
258: //uses the key V-e-mail
259: public String getGuideEMail() {
260:
261: return (String) this
262: .getInformation(GuideWorld.STRING_GUIDE_E_MAIL);
263:
264: }
265:
266: //uses the key V-e-mail
267: public void setGuideEMail(String eMail) {
268:
269: this .addInformation(GuideWorld.STRING_GUIDE_E_MAIL, eMail);
270: this .setDirty();
271: this .doInformationChanged();
272:
273: }
274:
275: //uses the key V-Address (virtual world address)
276: public String getGuideAddress() {
277:
278: return (String) this
279: .getInformation(GuideWorld.STRING_GUIDE_ADDRESS);
280:
281: }
282:
283: //uses the key V-Address (virtual world address)
284: public void setGuideAddress(String address) {
285:
286: this .addInformation(GuideWorld.STRING_GUIDE_ADDRESS, address);
287: this .setDirty();
288: this .doInformationChanged();
289:
290: }
291:
292: //uses the key V-Phone (virtual phone number, mostly useless)
293: public String getGuidePhone() {
294:
295: return (String) this
296: .getInformation(GuideWorld.STRING_GUIDE_PHONE);
297:
298: }
299:
300: //uses the key V-Phone (virtual phone number, mostly useless)
301: public void setGuidePhone(String phone) {
302:
303: this .addInformation(GuideWorld.STRING_GUIDE_PHONE, phone);
304: this .setDirty();
305: this .doInformationChanged();
306:
307: }
308:
309: //Guides use the Pass of their owner when they travel
310:
311: public final Skin getSkin() {
312:
313: return this .skin;
314:
315: }
316:
317: //skin owner should be the same as this owner (this is not checked)
318: public final void setSkin(Skin skin) {
319:
320: this .skin = skin;
321: this .setDirty();
322: this .doSkinChanged();
323:
324: }
325:
326: //not a real inventory because object keeps its physical location and properties
327: //but rather a mean to have access to a set of tools
328: //we could use the code from Avatar to provide a different behavior
329: public final HashSet getInventory() {
330:
331: return this .inventory;
332:
333: }
334:
335: public final void setInventory(HashSet inventory) {
336:
337: Iterator iterator;
338: boolean good;
339: Object object;
340:
341: iterator = inventory.iterator();
342: good = true;
343:
344: while (iterator.hasNext() && good) {
345: object = iterator.next();
346: good = (object instanceof ObjectWorld)
347: && (((ObjectWorld) object).getUserOwner() == this
348: .getUserOwner());
349: }
350:
351: if (good) {
352: this .inventory = inventory;
353: this .setDirty();
354: this .doInventoryChanged();
355: }
356:
357: }
358:
359: public final void addInventoryEntry(ObjectWorld objectWorld) {
360:
361: if ((objectWorld != null)
362: && (objectWorld.getUserOwner() == this .getUserOwner())) {
363: this .inventory.add(objectWorld);
364: this .setDirty();
365: this .doInventoryChanged();
366: }
367:
368: }
369:
370: public final void removeInventoryEntry(ObjectWorld objectWorld) {
371:
372: this .inventory.remove(objectWorld);
373: this .setDirty();
374: this .doInventoryChanged();
375:
376: }
377:
378: //input send to the 3D GUI system of object and processed in internal methods
379: //GUI behaviors (provided by the swing3D system)
380:
381: //output tool (or object) or property of a tool (declared in the output access list).
382:
383: //SYSTEM CALLS DEPENDING ON CAPABILITIES
384:
385: protected void processGUI() {
386:
387: super .processGUI();
388:
389: if (this .checkWritable(GuideWorld.REMOTEVIEW)) {
390:
391: this .doRemoteViewStart();
392: this .doRemoteViewStop();
393:
394: }
395:
396: }
397:
398: public int getDesignerCapabilities() {
399:
400: //The designer of the object has to encode the desired feature mask of its object
401: //by setting objectCapabilities
402: //just to ensure no one will subclass his object to do undesired behaviors
403: //Designers should use the modifier "final" to ensure there is no one counterfeiting their identity
404:
405: return super .getDesignerCapabilities();
406:
407: }
408:
409: //time sliced actions
410:
411: public void doSkinChanged() {
412:
413: }
414:
415: public void doInventoryChanged() {
416:
417: }
418:
419: public void doRemoteViewStart() {
420:
421: }
422:
423: public void doRemoteViewStop() {
424:
425: }
426:
427: }
|