Making classes final to make inheritance impossible
[iot2.git] / benchmarks / other / ZigbeeTest / IoTAddress.java
1 \r
2 // Java packages\r
3 import java.net.Socket;\r
4 import java.net.ServerSocket;\r
5 import java.net.InetAddress;\r
6 import java.net.UnknownHostException;\r
7 \r
8 /** Class IoTAddress is a wrapper class to pass\r
9  *  IoTSet of any addresses from master to slave\r
10  *\r
11  * @author      Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>\r
12  * @version     1.0\r
13  * @since       2016-04-22\r
14  */\r
15 public class IoTAddress {\r
16 \r
17         /**\r
18          * IoTDeviceAddress class properties\r
19          */\r
20         protected final InetAddress inetAddress;\r
21 \r
22         /**\r
23          * Class constructor\r
24          *\r
25          * @param   sAddress  String address\r
26          */\r
27         public IoTAddress(String sAddress) throws UnknownHostException {\r
28 \r
29                 inetAddress = InetAddress.getByName(sAddress);\r
30         }\r
31 \r
32         /**\r
33          * getHostAddress() method\r
34          *\r
35          * @return  String\r
36          */\r
37         public String getHostAddress() {\r
38 \r
39                 return inetAddress.getHostAddress();\r
40 \r
41         }\r
42 \r
43         /**\r
44          * getHostName() method\r
45          *\r
46          * @return  String\r
47          */\r
48         public String getHostName() {\r
49 \r
50                 return inetAddress.getHostName();\r
51 \r
52         }\r
53 \r
54         /**\r
55          * getUrl() method\r
56          *\r
57          * @return  String\r
58          */\r
59         public String getURL(String strURLComplete) {\r
60 \r
61                 //e.g. http:// + inetAddress.getHostAddress() + strURLComplete\r
62                 //     http://192.168.2.254/cgi-bin/mjpg/video.cgi?\r
63                 return "http://" + inetAddress.getHostAddress() + strURLComplete;\r
64 \r
65         }\r
66 \r
67         /**\r
68          * getCompleteAddress() method\r
69          *\r
70          * @return  String\r
71          */\r
72         public String getCompleteAddress() {\r
73 \r
74                 return inetAddress.toString();\r
75 \r
76         }\r
77 }\r