Source Code Cross Referenced for Node.java in  » Code-Analyzer » javapathfinder » gov » nasa » ltl » 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 » Code Analyzer » javapathfinder » gov.nasa.ltl.graph 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //
002:        // Copyright (C) 2005 United States Government as represented by the
003:        // Administrator of the National Aeronautics and Space Administration
004:        // (NASA).  All Rights Reserved.
005:        // 
006:        // This software is distributed under the NASA Open Source Agreement
007:        // (NOSA), version 1.3.  The NOSA has been approved by the Open Source
008:        // Initiative.  See the file NOSA-1.3-JPF at the top of the distribution
009:        // directory tree for the complete NOSA document.
010:        // 
011:        // THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
012:        // KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
013:        // LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
014:        // SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
015:        // A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
016:        // THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
017:        // DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
018:        //
019:        package gov.nasa.ltl.graph;
020:
021:        import java.io.PrintStream;
022:
023:        import java.util.Iterator;
024:        import java.util.LinkedList;
025:        import java.util.List;
026:
027:        /**
028:         * DOCUMENT ME!
029:         */
030:        public class Node {
031:            private Graph graph;
032:
033:            private List outgoingEdges;
034:
035:            private List incomingEdges;
036:
037:            private Attributes attributes;
038:
039:            public Node(Graph g, Attributes a) {
040:                init(g, a);
041:            }
042:
043:            public Node(Graph g) {
044:                init(g, null);
045:            }
046:
047:            public Node(Node n) {
048:                init(n.graph, new Attributes(n.attributes));
049:
050:                for (Iterator i = n.outgoingEdges.iterator(); i.hasNext();) {
051:                    new Edge(this , (Edge) i.next());
052:                }
053:
054:                for (Iterator i = n.incomingEdges.iterator(); i.hasNext();) {
055:                    new Edge((Edge) i.next(), this );
056:                }
057:            }
058:
059:            public synchronized void setAttributes(Attributes a) {
060:                int id = getId();
061:                attributes = new Attributes(a);
062:                setId(id);
063:            }
064:
065:            public Attributes getAttributes() {
066:                return attributes;
067:            }
068:
069:            public synchronized void setBooleanAttribute(String name,
070:                    boolean value) {
071:                if (name.equals("_id")) {
072:                    return;
073:                }
074:
075:                attributes.setBoolean(name, value);
076:            }
077:
078:            public boolean getBooleanAttribute(String name) {
079:                return attributes.getBoolean(name);
080:            }
081:
082:            public Graph getGraph() {
083:                return graph;
084:            }
085:
086:            public synchronized int getId() {
087:                return attributes.getInt("_id");
088:            }
089:
090:            public int getIncomingEdgeCount() {
091:                return outgoingEdges.size();
092:            }
093:
094:            public List getIncomingEdges() {
095:                return new LinkedList(incomingEdges);
096:            }
097:
098:            public synchronized void setIntAttribute(String name, int value) {
099:                if (name.equals("_id")) {
100:                    return;
101:                }
102:
103:                attributes.setInt(name, value);
104:            }
105:
106:            public int getIntAttribute(String name) {
107:                return attributes.getInt(name);
108:            }
109:
110:            public int getOutgoingEdgeCount() {
111:                return outgoingEdges.size();
112:            }
113:
114:            public List getOutgoingEdges() {
115:                return new LinkedList(outgoingEdges);
116:            }
117:
118:            public synchronized void setStringAttribute(String name,
119:                    String value) {
120:                if (name.equals("_id")) {
121:                    return;
122:                }
123:
124:                attributes.setString(name, value);
125:            }
126:
127:            public String getStringAttribute(String name) {
128:                return attributes.getString(name);
129:            }
130:
131:            public synchronized void forAllEdges(Visitor v) {
132:                for (Iterator i = new LinkedList(outgoingEdges).iterator(); i
133:                        .hasNext();) {
134:                    v.visitEdge((Edge) i.next());
135:                }
136:            }
137:
138:            public synchronized void remove() {
139:                for (Iterator i = new LinkedList(outgoingEdges).iterator(); i
140:                        .hasNext();) {
141:                    ((Edge) i.next()).remove();
142:                }
143:
144:                for (Iterator i = new LinkedList(incomingEdges).iterator(); i
145:                        .hasNext();) {
146:                    ((Edge) i.next()).remove();
147:                }
148:
149:                graph.removeNode(this );
150:            }
151:
152:            synchronized void setId(int id) {
153:                attributes.setInt("_id", id);
154:            }
155:
156:            synchronized void addIncomingEdge(Edge e) {
157:                incomingEdges.add(e);
158:            }
159:
160:            synchronized void addOutgoingEdge(Edge e) {
161:                outgoingEdges.add(e);
162:            }
163:
164:            synchronized void removeIncomingEdge(Edge e) {
165:                incomingEdges.remove(e);
166:            }
167:
168:            synchronized void removeOutgoingEdge(Edge e) {
169:                outgoingEdges.remove(e);
170:            }
171:
172:            // Modified by robbyjo - Jul 15, 2002
173:            void save(PrintStream out, int format) {
174:                switch (format) {
175:                case Graph.SM_FORMAT:
176:                    save_sm(out);
177:
178:                    break;
179:
180:                case Graph.FSP_FORMAT:
181:                    save_fsp(out);
182:
183:                    break;
184:
185:                case Graph.XML_FORMAT:
186:                    save_xml(out);
187:
188:                    break;
189:
190:                case Graph.SPIN_FORMAT:
191:                    save_spin(out);
192:
193:                    break;
194:
195:                default:
196:                    throw new RuntimeException("Unknown format!");
197:                }
198:            }
199:
200:            private void init(Graph g, Attributes a) {
201:                graph = g;
202:
203:                if (a == null) {
204:                    attributes = new Attributes();
205:                } else {
206:                    attributes = a;
207:                }
208:
209:                incomingEdges = new LinkedList();
210:                outgoingEdges = new LinkedList();
211:
212:                graph.addNode(this );
213:            }
214:
215:            // Modified by ckong - Sept 7, 2001
216:            private void save_fsp(PrintStream out) {
217:                ///System.out.print("S" + getId() + "=(");
218:                out.print("S" + getId() + "=(");
219:
220:                for (Iterator i = outgoingEdges.iterator(); i.hasNext();) {
221:                    ((Edge) i.next()).save(out, Graph.FSP_FORMAT);
222:
223:                    if (i.hasNext()) {
224:                        //System.out.print(" |");
225:                        out.print(" |");
226:                    }
227:                }
228:
229:                //System.out.print(")");
230:                out.print(")");
231:            }
232:
233:            private void save_sm(PrintStream out) {
234:                int id = getId();
235:                out.print("  ");
236:                out.println(outgoingEdges.size());
237:                attributes.unset("_id");
238:                out.print("  ");
239:                out.println(attributes);
240:                setId(id);
241:
242:                for (Iterator i = outgoingEdges.iterator(); i.hasNext();) {
243:                    ((Edge) i.next()).save(out, Graph.SM_FORMAT);
244:                }
245:            }
246:
247:            // robbyjo's contribution
248:            private void save_spin(PrintStream out) {
249:                String ln = System.getProperty("line.separator");
250:                String lntab = ln + "     :: ";
251:
252:                if (getBooleanAttribute("accepting")) {
253:                    out.print("accept_");
254:                }
255:
256:                out.print("S" + getId() + ":" + ln + "     if" + lntab);
257:
258:                for (Iterator i = outgoingEdges.iterator(); i.hasNext();) {
259:                    Edge e = (Edge) i.next();
260:                    e.save(out, Graph.SPIN_FORMAT);
261:
262:                    if (i.hasNext()) {
263:                        out.print(lntab);
264:                    }
265:                }
266:
267:                out.print(ln + "     fi;\n");
268:            }
269:
270:            private void save_xml(PrintStream out) {
271:                int id = getId();
272:                out.println("<node id=\"" + id + "\">");
273:                attributes.unset("_id");
274:                attributes.save(out, Graph.XML_FORMAT);
275:                setId(id);
276:
277:                for (Iterator i = outgoingEdges.iterator(); i.hasNext();) {
278:                    ((Edge) i.next()).save(out, Graph.XML_FORMAT);
279:                }
280:
281:                out.println("</node>");
282:            }
283:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.