1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.mobility.weather.entity;
17
18 import java.util.ArrayList;
19 import java.util.HashMap;
20 import java.util.List;
21 import java.util.Map;
22
23 import javax.xml.bind.annotation.XmlElement;
24 import javax.xml.bind.annotation.XmlRootElement;
25
26 @XmlRootElement( name = "weather")
27 public class Weather {
28
29 private List<HashMap<String, String>> forecasts;
30
31 private String currentCondition;
32 private String temperature;
33 private String humidity;
34 private String windDirection;
35 private String windSpeed;
36 private String pressure;
37
38 public Weather() {
39 forecasts = new ArrayList<HashMap<String, String>>();
40 }
41
42 @XmlElement(name = "forecasts")
43 public List<HashMap<String, String>> getForecasts() {
44 return forecasts;
45 }
46
47 public String getPressure() {
48 return pressure;
49 }
50
51 public void setPressure(String pressure) {
52 this.pressure = pressure;
53 }
54
55 public void setForecasts(List<HashMap<String, String>> forecasts) {
56 this.forecasts = forecasts;
57 }
58
59 public String getCurrentCondition() {
60 return currentCondition;
61 }
62
63 public void setCurrentCondition(String currentCondition) {
64 this.currentCondition = currentCondition;
65 }
66
67 public String getTemperature() {
68 return temperature;
69 }
70
71 public void setTemperature(String temperature) {
72 this.temperature = temperature;
73 }
74
75 public String getHumidity() {
76 return humidity;
77 }
78
79 public void setHumidity(String humidity) {
80 this.humidity = humidity;
81 }
82
83 public String getWind() {
84 String speed = getWindSpeed();
85 if ("0".equals(speed)) {
86 return "0 MPH";
87 }
88 return speed + " MPH from the " + getWindDirection();
89 }
90
91 public String getWindDirection() {
92 String text = "";
93 try {
94 int direction = Integer.parseInt(windDirection);
95 if (direction > 348.75 && direction <= 11.25) {
96 text = "North";
97 }
98 if (direction > 11.25 && direction <= 33.75) {
99 text = "North Northeast";
100 }
101 if (direction > 33.75 && direction <= 56.25) {
102 text = "Northeast";
103 }
104 if (direction > 56.25 && direction <= 78.75) {
105 text = "East Northeast";
106 }
107 if (direction > 78.75 && direction <= 101.25) {
108 text = "East";
109 }
110 if (direction > 101.25 && direction <= 123.75) {
111 text = "East Southeast";
112 }
113 if (direction > 123.75 && direction <= 146.25) {
114 text = "Southeast";
115 }
116 if (direction > 146.25 && direction <= 168.75) {
117 text = "South Southeast";
118 }
119 if (direction > 168.75 && direction <= 191.25 ) {
120 text = "South";
121 }
122 if (direction > 191.25 && direction <= 213.75) {
123 text = "South Southwest";
124 }
125 if (direction > 213.75 && direction <= 236.25) {
126 text = "Southwest";
127 }
128 if (direction > 236.25 && direction <= 258.75) {
129 text = "West Southwest";
130 }
131 if (direction > 258.75 && direction <= 281.25) {
132 text = "West";
133 }
134 if (direction > 281.25 && direction <= 303.75) {
135 text = "West Northwest";
136 }
137 if (direction > 303.75 && direction <= 326.25) {
138 text = "Northwest";
139 }
140 if (direction > 326.25 && direction <= 348.75) {
141 text = "North Northwest";
142 }
143 } catch (Exception e) {
144 }
145 return text;
146 }
147
148 public void setWindDirection(String windDirection) {
149 this.windDirection = windDirection;
150 }
151
152 public String getWindSpeed() {
153 return windSpeed;
154 }
155
156 public void setWindSpeed(String windSpeed) {
157 this.windSpeed = windSpeed;
158 }
159
160 }