001    /*
002     * $Id: StormInfo.java,v 1.1 2012/01/04 20:40:52 tommyj Exp $
003     *
004     * This file is part of McIDAS-V
005     *
006     * Copyright 2007-2012
007     * Space Science and Engineering Center (SSEC)
008     * University of Wisconsin - Madison
009     * 1225 W. Dayton Street, Madison, WI 53706, USA
010     * https://www.ssec.wisc.edu/mcidas
011     * 
012     * All Rights Reserved
013     * 
014     * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and
015     * some McIDAS-V source code is based on IDV and VisAD source code.  
016     * 
017     * McIDAS-V is free software; you can redistribute it and/or modify
018     * it under the terms of the GNU Lesser Public License as published by
019     * the Free Software Foundation; either version 3 of the License, or
020     * (at your option) any later version.
021     * 
022     * McIDAS-V is distributed in the hope that it will be useful,
023     * but WITHOUT ANY WARRANTY; without even the implied warranty of
024     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
025     * GNU Lesser Public License for more details.
026     * 
027     * You should have received a copy of the GNU Lesser Public License
028     * along with this program.  If not, see http://www.gnu.org/licenses.
029     */
030    
031    package edu.wisc.ssec.mcidasv.data.cyclone;
032    
033    import visad.DateTime;
034    
035    /**
036     * Created by IntelliJ IDEA. User: yuanho Date: Apr 9, 2008 Time: 4:57:21 PM To
037     * change this template use File | Settings | File Templates.
038     */
039    
040    public class StormInfo implements Comparable {
041    
042            /** _more_ */
043            private String stormID;
044    
045            /** _more_ */
046            private String name;
047    
048            /** _more_ */
049            private String basin;
050    
051            /** _more_ */
052            private String number;
053    
054            /** _more_ */
055            private DateTime startTime;
056    
057            /**
058             * _more_
059             */
060            public StormInfo() {
061            }
062    
063            /**
064             * _more_
065             * 
066             * @param id
067             *            _more_
068             * @param sTime
069             *            _more_
070             */
071            public StormInfo(String id, DateTime sTime) {
072                    this(id, id, sTime);
073            }
074    
075            /**
076             * _more_
077             * 
078             * @param id
079             *            _more_
080             * @param name
081             *            _more_
082             * @param sTime
083             *            _more_
084             */
085            public StormInfo(String id, String name, DateTime sTime) {
086                    this(id, name, null, null, sTime);
087            }
088    
089            /**
090             * _more_
091             * 
092             * @param id
093             *            _more_
094             * @param name
095             *            _more_
096             * @param basin
097             *            _more_
098             * @param number
099             *            _more_
100             * @param sTime
101             *            _more_
102             */
103            public StormInfo(String id, String name, String basin, String number,
104                            DateTime sTime) {
105                    this.stormID = id;
106                    this.name = name;
107                    this.basin = basin;
108                    this.startTime = sTime;
109                    this.number = number;
110            }
111    
112            /**
113             * Compare this object to another.
114             * 
115             * @param o
116             *            object in question.
117             * @return spec from Comparable interface.
118             */
119            public int compareTo(Object o) {
120                    if (o instanceof StormInfo) {
121                            StormInfo that = (StormInfo) o;
122                            if (startTime.getValue() < that.startTime.getValue()) {
123                                    return -1;
124                            }
125                            if (startTime.getValue() > that.startTime.getValue()) {
126                                    return 1;
127                            }
128                            return 0;
129                    }
130                    return toString().compareTo(o.toString());
131            }
132    
133            /**
134             * _more_
135             * 
136             * @param id
137             *            _more_
138             */
139            public void setStormId(String id) {
140                    this.stormID = id;
141            }
142    
143            /**
144             * _more_
145             * 
146             * @return _more_
147             */
148            public String getStormId() {
149                    return stormID;
150            }
151    
152            /**
153             * _more_
154             * 
155             * @param dt
156             *            _more_
157             */
158            public void setStartTime(DateTime dt) {
159                    this.startTime = dt;
160            }
161    
162            /**
163             * _more_
164             * 
165             * @return _more_
166             */
167            public DateTime getStartTime() {
168                    return startTime;
169            }
170    
171            /**
172             * _more_
173             * 
174             * @return _more_
175             */
176            public String toString() {
177                    if (name != null) {
178                            return name;
179                    }
180                    return stormID;
181            }
182    
183            /**
184             * _more_
185             * 
186             * @return _more_
187             */
188            public int hashCode() {
189                    return stormID.hashCode();
190            }
191    
192            /**
193             * _more_
194             * 
195             * @param o
196             *            _more_
197             * 
198             * @return _more_
199             */
200            public boolean equals(Object o) {
201                    if (o == null) {
202                            return false;
203                    }
204                    if (!(o instanceof StormInfo)) {
205                            return false;
206                    }
207                    StormInfo other = (StormInfo) o;
208                    return (this.stormID.equals(other.stormID));
209            }
210    
211            /**
212             * Set the Name property.
213             * 
214             * @param value
215             *            The new value for Name
216             */
217            public void setName(String value) {
218                    name = value;
219            }
220    
221            /**
222             * Get the Name property.
223             * 
224             * @return The Name
225             */
226            public String getName() {
227                    return name;
228            }
229    
230            /**
231             * Set the Basin property.
232             * 
233             * @param value
234             *            The new value for Basin
235             */
236            public void setBasin(String value) {
237                    basin = value;
238            }
239    
240            /**
241             * Get the Basin property.
242             * 
243             * @return The Basin
244             */
245            public String getBasin() {
246                    return basin;
247            }
248    
249            /**
250             * Set the Number property.
251             * 
252             * @param value
253             *            The new value for Number
254             */
255            public void setNumber(String value) {
256                    number = value;
257            }
258    
259            /**
260             * Get the Number property.
261             * 
262             * @return The Number
263             */
264            public String getNumber() {
265                    return number;
266            }
267    
268    }