Skip to content

Package: NetworkAdapter

NetworkAdapter

nameinstructionbranchcomplexitylinemethod
NetworkAdapter(Point, Device)
M: 0 C: 23
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
NetworkAdapter(Point, Device, VariableAssignment, VariableAssignment)
M: 0 C: 71
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 11
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: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getIpv4Adress()
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%
getIpv6Adress()
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%
getMacAddress()
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: 4 C: 0
0%
M: 1 C: 0
0%
setIpv4Adress(String)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setIpv6Adress(String)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setMacAddress(String)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

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:
8: import javax.imageio.ImageIO;
9:
10: import model.assignment.VariableAssignment;
11: import networkconfigurator.DetailBarLabel;
12: import networkconfigurator.DetailBarPropertyEntry;
13: import networkconfigurator.DetailDrawPropertyEntry;
14:
15: /**
16: * Network Adapter Node.
17: *
18: * @author Erik Arand
19: *
20: */
21: public class NetworkAdapter extends Adapter {
22:         /**
23:          * the IPv4 adress of the network adapter.
24:          */
25:         private String ipv4Adress;
26:
27:         /**
28:          * the IPv6 adress of the network adapter.
29:          */
30:         private String ipv6Adress;
31:
32:         /**
33:          * the mac address of the network adapter.
34:          */
35:         private String macAddress;
36:
37:         /**
38:          * Constructor.
39:          *
40:          * @param p
41:          * the point;
42:          * @param owner
43:          * the owner of the node.
44:          */
45:         public NetworkAdapter(final Point p, final Device owner) {
46:                 this.setPoint(p);
47:                 this.setBoundary();
48:                 this.setName(NcNodeConstants.NETWORK_ADAPTER);
49:                 this.ipv4Adress = "";
50:                 this.ipv6Adress = "";
51:                 this.macAddress = "";
52:                 this.setOwner(owner);
53:         }
54:
55:         /**
56:          * Constructor.
57:          *
58:          * @param p
59:          * the point;
60:          * @param owner
61:          * the owner;
62:          * @param name
63:          * the name;
64:          * @param ipv4Adress
65:          * the ipv4Adress;
66:          */
67:         public NetworkAdapter(final Point p, final Device owner, final VariableAssignment name,
68:                         final VariableAssignment ipv4Adress) {
69:                 this(p, owner);
70:                 this.setName(name.getValue());
71:                 this.ipv4Adress = ipv4Adress.getValue();
72:                 this.getPropertyBar().add(new DetailBarPropertyEntry(new DetailBarLabel("Name")));
73:                 this.getPropertyBar().add(new DetailBarPropertyEntry(name));
74:                 this.getPropertyBar().add(new DetailBarPropertyEntry(new DetailBarLabel("IPv4 Address")));
75:                 this.getPropertyBar().add(new DetailBarPropertyEntry(ipv4Adress));
76:                 this.getPropertyDraw().add(new DetailDrawPropertyEntry(name));
77:                 this.getPropertyDraw()
78:                                 .add(new DetailDrawPropertyEntry(ipv4Adress, NcNodeConstants.IPV4_TEXT, 0,
79:                                                 NcNodeConstants.NUMBER_PRIMARY, NcNodeConstants.RED));
80:                 // this.getPropertyDraw().add(new DetailDrawPropertyEntry(ipv4Adress, Constants.IPV6_TEXT,
81:                 // 0,
82:                 // Constants.NUMBER_SECONDARY, Constants.BLUE));
83:         }
84:
85:         /**
86:          * Üblicher Getter für das Attribut ipv4Adress.
87:          *
88:          * @return liefert ipv4Adress.
89:          */
90:         public String getIpv4Adress() {
91:                 return ipv4Adress;
92:         }
93:
94:         /**
95:          * Üblicher Setter für das Attribut ipv4Adress.
96:          *
97:          * @param ipv4Adress
98:          * Setzt den Parameter {@code ipv4Adress} in das Feld ipv4Adress.
99:          */
100:         public void setIpv4Adress(final String ipv4Adress) {
101:                 this.ipv4Adress = ipv4Adress;
102:         }
103:
104:         /**
105:          * Üblicher Getter für das Attribut ipv6Adress.
106:          *
107:          * @return liefert ipv6Adress.
108:          */
109:         public String getIpv6Adress() {
110:                 return ipv6Adress;
111:         }
112:
113:         /**
114:          * Üblicher Setter für das Attribut ipv6Adress.
115:          *
116:          * @param ipv6Adress
117:          * Setzt den Parameter {@code ipv6Adress} in das Feld ipv6Adress.
118:          */
119:         public void setIpv6Adress(final String ipv6Adress) {
120:                 this.ipv6Adress = ipv6Adress;
121:         }
122:
123:         /**
124:          * Üblicher Getter für das Attribut macAddress.
125:          *
126:          * @return liefert macAddress.
127:          */
128:         public String getMacAddress() {
129:                 return macAddress;
130:         }
131:
132:         /**
133:          * Üblicher Setter für das Attribut macAddress.
134:          *
135:          * @param macAddress
136:          * Setzt den Parameter {@code macAddress} in das Feld macAddress.
137:          */
138:         public void setMacAddress(final String macAddress) {
139:                 this.macAddress = macAddress;
140:         }
141:
142:         @Override
143:         public void accept(final ItemVisitor visitor) {
144:                 visitor.adapter(this);
145:         }
146:
147:         @Override
148:         public BufferedImage giveImage() {
149:                 try {
150:                         return ImageIO.read(new File(NcNodeConstants.PACKAGE_ICONS + "networkadapter.png"));
151:                 } catch (final IOException e) {
152:                         e.printStackTrace();
153:                 }
154:                 return null;
155:         }
156:
157:         @Override
158:         public void acceptConnectVisitor(final ConnectVisitor visitor) {
159:                 visitor.adapter(this);
160:         }
161:
162: }