Source Code Cross Referenced for AspectType.java in  » Science » Cougaar12_4 » org » cougaar » planning » ldm » plan » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » Cougaar12_4 » org.cougaar.planning.ldm.plan 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * <copyright>
003:         *  
004:         *  Copyright 1997-2004 BBNT Solutions, LLC
005:         *  under sponsorship of the Defense Advanced Research Projects
006:         *  Agency (DARPA).
007:         * 
008:         *  You can redistribute this software and/or modify it under the
009:         *  terms of the Cougaar Open Source License as published on the
010:         *  Cougaar Open Source Website (www.cougaar.org).
011:         * 
012:         *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013:         *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014:         *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015:         *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016:         *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017:         *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018:         *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019:         *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020:         *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021:         *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022:         *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023:         *  
024:         * </copyright>
025:         */
026:
027:        package org.cougaar.planning.ldm.plan;
028:
029:        import java.util.HashMap;
030:
031:        /** Constant names for different 'score' dimensions in which to report
032:         * allocation consequences.
033:         **/
034:        public interface AspectType {
035:
036:            /** Undefined value for an aspect type **/
037:            int UNDEFINED = -1;
038:
039:            /** Start time of given Task **/
040:            int START_TIME = 0;
041:
042:            /** End time of given Task **/
043:            int END_TIME = 1;
044:
045:            /** Duration time of the Task **/
046:            int DURATION = 2;
047:
048:            /** Cost (in $) of allocating given Task **/
049:            int COST = 3;
050:
051:            /** Probability of loss of assets associated with allocation **/
052:            int DANGER = 4;
053:
054:            /** Probability of failure of the Mission **/
055:            int RISK = 5;
056:
057:            /** Quantities associated with allocation (number of elements sourced, e.g.) **/
058:            int QUANTITY = 6;
059:
060:            /** For repetitive tasks - specify the amount of time(milliseconds) 
061:             * in between deliveries 
062:             **/
063:            int INTERVAL = 7;
064:
065:            /**For repetitive tasks the total sum quantity of item for the time span **/
066:            int TOTAL_QUANTITY = 8;
067:
068:            /** For repetitive tasks the total number of shipments requested across 
069:             * the time span.
070:             * This should be used in association with the interval aspect.
071:             **/
072:            int TOTAL_SHIPMENTS = 9;
073:
074:            /**   **/
075:            int CUSTOMER_SATISFACTION = 10;
076:
077:            /** Used to represent an Asset/Quantity relationship
078:             * @see org.cougaar.planning.ldm.plan.TypedQuantityAspectValue
079:             **/
080:            int TYPED_QUANTITY = 11;
081:
082:            /** The extent to which a task has been satisfactorily completed **/
083:            int READINESS = 12;
084:
085:            int _LAST_ASPECT = READINESS;
086:            int _ASPECT_COUNT = _LAST_ASPECT + 1;
087:
088:            int[] _STANDARD_ASPECTS = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
089:                    12 };
090:
091:            /** Commonly-used aspect types: START_TIME, END_TIME, COST, QUANTITY **/
092:            int[] CommonAspects = { START_TIME, END_TIME, COST, QUANTITY };
093:
094:            /** Time Aspects: START_TIME, END_TIME **/
095:            int[] TimeAspects = { START_TIME, END_TIME };
096:
097:            // extended AspectTypes that are NOT handled by default
098:            // AllocationResultAggregators or AllocationResultDistributors
099:
100:            /** The point of debarkation of a task **/
101:            int POD = 13;
102:
103:            /** The time at which a task should arrive at the POD **/
104:            int POD_DATE = 14;
105:
106:            /** The number of core-defined aspect types **/
107:            int N_CORE_ASPECTS = 15;
108:
109:            String[] ASPECT_STRINGS = { "START_TIME", "END_TIME", "DURATION",
110:                    "COST", "DANGER", "RISK", "QUANTITY", "INTERVAL",
111:                    "TOTAL_QUANTITY", "TOTAL_SHIPMENTS",
112:                    "CUSTOMER_SATISFACTION", "TYPED_QUANTITY", "READINESS",
113:                    "POD", "POD_DATE" };
114:
115:            interface Factory {
116:                /** the key of the AspectType **/
117:                int getKey();
118:
119:                /** The name of the AspectType **/
120:                String getName();
121:
122:                /** The factory to use for creating AspectValues of the AspectType. **/
123:                AspectValue newAspectValue(Object o);
124:            }
125:
126:            /** Undefined - Illegal to use **/
127:            Factory Undefined = new Factory() {
128:                public int getKey() {
129:                    return -1;
130:                }
131:
132:                public String getName() {
133:                    return "Undefined";
134:                }
135:
136:                public AspectValue newAspectValue(Object o) {
137:                    throw new IllegalArgumentException(
138:                            "Cannot make Undefined AspectValues");
139:                }
140:            };
141:
142:            /** Start time of given Task **/
143:            Factory StartTime = new Factory() {
144:                public int getKey() {
145:                    return START_TIME;
146:                }
147:
148:                public String getName() {
149:                    return "START_TIME";
150:                }
151:
152:                public AspectValue newAspectValue(Object o) {
153:                    return TimeAspectValue.create(START_TIME, o);
154:                }
155:            };
156:            /** End time of given Task **/
157:            Factory EndTime = new Factory() {
158:                public int getKey() {
159:                    return END_TIME;
160:                }
161:
162:                public String getName() {
163:                    return "END_TIME";
164:                }
165:
166:                public AspectValue newAspectValue(Object o) {
167:                    return TimeAspectValue.create(END_TIME, o);
168:                }
169:            };
170:            /** (requested) Duration of a task **/
171:            Factory Duration = new Factory() {
172:                public int getKey() {
173:                    return DURATION;
174:                }
175:
176:                public String getName() {
177:                    return "DURATION";
178:                }
179:
180:                public AspectValue newAspectValue(Object o) {
181:                    return TimeAspectValue.create(DURATION, o);
182:                }
183:            };
184:            /** Cost (in $) of allocating given Task **/
185:            Factory Cost = new Factory() {
186:                public int getKey() {
187:                    return COST;
188:                }
189:
190:                public String getName() {
191:                    return "COST";
192:                }
193:
194:                public AspectValue newAspectValue(Object o) {
195:                    return FloatAspectValue.create(COST, o);
196:                }
197:            };
198:            /** Probability of loss of assets associated with allocation **/
199:            Factory Danger = new Factory() {
200:                public int getKey() {
201:                    return DANGER;
202:                }
203:
204:                public String getName() {
205:                    return "DANGER";
206:                }
207:
208:                public AspectValue newAspectValue(Object o) {
209:                    return FloatAspectValue.create(DANGER, o);
210:                }
211:            };
212:            /** Probability of failure of the Mission **/
213:            Factory Risk = new Factory() {
214:                public int getKey() {
215:                    return RISK;
216:                }
217:
218:                public String getName() {
219:                    return "RISK";
220:                }
221:
222:                public AspectValue newAspectValue(Object o) {
223:                    return FloatAspectValue.create(RISK, o);
224:                }
225:            };
226:            /** Quantities associated with allocation (number of elements sourced, e.g.) **/
227:            Factory Quantity = new Factory() {
228:                public int getKey() {
229:                    return QUANTITY;
230:                }
231:
232:                public String getName() {
233:                    return "QUANTITY";
234:                }
235:
236:                public AspectValue newAspectValue(Object o) {
237:                    return FloatAspectValue.create(QUANTITY, o);
238:                }
239:            };
240:            /** For repetitive tasks - specify the amount of time(milliseconds) 
241:             * in between deliveries 
242:             **/
243:            Factory Interval = new Factory() {
244:                public int getKey() {
245:                    return INTERVAL;
246:                }
247:
248:                public String getName() {
249:                    return "INTERVAL";
250:                }
251:
252:                public AspectValue newAspectValue(Object o) {
253:                    return TimeAspectValue.create(INTERVAL, o);
254:                }
255:            };
256:            /**For repetitive tasks the total sum quantity of item for the time span **/
257:            Factory TotalQuantity = new Factory() {
258:                public int getKey() {
259:                    return TOTAL_QUANTITY;
260:                }
261:
262:                public String getName() {
263:                    return "TOTAL_QUANTITY";
264:                }
265:
266:                public AspectValue newAspectValue(Object o) {
267:                    return FloatAspectValue.create(TOTAL_QUANTITY, o);
268:                }
269:            };
270:            /** For repetitive tasks the total number of shipments requested across 
271:             * the time span.
272:             * This should be used in association with the interval aspect.
273:             **/
274:            Factory TotalShipments = new Factory() {
275:                public int getKey() {
276:                    return TOTAL_SHIPMENTS;
277:                }
278:
279:                public String getName() {
280:                    return "TOTAL_SHIPMENTS";
281:                }
282:
283:                public AspectValue newAspectValue(Object o) {
284:                    return FloatAspectValue.create(TOTAL_SHIPMENTS, o);
285:                }
286:            };
287:            /**   **/
288:            Factory CustomerSatisfaction = new Factory() {
289:                public int getKey() {
290:                    return CUSTOMER_SATISFACTION;
291:                }
292:
293:                public String getName() {
294:                    return "CUSTOMER_SATISFACTION";
295:                }
296:
297:                public AspectValue newAspectValue(Object o) {
298:                    return FloatAspectValue.create(CUSTOMER_SATISFACTION, o);
299:                }
300:            };
301:            /** Used to represent an Asset/Quantity relationship
302:             * @see org.cougaar.planning.ldm.plan.TypedQuantityAspectValue
303:             **/
304:            Factory TypedQuantity = new Factory() {
305:                public int getKey() {
306:                    return TYPED_QUANTITY;
307:                }
308:
309:                public String getName() {
310:                    return "TYPED_QUANTITY";
311:                }
312:
313:                public AspectValue newAspectValue(Object o) {
314:                    return FloatAspectValue.create(TYPED_QUANTITY, o);
315:                }
316:            };
317:            /** The extent to which a task has been satisfactorily completed **/
318:            Factory Readiness = new Factory() {
319:                public int getKey() {
320:                    return READINESS;
321:                }
322:
323:                public String getName() {
324:                    return "READINESS";
325:                }
326:
327:                public AspectValue newAspectValue(Object o) {
328:                    return FloatAspectValue.create(READINESS, o);
329:                }
330:            };
331:
332:            /** The point of debarkation of a task **/
333:            Factory Pod = new Factory() {
334:                public int getKey() {
335:                    return POD;
336:                }
337:
338:                public String getName() {
339:                    return "POD";
340:                }
341:
342:                public AspectValue newAspectValue(Object o) {
343:                    return AspectLocation.create(POD, o);
344:                }
345:            };
346:            /** The time at which a task should arrive at the POD **/
347:            Factory PodDate = new Factory() {
348:                public int getKey() {
349:                    return POD_DATE;
350:                }
351:
352:                public String getName() {
353:                    return "POD_DATE";
354:                }
355:
356:                public AspectValue newAspectValue(Object o) {
357:                    return TimeAspectValue.create(POD_DATE, o);
358:                }
359:            };
360:
361:            /** Array of the "standard" AspectValue Factories.  This should match the other
362:             * arrays in this class.
363:             **/
364:            Factory[] AspectFactories = { StartTime, EndTime, Duration, Cost,
365:                    Danger, Risk, Quantity, Interval, TotalQuantity,
366:                    TotalShipments, CustomerSatisfaction, TypedQuantity,
367:                    Readiness, Pod, PodDate };
368:
369:            /** Simple class for registering AspectValue Factories **/
370:            class Registry {
371:                private HashMap table = new HashMap(64);
372:
373:                public Registry(Factory[] fs) {
374:                    for (int i = 0; i < fs.length; i++) {
375:                        Factory f = fs[i];
376:                        assert (f.getKey() == i);
377:                        registerFactory(f);
378:                    }
379:                }
380:
381:                public void registerFactory(Factory f) {
382:                    String s = f.getName();
383:                    Integer i = new Integer(f.getKey());
384:                    synchronized (table) {
385:                        if (table.get(s) != null || table.get(i) != null) {
386:                            throw new IllegalArgumentException(
387:                                    "Cannot register AspectType " + f + " as "
388:                                            + s + "(" + i + ")");
389:                        }
390:                        table.put(s, f);
391:                        table.put(i, f);
392:                    }
393:                }
394:
395:                public Factory get(String name) {
396:                    synchronized (table) {
397:                        return (Factory) table.get(name);
398:                    }
399:                }
400:
401:                public Factory get(Integer key) {
402:                    {
403:                        int i = key.intValue();
404:                        if (i >= 0 && i < AspectFactories.length) {
405:                            return AspectFactories[i];
406:                        }
407:                    }
408:                    synchronized (table) {
409:                        return (Factory) table.get(key);
410:                    }
411:                }
412:
413:                public Factory get(int key) {
414:                    if (key >= 0 && key < AspectFactories.length) {
415:                        return AspectFactories[key];
416:                    }
417:                    synchronized (table) {
418:                        return (Factory) table.get(new Integer(key));
419:                    }
420:                }
421:            }
422:
423:            /** Registry of AspectValue factories **/
424:            Registry registry = new Registry(AspectFactories);
425:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.