Source Code Cross Referenced for Organization.java in  » Science » Cougaar12_4 » org » cougaar » planning » servlet » data » hierarchy » 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.hierarchy 
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.hierarchy;
027:
028:        import java.io.IOException;
029:        import java.io.Serializable;
030:        import java.util.ArrayList;
031:        import java.util.List;
032:
033:        import org.cougaar.planning.servlet.data.xml.DeXMLable;
034:        import org.cougaar.planning.servlet.data.xml.UnexpectedXMLException;
035:        import org.cougaar.planning.servlet.data.xml.XMLWriter;
036:        import org.cougaar.planning.servlet.data.xml.XMLable;
037:        import org.xml.sax.Attributes;
038:
039:        /**
040:         * Represents the organization data within the hierarchy PSP
041:         *
042:         * @since 1/24/01
043:         **/
044:        public class Organization implements  XMLable, DeXMLable, Serializable,
045:                Comparable {
046:
047:            //Variables:
048:            ////////////
049:
050:            public final static String NAME_TAG = "Org";
051:            protected final static String UID_TAG = "OrgID";
052:            protected final static String PRETTY_NAME_TAG = "Name";
053:            protected final static String RELATION_TAG = "Rel";
054:
055:            public static final int ADMIN_SUBORDINATE = 0;
056:            public static final int SUBORDINATE = 1;
057:
058:            protected String UID;
059:            protected String prettyName;
060:            protected List relations;
061:
062:            //Constructors:
063:            ///////////////
064:
065:            public Organization() {
066:                relations = new ArrayList();
067:            }
068:
069:            //Members:
070:            //////////
071:
072:            public void setUID(String UID) {
073:                this .UID = UID;
074:            }
075:
076:            public void setPrettyName(String name) {
077:                prettyName = name;
078:            }
079:
080:            public void addRelation(String UID, int relation) {
081:                relations.add(new OrgRelation(UID, relation));
082:            }
083:
084:            public void addRelation(String UID, String relation) {
085:                relations.add(new OrgRelation(UID, relation));
086:            }
087:
088:            public String getUID() {
089:                return UID;
090:            }
091:
092:            public String getPrettyName() {
093:                return prettyName;
094:            }
095:
096:            public int getNumRelations() {
097:                return relations.size();
098:            }
099:
100:            public String getRelationUIDAt(int i) {
101:                OrgRelation or = (OrgRelation) relations.get(i);
102:                return or.org;
103:            }
104:
105:            public int getRelationAt(int i) {
106:                OrgRelation or = (OrgRelation) relations.get(i);
107:                return or.relation;
108:            }
109:
110:            public OrgRelation getOrgRelationAt(int i) {
111:                return (OrgRelation) relations.get(i);
112:            }
113:
114:            public String getRelatedOrgAt(int i) {
115:                return ((OrgRelation) relations.get(i)).getRelatedOrg();
116:            }
117:
118:            public String getNamedRelationAt(int i) {
119:                return ((OrgRelation) relations.get(i)).getName();
120:            }
121:
122:            public List getRelations() {
123:                return relations;
124:            }
125:
126:            public int compareTo(Object other) {
127:                if (!(other instanceof  Organization))
128:                    return 0;
129:                int value = UID.compareTo(((Organization) other).UID);
130:                return value;
131:            }
132:
133:            public boolean equals(Object other) {
134:                if (!(other instanceof  Organization)) {
135:                    System.out
136:                            .println("ERROR ERROR ERROR comparing with non-org "
137:                                    + other);
138:                    return false;
139:                }
140:                boolean value = UID.equals(((Organization) other).UID);
141:                return value;
142:            }
143:
144:            public String toString() {
145:                return UID;
146:            }
147:
148:            //XMLable members:
149:            //----------------
150:
151:            /**
152:             * Write this class out to the Writer in XML format
153:             * @param w output Writer
154:             **/
155:            public void toXML(XMLWriter w) throws IOException {
156:                w.optagln(NAME_TAG);
157:
158:                w.tagln(UID_TAG, getUID());
159:                w.tagln(PRETTY_NAME_TAG, getPrettyName());
160:
161:                for (int i = 0; i < getNumRelations(); i++) {
162:                    OrgRelation relation = getOrgRelationAt(i);
163:                    w.sitagln(RELATION_TAG, UID_TAG, getRelationUIDAt(i),
164:                            RELATION_TAG, (relation.hasName() ? relation
165:                                    .getName() : Integer
166:                                    .toString(getRelationAt(i))));
167:                }
168:
169:                w.cltagln(NAME_TAG);
170:            }
171:
172:            //DeXMLable members:
173:            //------------------
174:
175:            /**
176:             * Report a startElement that pertains to THIS object, not any
177:             * sub objects.  Call also provides the elements Attributes and data.  
178:             * Note, that  unlike in a SAX parser, data is guaranteed to contain 
179:             * ALL of this tag's data, not just a 'chunk' of it.
180:             * @param name startElement tag
181:             * @param attr attributes for this tag
182:             * @param data data for this tag
183:             **/
184:            public void openTag(String name, Attributes attr, String data)
185:                    throws UnexpectedXMLException {
186:                if (name.equals(NAME_TAG)) {
187:                } else if (name.equals(PRETTY_NAME_TAG)) {
188:                    setPrettyName(data);
189:                } else if (name.equals(UID_TAG)) {
190:                    setUID(data);
191:                } else if (name.equals(RELATION_TAG)) {
192:                    try {
193:                        addRelation(attr.getValue(UID_TAG), Integer
194:                                .parseInt(attr.getValue(RELATION_TAG)));
195:                    } catch (NumberFormatException e) {
196:                        addRelation(attr.getValue(UID_TAG), attr
197:                                .getValue(RELATION_TAG));
198:                    }
199:                } else {
200:                    throw new UnexpectedXMLException("Unexpected tag: " + name);
201:                }
202:            }
203:
204:            /**
205:             * Report an endElement.
206:             * @param name endElement tag
207:             * @return true iff the object is DONE being DeXMLized
208:             **/
209:            public boolean closeTag(String name) throws UnexpectedXMLException {
210:                return name.equals(NAME_TAG);
211:            }
212:
213:            /**
214:             * This function will be called whenever a subobject has
215:             * completed de-XMLizing and needs to be encorporated into
216:             * this object.
217:             * @param name the startElement tag that caused this subobject
218:             * to be created
219:             * @param obj the object itself
220:             **/
221:            public void completeSubObject(String name, DeXMLable obj)
222:                    throws UnexpectedXMLException {
223:            }
224:
225:            public static class OrgRelation implements  Serializable, Comparable {
226:                public String org;
227:                public int relation;
228:                public String relationName;
229:                public boolean hasName = false;
230:
231:                public OrgRelation(String o, int r) {
232:                    org = o;
233:                    relation = r;
234:                }
235:
236:                public OrgRelation(String org, String relation) {
237:                    this .org = org;
238:                    relationName = relation;
239:                    hasName = true;
240:                }
241:
242:                public int compareTo(Object other) {
243:                    if (!(other instanceof  OrgRelation))
244:                        return 0;
245:                    int comp = org.compareTo(((OrgRelation) other).org);
246:                    if (comp == 0)
247:                        return relationName
248:                                .compareTo(((OrgRelation) other).relationName);
249:                    else
250:                        return comp;
251:                }
252:
253:                public boolean hasName() {
254:                    return hasName;
255:                }
256:
257:                public String getName() {
258:                    return relationName;
259:                }
260:
261:                public String getRelatedOrg() {
262:                    return org;
263:                }
264:
265:                /** 
266:                 * Set the serialVersionUID to keep the object serializer from seeing
267:                 * xerces (org.xml.sax.Attributes).
268:                 */
269:                private static final long serialVersionUID = 109382094832059403L;
270:            }
271:
272:            /** 
273:             * Set the serialVersionUID to keep the object serializer from seeing
274:             * xerces (org.xml.sax.Attributes).
275:             */
276:            private static final long serialVersionUID = 893487223987438473L;
277:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.