Skip to content

Package: ConfigRouter

ConfigRouter

nameinstructionbranchcomplexitylinemethod
ConfigRouter(Point)
M: 0 C: 26
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
ConfigRouter(Point, VariableAssignment)
M: 0 C: 48
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
accept(ItemVisitor)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
acceptConnectVisitor(ConnectVisitor)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
acceptConnectingTypeVisitor(ConnectingTypeVisitor)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
addConnectingType(ConnectingType)
M: 0 C: 13
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 3
100%
M: 0 C: 1
100%
addRoute(VariableAssignment)
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getConnectingTypes()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getIpRoutes()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getRoute()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
giveImage()
M: 18 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
removeConnectingType(ConnectingType)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: package networkconfigurator.item;
2:
3: import java.awt.Point;
4: import java.awt.image.BufferedImage;
5: import java.io.File;
6: import java.io.IOException;
7: import java.util.ArrayList;
8: import java.util.List;
9:
10: import javax.imageio.ImageIO;
11:
12: import model.assignment.VariableAssignment;
13: import networkconfigurator.DetailBarLabel;
14: import networkconfigurator.DetailBarPropertyEntry;
15: import networkconfigurator.DetailDrawPropertyEntry;
16:
17: /**
18: * Configurable Router Node.
19: *
20: * @author Erik Arand
21: *
22: */
23: public class ConfigRouter extends Routable {
24:         /**
25:          * connecting types supported by the Config router.
26:          */
27:         private final ConnectingTypeList connectingTypes = new ConnectingTypeList();
28:         /**
29:          * The routes of the configurable router.
30:          */
31:         private final List<VariableAssignment> route = new ArrayList<VariableAssignment>();
32:
33:         /**
34:          * getter for the connecting types.
35:          *
36:          * @return connectingTypes
37:          */
38:         public ConnectingTypeList getConnectingTypes() {
39:                 return connectingTypes;
40:         }
41:
42:         /**
43:          * List of IP Routes.
44:          */
45:         private final List<String> ipRoutes = new ArrayList<String>();
46:
47:         /**
48:          * getter of List of IP Routes.
49:          *
50:          * @return the list
51:          */
52:         public List<String> getIpRoutes() {
53:                 return ipRoutes;
54:         }
55:
56:         /**
57:          * Constructor.
58:          *
59:          * @param p
60:          * the point.
61:          */
62:         public ConfigRouter(final Point p) {
63:                 this.setPoint(p);
64:                 setBoundary();
65:                 this.setName(NcNodeConstants.CONFIGROUTER);
66:         }
67:
68:         /**
69:          * Constructor.
70:          *
71:          * @param p
72:          * the point.
73:          * @param name
74:          * the HOSTNAME. For example, the variable HOSTNAME of the fli4l configuration.
75:          */
76:         public ConfigRouter(final Point p, final VariableAssignment name) {
77:                 this(p);
78:                 this.setName(name.getValue());
79:                 this.getPropertyBar().add(new DetailBarPropertyEntry(new DetailBarLabel("Name")));
80:                 this.getPropertyBar().add(new DetailBarPropertyEntry(name));
81:                 this.getPropertyDraw().add(new DetailDrawPropertyEntry(name));
82:                 this.getPropertyDraw().add(new DetailDrawPropertyEntry(this.getConnectingTypes(), "", 0,
83:                                 NcNodeConstants.NUMBER_PRIMARY, NcNodeConstants.RED));
84:         }
85:
86:         @Override
87:         public void accept(final ItemVisitor visitor) {
88:                 visitor.configRouter(this);
89:         }
90:
91:         @Override
92:         public BufferedImage giveImage() {
93:                 try {
94:                         return ImageIO
95:                                         .read(new File(NcNodeConstants.PACKAGE_ICONS + "configurablerouter.png"));
96:                 } catch (final IOException e) {
97:                         e.printStackTrace();
98:                 }
99:                 return null;
100:         }
101:
102:         /**
103:          * removing the type of the list.
104:          *
105:          * @param type
106:          * type to be removed
107:          */
108:         public void removeConnectingType(final ConnectingType type) {
109:                 connectingTypes.getConnectingTypeList().remove(type);
110:         }
111:
112:         /**
113:          * true for adding the type to the list.
114:          *
115:          * @param type
116:          * type to be added
117:          */
118:         public void addConnectingType(final ConnectingType type) {
119:•                if (!(connectingTypes.getConnectingTypeList().contains(type))) {
120:                         connectingTypes.getConnectingTypeList().add(type);
121:                 }
122:         }
123:
124:         @Override
125:         public void acceptConnectingTypeVisitor(final ConnectingTypeVisitor visitor) {
126:                 visitor.router(this);
127:         }
128:
129:         @Override
130:         public void acceptConnectVisitor(final ConnectVisitor visitor) {
131:         }
132:
133:         /**
134:          * getter for getRoute.
135:          *
136:          * @return getRoute
137:          */
138:         public final List<VariableAssignment> getRoute() {
139:                 return route;
140:         }
141:
142:         /**
143:          * adds a route to the configurable router.
144:          *
145:          * @param pRoute
146:          * route to add.
147:          */
148:         public final void addRoute(final VariableAssignment pRoute) {
149:                 this.route.add(pRoute);
150:                 this.ipRoutes.add(pRoute.getValue());
151:         }
152:
153: }