16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 package com.nokia.carbide.remoteconnections.tests.extensions; |
19 package com.nokia.carbide.remoteconnections.tests.extensions; |
20 |
20 |
21 import com.nokia.carbide.remoteconnections.interfaces.IConnection; |
21 import java.util.HashMap; |
|
22 import java.util.Map; |
|
23 |
|
24 import com.nokia.carbide.remoteconnections.interfaces.AbstractConnection; |
22 import com.nokia.carbide.remoteconnections.interfaces.IConnectionType; |
25 import com.nokia.carbide.remoteconnections.interfaces.IConnectionType; |
23 import com.nokia.cpp.internal.api.utils.core.Check; |
26 import com.nokia.cpp.internal.api.utils.core.Check; |
24 |
27 |
25 import java.util.Collections; |
28 public class IntervalConnection extends AbstractConnection { |
26 import java.util.Map; |
|
27 |
|
28 public class IntervalConnection implements IConnection { |
|
29 |
29 |
30 private int msInterval; |
30 private int msInterval; |
31 private String id; |
|
32 private String name; |
|
33 private IConnectionType connectionType; |
|
34 |
31 |
35 public IntervalConnection(IConnectionType connectionType) { |
32 public IntervalConnection(IConnectionType connectionType) { |
36 this.connectionType = connectionType; |
33 super(connectionType, new HashMap<String, String>()); |
|
34 msInterval = Integer.parseInt(IntervalConnectionType.VALUE); |
|
35 getSettings().put(IntervalConnectionType.KEY, Integer.toString(msInterval)); |
37 } |
36 } |
38 |
37 |
39 /* (non-Javadoc) |
|
40 * @see com.nokia.carbide.remoteconnections.extensions.IConnection#dispose() |
|
41 */ |
|
42 public void dispose() { |
|
43 } |
|
44 |
|
45 /* (non-Javadoc) |
|
46 * @see com.nokia.carbide.remoteconnections.extensions.IConnection#getConnectionType() |
|
47 */ |
|
48 public IConnectionType getConnectionType() { |
|
49 return connectionType; |
|
50 } |
|
51 |
|
52 /* (non-Javadoc) |
|
53 * @see com.nokia.carbide.remoteconnections.extensions.IConnection#getIdentifier() |
|
54 */ |
|
55 public String getIdentifier() { |
|
56 return id; |
|
57 } |
|
58 |
|
59 /* (non-Javadoc) |
|
60 * @see com.nokia.carbide.remoteconnections.interfaces.IConnection#getDisplayName() |
|
61 */ |
|
62 public String getDisplayName() { |
|
63 return name; |
|
64 } |
|
65 |
|
66 /* (non-Javadoc) |
|
67 * @see com.nokia.carbide.remoteconnections.interfaces.IConnection#setDisplayName(java.lang.String) |
|
68 */ |
|
69 public void setDisplayName(String name) { |
|
70 this.name = name; |
|
71 } |
|
72 |
|
73 /* (non-Javadoc) |
|
74 * @see com.nokia.carbide.remoteconnections.extensions.IConnection#getSettings() |
|
75 */ |
|
76 public Map<String, String> getSettings() { |
|
77 return Collections.singletonMap(IntervalConnectionType.KEY, Integer.toString(msInterval)); |
|
78 } |
|
79 |
|
80 /* (non-Javadoc) |
|
81 * @see com.nokia.carbide.remoteconnections.extensions.IConnection#setIdentifier(java.lang.String) |
|
82 */ |
|
83 public void setIdentifier(String id) { |
|
84 this.id = id; |
|
85 } |
|
86 |
|
87 /* (non-Javadoc) |
|
88 * @see com.nokia.carbide.remoteconnections.extensions.IConnection#updateSettings(java.util.Map) |
|
89 */ |
|
90 public void updateSettings(Map<String, String> newSettings) { |
38 public void updateSettings(Map<String, String> newSettings) { |
91 Check.checkContract(newSettings.containsKey(IntervalConnectionType.KEY)); |
39 Check.checkContract(newSettings.containsKey(IntervalConnectionType.KEY)); |
92 String string = newSettings.get(IntervalConnectionType.KEY); |
40 String string = newSettings.get(IntervalConnectionType.KEY); |
93 msInterval = Integer.parseInt(string); |
41 msInterval = Integer.parseInt(string); |
94 } |
42 } |