Source Code Cross Referenced for GraphNode.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » cPlanner » partitioner » graph » 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 » Workflow Engines » pegasus 2.1.0 » org.griphyn.cPlanner.partitioner.graph 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file or a portion of this file is licensed under the terms of
003:         * the Globus Toolkit Public License, found in file GTPL, or at
004:         * http://www.globus.org/toolkit/download/license.html. This notice must
005:         * appear in redistributions of this file, with or without modification.
006:         *
007:         * Redistributions of this Software, with or without modification, must
008:         * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
009:         * some other similar material which is provided with the Software (if
010:         * any).
011:         *
012:         * Copyright 1999-2004 University of Chicago and The University of
013:         * Southern California. All rights reserved.
014:         */
015:        package org.griphyn.cPlanner.partitioner.graph;
016:
017:        import org.griphyn.cPlanner.classes.Data;
018:
019:        import java.util.Iterator;
020:        import java.util.List;
021:
022:        /**
023:         * Data class that allows us to construct information about the nodes
024:         * in the abstract graph. Contains for each node the references to it's
025:         * parents and children. The direction of the edges is usually following the
026:         * children from a node. Parents are kept to facilitate bottom up traversals.
027:         *
028:         * @author Karan Vahi
029:         * @version $Revision: 50 $
030:         */
031:        public class GraphNode extends Data {
032:
033:            //the constants for the color of the nodes
034:            public static final int WHITE_COLOR = 0;
035:            public static final int GRAY_COLOR = 1;
036:            public static final int BLACK_COLOR = 2;
037:
038:            /**
039:             * The logical id of the job as identified in the dax.
040:             */
041:            private String mLogicalID;
042:
043:            /**
044:             * The logical name of the node as identified in the dax.
045:             */
046:            private String mLogicalName;
047:
048:            /**
049:             * The depth of the node from the root or any arbitary node.
050:             */
051:            private int mDepth;
052:
053:            /**
054:             * The color the node is colored.
055:             */
056:            private int mColor;
057:
058:            /**
059:             * The list of parents of the job/node in the abstract graph. Each element
060:             * of the list is a <code>GraphNode</code> object.
061:             */
062:            private List mParents;
063:
064:            /**
065:             * The list of children of the job/node in the abstract graph. Each element
066:             * of the list is a <code>GraphNode</code> object.
067:             */
068:            private List mChildren;
069:
070:            /**
071:             * The content associated with this node.
072:             */
073:            private GraphNodeContent mContent;
074:
075:            /**
076:             * A Bag of objects that maybe associated with the node.
077:             *
078:             * @see Bag
079:             */
080:            private Bag mBag;
081:
082:            /**
083:             * The default constructor.
084:             */
085:            public GraphNode() {
086:                mLogicalID = new String();
087:                mParents = new java.util.LinkedList();
088:                mChildren = new java.util.LinkedList();
089:                mDepth = -1;
090:                mLogicalName = new String();
091:                mColor = this .WHITE_COLOR;
092:                mBag = null;
093:            }
094:
095:            /**
096:             * The overloaded constructor.
097:             *
098:             * @param id       the id of the node in the graph.
099:             * @param content  the content to be associated with the node.
100:             */
101:            public GraphNode(String id, GraphNodeContent content) {
102:                this ();
103:                mLogicalID = id;
104:                mContent = content;
105:            }
106:
107:            /**
108:             * The overloaded constructor.
109:             *
110:             * @param id    the logical id of the node.
111:             * @param name  the name of the node.
112:             */
113:            public GraphNode(String id, String name) {
114:                mLogicalID = id;
115:                mParents = new java.util.LinkedList();
116:                mChildren = new java.util.LinkedList();
117:                mDepth = -1;
118:                mLogicalName = name;
119:                mColor = this .WHITE_COLOR;
120:            }
121:
122:            /**
123:             * Sets the bag of objects associated with the node. Overwrite the previous
124:             * bag if existing.
125:             *
126:             * @param bag  the <code>Bag</code> to be associated with the node.
127:             */
128:            public void setBag(Bag bag) {
129:                mBag = bag;
130:            }
131:
132:            /**
133:             * Sets the content associated with the node. Overwrites the previous
134:             * content if existing.
135:             *
136:             * @param content  the <code>GraphNodeContent</code> to be associated with the node.
137:             */
138:            public void setContent(GraphNodeContent content) {
139:                mContent = content;
140:            }
141:
142:            /**
143:             * It adds the parents to the node. It ends up overwriting all the existing
144:             * parents if some already exist.
145:             */
146:            public void setParents(List parents) {
147:                mParents = parents;
148:            }
149:
150:            /**
151:             * It sets the children to the node. It ends up overwriting all the existing
152:             * parents if some already exist.
153:             */
154:            public void setChildren(List children) {
155:                mChildren = children;
156:            }
157:
158:            /**
159:             * Sets the depth associated with the node.
160:             */
161:            public void setDepth(int depth) {
162:                mDepth = depth;
163:            }
164:
165:            /**
166:             * Returns the bag of objects associated with the node.
167:             *
168:             * @return the bag or null if no bag associated
169:             */
170:            public Bag getBag() {
171:                return mBag;
172:            }
173:
174:            /**
175:             * Returns the content associated with the node.
176:             *
177:             * @return the content or null if no content associated
178:             */
179:            public GraphNodeContent getContent() {
180:                return mContent;
181:            }
182:
183:            /**
184:             * Returns a list of <code>GraphNode</code> objects that are parents of the node.
185:             *
186:             * @return list of <code>GraphNode</code> objects.
187:             */
188:            public List getParents() {
189:                return mParents;
190:            }
191:
192:            /**
193:             * Returns a list of <code>GraphNode</code> objects that are children of the
194:             * node.
195:             *
196:             * @return list of <code>GraphNode</code> objects.
197:             */
198:            public List getChildren() {
199:                return mChildren;
200:            }
201:
202:            /**
203:             * Adds a child to end of the child list.
204:             *
205:             * @param child  adds a child to the node.
206:             */
207:            public void addChild(GraphNode child) {
208:                mChildren.add(child);
209:            }
210:
211:            /**
212:             * Adds a parent to end of the parent list.
213:             *
214:             * @param parent  adds a parent to the node.
215:             */
216:            public void addParent(GraphNode parent) {
217:                mParents.add(parent);
218:            }
219:
220:            /**
221:             * Removes a child linkage to the node.
222:             *
223:             * @param child  child to be removed.
224:             */
225:            public void removeChild(GraphNode child) {
226:                mChildren.remove(child);
227:            }
228:
229:            /**
230:             * Removes a parent linkage to the node.
231:             *
232:             * @param parent  parent to be removed.
233:             */
234:            public void removeParent(GraphNode parent) {
235:                mParents.remove(parent);
236:            }
237:
238:            /**
239:             * Returns the logical id of the graph node.
240:             */
241:            public String getID() {
242:                return mLogicalID;
243:            }
244:
245:            /**
246:             * Returns the logical name of the graph node.
247:             */
248:            public String getName() {
249:                return mLogicalName;
250:            }
251:
252:            /**
253:             * Returns the depth of the node in the graph.
254:             */
255:            public int getDepth() {
256:                return mDepth;
257:            }
258:
259:            /**
260:             * Returns if the color of the node is as specified.
261:             *
262:             * @param color  color that node should be.
263:             */
264:            public boolean isColor(int color) {
265:                return (mColor == color) ? true : false;
266:            }
267:
268:            /**
269:             * Sets the color of the node to the color specified
270:             *
271:             * @param color  color that node should be.
272:             */
273:            public void setColor(int color) {
274:                mColor = color;
275:            }
276:
277:            /**
278:             * Returns if all the parents of that node have the color that is specified.
279:             *
280:             * @param color the color of the node.
281:             *
282:             * @return  true if there are no parents or all parents are of the color.
283:             *          false in all other  cases.
284:             */
285:            public boolean parentsColored(int color) {
286:                boolean colored = true;
287:                GraphNode par;
288:                if (mParents == null) {
289:                    return colored;
290:                }
291:
292:                Iterator it = mParents.iterator();
293:                while (it.hasNext() && colored) {
294:                    par = (GraphNode) it.next();
295:                    colored = par.isColor(color);
296:                }
297:
298:                return colored;
299:            }
300:
301:            /**
302:             * The textual representation of the graph node.
303:             *
304:             * @return textual description.
305:             */
306:            public String toString() {
307:                StringBuffer sb = new StringBuffer();
308:                Iterator it;
309:
310:                sb.append("ID->").append(mLogicalID).append(" name->").append(
311:                        mLogicalName).append(" parents->{");
312:                if (mParents != null) {
313:                    it = mParents.iterator();
314:                    while (it.hasNext()) {
315:                        sb.append(((GraphNode) it.next()).getID()).append(',');
316:                    }
317:
318:                }
319:                sb.append("} children->{");
320:                it = mChildren.iterator();
321:                while (it.hasNext()) {
322:                    sb.append(((GraphNode) it.next()).getID()).append(',');
323:                }
324:                sb.append("}");
325:                sb.append(" Content-{").append(getContent()).append("}");
326:                sb.append(" Bag-{").append(getBag()).append("}");
327:                return sb.toString();
328:            }
329:
330:            /**
331:             * Returns a copy of the object.
332:             */
333:            public Object clone() {
334:                return new java.lang.CloneNotSupportedException(
335:                        "Clone() not implemented in GraphNode");
336:            }
337:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.