-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRTMLExtinctionConstraint.java
More file actions
289 lines (261 loc) · 7.69 KB
/
RTMLExtinctionConstraint.java
File metadata and controls
289 lines (261 loc) · 7.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/*
Copyright 2006, Astrophysics Research Institute, Liverpool John Moores University.
This file is part of org.estar.rtml.
org.estar.rtml is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
org.estar.rtml is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with org.estar.rtml; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// RTMLExtinctionConstraint.java
// $Header: /space/home/eng/cjm/cvs/org_estar_rtml/RTMLExtinctionConstraint.java,v 1.1 2011-02-09 18:40:42 cjm Exp $
package org.estar.rtml;
import java.io.*;
import java.text.*;
/**
* This class is a data container for information contained in the ExtinctionConstraint nodes/tags of an RTML document.
* The elements in a ExtinctionConstraint are:
* <ul>
* <li><b>Clouds</b> A string based description, one of: (clear|light|scattered|heavy).
* <li><b>Magnitudes</b> The extinction in magnitudes.
* </ul>
* Only the <i>Clouds</i> value is used by the TEA at the moment.
* @author Chris Mottram
* @version $Revision$
*/
public class RTMLExtinctionConstraint implements Serializable
{
/**
* Revision control system version id.
*/
public final static String RCSID = "$Id$";
/**
* Serial version ID. Fixed as these documents can be used as parameters in RMI calls across JVMs.
*/
static final long serialVersionUID = 7432524348364737357L;
/**
* A description of the clouds: (clear|light|scattered|heavy) are acceptable.
*/
private String clouds = null;
/**
* The extinction in magnitudes.
*/
private double value = 0.0;
/**
* Default constructor.
*/
public RTMLExtinctionConstraint()
{
super();
}
/**
* Set the value of extinction in magnitudes.
* @param s The value specified as a string representation of a double.
* @exception NumberFormatException Thrown if the string parsing fails.
* @see #value
*/
public void setValue(String s) throws NumberFormatException
{
value = Double.parseDouble(s);
}
/**
* Set the value of extinction in magnitudes.
* @param d The value, specified as a double.
* @see #value
*/
public void setValue(double d)
{
value = d;
}
/**
* Get the value.
* @return The value of extinction in magnitudes.
* @see #value
*/
public double getValue()
{
return value;
}
/**
* Set the extinction in terms of cloud cover.
* @param s A string, a valid description of the cloud cover (clear|light|scattered|heavy).
* @exception IllegalArgumentException Thrown if the string is not a valid description.
* @see #clouds
* @see #isClear
* @see #isLight
* @see #isScattered
* @see #isHeavy
*/
public void setClouds(String s) throws IllegalArgumentException
{
if(!(isClear(s)||isLight(s)||(isScattered(s))||(isHeavy(s))))
{
throw new IllegalArgumentException(this.getClass().getName()+":setClouds:Illegal cloud cover:"
+s+".");
}
clouds = s;
}
/**
* Get the cloud cover description.
* @return The string representing cloud cover.
* @see #clouds
*/
public String getClouds()
{
return clouds;
}
/**
* Is the cloud cover "clear"?
* Only looks at the <i>clouds</i> description at the present time.
* @return A boolean, true if the <i>clouds</i> description is "clear", false otherwise.
* @see #clouds
* @see #isClear(java.lang.String)
*/
public boolean isClear()
{
return isClear(clouds);
}
/**
* Is the specified cloud cover string "clear"?
* @param s The string representing the cloud cover.
* @return A boolean, true if the string cloud cover is "clear", false otherwise.
*/
protected boolean isClear(String s)
{
return s.equals("clear");
}
/**
* Is the cloud cover "light"?
* Only looks at the <i>clouds</i> description at the present time.
* @return A boolean, true if the <i>clouds</i> description is "light", false otherwise.
* @see #clouds
* @see #isLight(java.lang.String)
*/
public boolean isLight()
{
return isLight(clouds);
}
/**
* Is the specified cloud cover string "light"?
* @param s The string representing the cloud cover.
* @return A boolean, true if the string cloud cover is "light", false otherwise.
*/
protected boolean isLight(String s)
{
return s.equals("light");
}
/**
* Is the cloud cover "scattered"?
* Only looks at the <i>clouds</i> description at the present time.
* @return A boolean, true if the <i>clouds</i> description is "scattered", false otherwise.
* @see #clouds
* @see #isScattered(java.lang.String)
*/
public boolean isScattered()
{
return isScattered(clouds);
}
/**
* Is the specified cloud cover string "scattered"?
* @param s The string representing the cloud cover.
* @return A boolean, true if the string cloud cover is "scattered", false otherwise.
*/
protected boolean isScattered(String s)
{
return s.equals("scattered");
}
/**
* Is the cloud cover "heavy"?
* Only looks at the <i>clouds</i> description at the present time.
* @return A boolean, true if the <i>clouds</i> description is "heavy", false otherwise.
* @see #clouds
* @see #isHeavy(java.lang.String)
*/
public boolean isHeavy()
{
return isHeavy(clouds);
}
/**
* Is the specified cloud cover string "heavy"?
* @param s The string representing the cloud cover.
* @return A boolean, true if the string cloud cover is "heavy", false otherwise.
*/
protected boolean isHeavy(String s)
{
return s.equals("heavy");
}
/**
* Is the cloud cover photometric.
* Only looks at the <i>clouds</i> description at the present time.
* @return A boolean, true if the <i>clouds</i> description is "clear", false otherwise.
* @see #clouds
* @see #isClear()
*/
public boolean isPhotometric()
{
return isClear();
}
/**
* Is the cloud cover spectroscopic.
* Only looks at the <i>clouds</i> description at the present time.
* @return A boolean, true if the <i>clouds</i> description is "light|scattered|heavy", false otherwise.
* @see #clouds
* @see #isLight()
* @see #isScattered()
* @see #isHeavy()
*/
public boolean isSpectroscopic()
{
return isLight()||isScattered()||isHeavy();
}
/**
* Test the equality of the extinction constraint.
* @param obj The other instance we are testing against.
* @return Returns true if the contents are the same, and false if they are not.
*/
public boolean equals(Object obj)
{
RTMLExtinctionConstraint other = null;
if(obj == null)
return false;
if((obj instanceof RTMLExtinctionConstraint) == false)
return false;
other = (RTMLExtinctionConstraint)obj;
if(other.getClouds().equals(clouds) == false)
return false;
return true;
}
/**
* Method to print out a string representation of this node.
*/
public String toString()
{
return toString("");
}
/**
* Method to print out a string representation of this node, with a prefix.
* @param prefix A string to prefix to each line of data we print out.
* @see #clouds
* @see #isPhotometric
* @see #isSpectroscopic
*/
public String toString(String prefix)
{
StringBuffer sb = null;
sb = new StringBuffer();
sb.append(prefix+"Extinction Constraint:\n");
sb.append(prefix+"\tCloud Cover:"+clouds+".\n");
sb.append(prefix+"\tPhotometric:"+isPhotometric()+".\n");
sb.append(prefix+"\tSpectroscopic:"+isSpectroscopic()+".\n");
return sb.toString();
}
}
/*
** $Log: not supported by cvs2svn $
*/