Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Windows |
|
| 4.25;4.25 |
1 | /* Copyright © 2013 Matthew Champion | |
2 | All rights reserved. | |
3 | ||
4 | Redistribution and use in source and binary forms, with or without | |
5 | modification, are permitted provided that the following conditions are met: | |
6 | * Redistributions of source code must retain the above copyright | |
7 | notice, this list of conditions and the following disclaimer. | |
8 | * Redistributions in binary form must reproduce the above copyright | |
9 | notice, this list of conditions and the following disclaimer in the | |
10 | documentation and/or other materials provided with the distribution. | |
11 | * Neither the name of mattunderscore.com nor the | |
12 | names of its contributors may be used to endorse or promote products | |
13 | derived from this software without specific prior written permission. | |
14 | ||
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
18 | DISCLAIMED. IN NO EVENT SHALL MATTHEW CHAMPION BE LIABLE FOR ANY | |
19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |
25 | ||
26 | package com.mattunderscore.http.headers.useragent.details.platform; | |
27 | ||
28 | /** | |
29 | * Indicates the user agent claims to run on a Windows operating system. | |
30 | * @author Matt Champion | |
31 | */ | |
32 | public class Windows extends OSPlatform | |
33 | { | |
34 | private final String windowsName; | |
35 | ||
36 | /** | |
37 | * Constructor for a detail with a name and version. | |
38 | * @param name The name | |
39 | * @param version The version | |
40 | */ | |
41 | public Windows(String name, String version) | |
42 | { | |
43 | 10 | super(name,version); |
44 | 10 | if ("Windows NT".equals(name) || "WinNT".equals(name)) |
45 | { | |
46 | 10 | if ("4.0".equals(version)) |
47 | { | |
48 | 0 | windowsName = "Microsoft Windows NT 4.0"; |
49 | } | |
50 | 10 | else if ("5.0".equals(version)) |
51 | { | |
52 | 0 | windowsName = "Windows 2000"; |
53 | } | |
54 | 10 | else if ("5.01".equals(version)) |
55 | { | |
56 | 0 | windowsName = "Windows 2000, Service Pack 1 (SP1)"; |
57 | } | |
58 | 10 | else if ("5.1".equals(version)) |
59 | { | |
60 | 0 | windowsName = "Windows XP"; |
61 | } | |
62 | 10 | else if ("5.2".equals(version)) |
63 | { | |
64 | 0 | windowsName = "Windows Server 2003; Windows XP x64 Edition"; |
65 | } | |
66 | 10 | else if ("6.0".equals(version)) |
67 | { | |
68 | 2 | windowsName = "Windows Vista"; |
69 | } | |
70 | 8 | else if ("6.1".equals(version)) |
71 | { | |
72 | 8 | windowsName = "Windows 7"; |
73 | } | |
74 | 0 | else if ("6.2".equals(version)) |
75 | { | |
76 | 0 | windowsName = "Windows 8"; |
77 | } | |
78 | 0 | else if ("6.3".equals(version)) |
79 | { | |
80 | 0 | windowsName = "Windows 8.1 Preview"; |
81 | } | |
82 | else | |
83 | { | |
84 | 0 | windowsName = ""; |
85 | } | |
86 | } | |
87 | else | |
88 | { | |
89 | 0 | windowsName = ""; |
90 | } | |
91 | 10 | } |
92 | ||
93 | /** | |
94 | * Constructor for a detail with a name, version and Windows name. | |
95 | * @param name The name | |
96 | * @param version The version | |
97 | * @param windowsName The Windows name | |
98 | */ | |
99 | public Windows(String name, String version, String windowsName) | |
100 | { | |
101 | 0 | super(name,version); |
102 | 0 | this.windowsName = windowsName; |
103 | 0 | } |
104 | ||
105 | /** | |
106 | * Name generally used to refer to the Windows version. | |
107 | * @return The Windows name | |
108 | */ | |
109 | public String windowsName() | |
110 | { | |
111 | 4 | return windowsName; |
112 | } | |
113 | ||
114 | @Override | |
115 | public String toString() | |
116 | { | |
117 | 0 | if ("".equals(windowsName)) |
118 | { | |
119 | 0 | return detailType() + ": " + name + " " + version; |
120 | } | |
121 | else | |
122 | { | |
123 | 0 | return detailType() + ": " + windowsName; |
124 | } | |
125 | } | |
126 | } |