Source Code Cross Referenced for FullCompletionData.java in  » Science » Cougaar12_4 » org » cougaar » planning » servlet » data » completion » 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.servlet.data.completion 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * <copyright>
003:         *  
004:         *  Copyright 2001-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:        package org.cougaar.planning.servlet.data.completion;
027:
028:        import java.io.IOException;
029:        import java.util.ArrayList;
030:        import java.util.List;
031:
032:        import org.cougaar.planning.servlet.data.xml.DeXMLable;
033:        import org.cougaar.planning.servlet.data.xml.UnexpectedXMLException;
034:        import org.cougaar.planning.servlet.data.xml.XMLWriter;
035:        import org.xml.sax.Attributes;
036:
037:        /**
038:         * Represents the data leaving the Completion PSP --
039:         * <code>FullCompletionData</code> captures all the <code>AbstractTask</code>s.
040:         *
041:         * @see SimpleCompletionData
042:         * @see CompletionData
043:         **/
044:        public class FullCompletionData extends CompletionData {
045:
046:            //Variables:
047:            ////////////
048:
049:            public static final String NAME_TAG = "FullCompletion";
050:
051:            protected List unplannedTasks;
052:            protected List unestimatedTasks;
053:            protected List unconfidentTasks;
054:            protected List failedTasks;
055:
056:            //Constructors:
057:            ///////////////
058:
059:            public FullCompletionData() {
060:                unplannedTasks = new ArrayList();
061:                unestimatedTasks = new ArrayList();
062:                unconfidentTasks = new ArrayList();
063:                failedTasks = new ArrayList();
064:            }
065:
066:            //Setters:
067:            //////////
068:
069:            public void addUnplannedTask(UnplannedTask ut) {
070:                unplannedTasks.add(ut);
071:            }
072:
073:            public void addUnestimatedTask(UnestimatedTask uet) {
074:                unestimatedTasks.add(uet);
075:            }
076:
077:            public void addUnconfidentTask(UnconfidentTask uct) {
078:                unconfidentTasks.add(uct);
079:            }
080:
081:            public void addFailedTask(FailedTask ft) {
082:                failedTasks.add(ft);
083:            }
084:
085:            //Getters:
086:            //////////
087:
088:            public int getNumberOfUnplannedTasks() {
089:                return unplannedTasks.size();
090:            }
091:
092:            public int getNumberOfUnestimatedTasks() {
093:                return unestimatedTasks.size();
094:            }
095:
096:            public int getNumberOfUnconfidentTasks() {
097:                return unconfidentTasks.size();
098:            }
099:
100:            public int getNumberOfFailedTasks() {
101:                return failedTasks.size();
102:            }
103:
104:            public UnplannedTask getUnplannedTaskAt(int i) {
105:                return (UnplannedTask) unplannedTasks.get(i);
106:            }
107:
108:            public UnestimatedTask getUnestimatedTaskAt(int i) {
109:                return (UnestimatedTask) unestimatedTasks.get(i);
110:            }
111:
112:            public UnconfidentTask getUnconfidentTaskAt(int i) {
113:                return (UnconfidentTask) unconfidentTasks.get(i);
114:            }
115:
116:            public FailedTask getFailedTaskAt(int i) {
117:                return (FailedTask) failedTasks.get(i);
118:            }
119:
120:            //XMLable members:
121:            //----------------
122:
123:            /**
124:             * Write this class out to the Writer in XML format
125:             * @param w output Writer
126:             **/
127:            public void toXML(XMLWriter w) throws IOException {
128:                w.optagln(NAME_TAG);
129:                w.tagln(TIME_MILLIS_ATTR, getTimeMillis());
130:                w.tagln(RATIO_ATTR, getRatio());
131:                w.tagln(NUMBER_OF_TASKS_ATTR, getNumberOfTasks());
132:                for (int i = 0; i < getNumberOfUnplannedTasks(); i++) {
133:                    getUnplannedTaskAt(i).toXML(w);
134:                }
135:                for (int i = 0; i < getNumberOfUnestimatedTasks(); i++) {
136:                    getUnestimatedTaskAt(i).toXML(w);
137:                }
138:                for (int i = 0; i < getNumberOfUnconfidentTasks(); i++) {
139:                    getUnconfidentTaskAt(i).toXML(w);
140:                }
141:                for (int i = 0; i < getNumberOfFailedTasks(); i++) {
142:                    getFailedTaskAt(i).toXML(w);
143:                }
144:                w.cltagln(NAME_TAG);
145:            }
146:
147:            //DeXMLable members:
148:            //------------------
149:
150:            /**
151:             * Report a startElement that pertains to THIS object, not any
152:             * sub objects.  Call also provides the elements Attributes and data.  
153:             * Note, that  unlike in a SAX parser, data is guaranteed to contain 
154:             * ALL of this tag's data, not just a 'chunk' of it.
155:             * @param name startElement tag
156:             * @param attr attributes for this tag
157:             * @param data data for this tag
158:             **/
159:            public void openTag(String name, Attributes attr, String data)
160:                    throws UnexpectedXMLException {
161:                try {
162:                    if (name.equals(NAME_TAG)) {
163:                    } else if (name.equals(TIME_MILLIS_ATTR)) {
164:                        timeMillis = Long.parseLong(data);
165:                    } else if (name.equals(RATIO_ATTR)) {
166:                        ratio = Double.parseDouble(data);
167:                    } else if (name.equals(NUMBER_OF_TASKS_ATTR)) {
168:                        numTasks = Integer.parseInt(data);
169:                    } else {
170:                        throw new UnexpectedXMLException("Unexpected tag: "
171:                                + name);
172:                    }
173:                } catch (NumberFormatException e) {
174:                    throw new UnexpectedXMLException("Malformed Number: "
175:                            + name + " : " + data);
176:                }
177:            }
178:
179:            /**
180:             * Report an endElement.
181:             * @param name endElement tag
182:             * @return true iff the object is DONE being DeXMLized
183:             **/
184:            public boolean closeTag(String name) throws UnexpectedXMLException {
185:                return name.equals(NAME_TAG);
186:            }
187:
188:            /**
189:             * This function will be called whenever a subobject has
190:             * completed de-XMLizing and needs to be encorporated into
191:             * this object.
192:             * @param name the startElement tag that caused this subobject
193:             * to be created
194:             * @param obj the object itself
195:             **/
196:            public void completeSubObject(String name, DeXMLable obj)
197:                    throws UnexpectedXMLException {
198:                if (obj instanceof  UnplannedTask) {
199:                    addUnplannedTask((UnplannedTask) obj);
200:                } else if (obj instanceof  UnestimatedTask) {
201:                    addUnestimatedTask((UnestimatedTask) obj);
202:                } else if (obj instanceof  UnconfidentTask) {
203:                    addUnconfidentTask((UnconfidentTask) obj);
204:                } else if (obj instanceof  FailedTask) {
205:                    addFailedTask((FailedTask) obj);
206:                } else {
207:                    throw new UnexpectedXMLException("Unexpected object: "
208:                            + obj);
209:                }
210:            }
211:
212:            //Inner Classes:
213:
214:            /** 
215:             * Set the serialVersionUID to keep the object serializer from seeing
216:             * xerces (org.xml.sax.Attributes).
217:             */
218:            private static final long serialVersionUID = 8898898989829387181L;
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.