KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > GraphNode


1 package org.apache.ojb.broker;
2
3 import java.io.Serializable JavaDoc;
4 import java.util.Collection JavaDoc;
5 import java.util.Vector JavaDoc;
6
7 /**
8  * GraphNode and GraphEdge model oriented graph with named nodes.
9  * In this case there are two relations between two classes.
10  * @author Oleg Nitz
11  */

12 public class GraphNode implements Serializable JavaDoc
13 {
14     private int id;
15     private String JavaDoc name;
16     private Collection JavaDoc outgoingEdges;
17     private Collection JavaDoc incomingEdges;
18     private int locationId;
19     private Point location;
20
21     public GraphNode()
22     {
23     }
24
25     public GraphNode(int id, String JavaDoc name, int locationId) {
26         this.id = id;
27         this.name = name;
28         this.locationId = locationId;
29     }
30
31     public GraphNode(String JavaDoc name)
32     {
33         this.name = name;
34     }
35
36     public void addOutgoingEdge(GraphEdge edge)
37     {
38         if (outgoingEdges == null)
39         {
40             outgoingEdges = new Vector JavaDoc();
41         }
42         outgoingEdges.add(edge);
43     }
44
45     public void addIncomingEdge(GraphEdge edge)
46     {
47         if (incomingEdges == null)
48         {
49             incomingEdges = new Vector JavaDoc();
50         }
51         incomingEdges.add(edge);
52     }
53
54     public Collection JavaDoc getOutgoingEdges()
55     {
56         return outgoingEdges;
57     }
58
59     public Collection JavaDoc getIncomingEdges()
60     {
61         return incomingEdges;
62     }
63
64     public String JavaDoc getName()
65     {
66         return name;
67     }
68
69     public int getLocationId()
70     {
71         return locationId;
72     }
73
74     public Point getLocation()
75     {
76         return location;
77     }
78
79     public int getId()
80     {
81         return id;
82     }
83
84     public void setOutgoingEdges(Collection JavaDoc edges)
85     {
86         outgoingEdges = edges;
87     }
88
89     public void setIncomingEdges(Collection JavaDoc edges)
90     {
91         incomingEdges = edges;
92     }
93
94     public void setName(String JavaDoc name)
95     {
96         this.name = name;
97     }
98
99     public void setLocationId(int locationId)
100     {
101         this.locationId = locationId;
102     }
103
104     public void setLocation(Point location)
105     {
106         this.location = location;
107     }
108
109     public void setId(int id)
110     {
111         this.id = id;
112     }
113
114     public String JavaDoc toString()
115     {
116         return name + " " + outgoingEdges;
117     }
118
119 }
120
Popular Tags