View Javadoc

1   package org.apache.myfaces.tobago.example.demo.model.solar;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * the License.  You may obtain a copy of the License at
10   *
11   *      http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  /**
21   * User: weber
22   * Date: Nov 5, 2002
23   * Time: 7:15:14 PM
24   */
25  
26  import java.util.ArrayList;
27  import java.util.List;
28  
29  public class SolarObject {
30  
31    private String name;
32  
33    private String number;
34  
35    private String orbit;
36  
37    private Integer distance;
38  
39    private Double period;
40  
41    private Double incl;
42  
43    private Double eccen;
44  
45    private String discoverer;
46  
47    private Integer discoverYear;
48  
49    private String population;
50  
51    public SolarObject(String[] strings) {
52      this.name = strings[0];
53      this.number = strings[1];
54      this.orbit = strings[2];
55      try {
56        this.distance = Integer.valueOf(strings[3]);
57      } catch (NumberFormatException e) {
58        new Integer(0);
59      }
60      try {
61        this.period = Double.valueOf(strings[4]);
62      } catch (NumberFormatException e) {
63        new Double(0);
64      }
65      try {
66        this.incl = Double.valueOf(strings[5]);
67      } catch (NumberFormatException e) {
68        new Double(0);
69      }
70      try {
71        this.eccen = Double.valueOf(strings[6]);
72      } catch (NumberFormatException e) {
73        new Double(0);
74      }
75      this.discoverer = strings[7];
76      try {
77        this.discoverYear = Integer.valueOf(strings[8]);
78      } catch (NumberFormatException e) {
79        new Integer(0);
80      }
81      if (strings[0].equals("Earth")) {
82        population = "ca.5500000000";
83      } else {
84        population = "0";
85      }
86    }
87  
88    public String getName() {
89      return name;
90    }
91  
92    public void setName(String name) {
93      this.name = name;
94    }
95  
96    public String getNumber() {
97      return number;
98    }
99  
100   public void setNumber(String number) {
101     this.number = number;
102   }
103 
104   public String getOrbit() {
105     return orbit;
106   }
107 
108   public void setOrbit(String orbit) {
109     this.orbit = orbit;
110   }
111 
112   public Integer getDistance() {
113     return distance;
114   }
115 
116   public void setDistance(Integer distance) {
117     this.distance = distance;
118   }
119 
120   public Double getPeriod() {
121     return period;
122   }
123 
124   public void setPeriod(Double period) {
125     this.period = period;
126   }
127 
128   public Double getIncl() {
129     return incl;
130   }
131 
132   public void setIncl(Double incl) {
133     this.incl = incl;
134   }
135 
136   public Double getEccen() {
137     return eccen;
138   }
139 
140   public void setEccen(Double eccen) {
141     this.eccen = eccen;
142   }
143 
144   public String getDiscoverer() {
145     return discoverer;
146   }
147 
148   public void setDiscoverer(String discoverer) {
149     this.discoverer = discoverer;
150   }
151 
152   public Integer getDiscoverYear() {
153     return discoverYear;
154   }
155 
156   public void setDiscoverYear(Integer discoverYear) {
157     this.discoverYear = discoverYear;
158   }
159 
160   public String getPopulation() {
161     return population;
162   }
163 
164   public void setPopulation(String population) {
165     this.population = population;
166   }
167 
168   public boolean isSelectionDisabled() {
169     return number.equals("II");
170   }
171 
172   public static SolarObject[] getArray() {
173     SolarObject[] array = new SolarObject[STRINGS.length];
174     for (int i = 0; i < array.length; i++) {
175       array[i] = new SolarObject(STRINGS[i]);
176     }
177     return array;
178   }
179 
180 
181   public static List<SolarObject> getList() {
182     SolarObject[] array = getArray();
183     List<SolarObject> list = new ArrayList<SolarObject>(array.length);
184     for (SolarObject object : array) {
185       list.add(object);
186     }
187     return list;
188   }
189 
190     public static List<SolarObject> getSatellites(String center) {
191     List<SolarObject> collect = new ArrayList<SolarObject>();
192     SolarObject[] all = getArray();
193     for (SolarObject anAll : all) {
194       if (anAll.getOrbit().equals(center)) {
195         collect.add(anAll);
196       }
197     }
198     return collect;
199   }
200 
201   private static final String[][] STRINGS =
202         {
203           {"Sun",         "-",          "-",        "0",     "0",       "0",     "0",             "-",       "0"},
204           {"Mercury",    "I",         "Sun",    "57910",    "87.97",    "7.00",  "0.21",          "-",       "-"},
205           {"Venus",      "II",        "Sun",   "108200",   "224.70",    "3.39",  "0.01",          "-",       "-"},
206           {"Earth",      "III",       "Sun",   "149600",   "365.26",    "0.00",  "0.02",          "-",       "-"},
207           {"Mars",       "IV",        "Sun",   "227940",   "686.98",    "1.85",  "0.09",          "-",       "-"},
208           {"Jupiter",    "V",         "Sun",   "778330",  "4332.71",    "1.31",  "0.05",          "-",       "-"},
209           {"Saturn",     "VI",        "Sun",  "1429400", "10759.50",    "2.49",  "0.06",          "-",       "-"},
210           {"Uranus",     "VII",       "Sun",  "2870990", "30685.00",    "0.77",  "0.05",   "Herschel",    "1781"},
211           {"Neptune",    "VIII",      "Sun",  "4504300", "60190.00",    "1.77",  "0.01",      "Adams",    "1846"},
212           {"Pluto",      "IX",        "Sun",  "5913520", "90800",      "17.15",  "0.25",   "Tombaugh",    "1930"},
213           {"Moon",       "I",       "Earth",      "384",    "27.32",    "5.14",  "0.05",          "-",       "-"},
214           {"Phobos",     "I",        "Mars",        "9",     "0.32",    "1.00",  "0.02",       "Hall",    "1877"},
215           {"Deimos",     "II",       "Mars",       "23",     "1.26",    "1.80",  "0.00",       "Hall",    "1877"},
216           {"Metis",      "XVI",   "Jupiter",      "128",     "0.29",    "0.00",  "0.00",    "Synnott",    "1979"},
217           {"Adrastea",   "XV",    "Jupiter",      "129",     "0.30",    "0.00",  "0.00",     "Jewitt",    "1979"},
218           {"Amalthea",   "V",     "Jupiter",      "181",     "0.50",    "0.40",  "0.00",    "Barnard",    "1892"},
219           {"Thebe",      "XIV",   "Jupiter",      "222",     "0.67",    "0.80",  "0.02",    "Synnott",    "1979"},
220           {"Io",         "I",     "Jupiter",      "422",     "1.77",    "0.04",  "0.00",    "Galileo",    "1610"},
221           {"Europa",     "II",    "Jupiter",      "671",     "3.55",    "0.47",  "0.01",    "Galileo",    "1610"},
222           {"Ganymede",   "III",   "Jupiter",     "1070",     "7.15",    "0.19",  "0.00",    "Galileo",    "1610"},
223           {"Callisto",   "IV",    "Jupiter",     "1883",    "16.69",    "0.28",  "0.01",    "Galileo",    "1610"},
224           {"Themisto",   "XVIII", "Jupiter",     "7507",     "0",           "",      "",   "Sheppard",    "2000"},
225           {"Leda",       "XIII",  "Jupiter",    "11094",   "238.72",   "27.00",  "0.15",      "Kowal",    "1974"},
226           {"Himalia",    "VI",    "Jupiter",    "11480",   "250.57",   "28.00",  "0.16",    "Perrine",    "1904"},
227           {"Lysithea",   "X",     "Jupiter",    "11720",   "259.22",   "29.00",  "0.11",  "Nicholson",    "1938"},
228           {"Elara",      "VII",   "Jupiter",    "11737",   "259.65",   "28.00",  "0.21",    "Perrine",    "1905"},
229           {"Ananke",     "XII",   "Jupiter",    "21200",  "-631",     "147.00",  "0.17",  "Nicholson",    "1951"},
230           {"Carme",      "XI",    "Jupiter",    "22600",  "-692",     "163.00",  "0.21",  "Nicholson",    "1938"},
231           {"Pasiphae",   "VIII",  "Jupiter",    "23500",  "-735",     "147.00",  "0.38",    "Melotte",    "1908"},
232           {"Sinope",     "IX",    "Jupiter",    "23700",  "-758",     "153.00",  "0.28",  "Nicholson",    "1914"},
233           {"Iocaste",    "XXIV",  "Jupiter",    "20216",     "0",           "",      "",   "Sheppard",    "2000"},
234           {"Harpalyke",  "XXII",  "Jupiter",    "21132",     "0",           "",      "",   "Sheppard",    "2000"},
235           {"Praxidike",  "XXVII", "Jupiter",    "20964",     "0",           "",      "",   "Sheppard",    "2000"},
236           {"Taygete",    "XX",    "Jupiter",    "23312",     "0",           "",      "",   "Sheppard",    "2000"},
237           {"Chaldene",   "XXI",   "Jupiter",    "23387",     "0",           "",      "",   "Sheppard",    "2000"},
238           {"Kalyke",     "XXIII", "Jupiter",    "23745",     "0",           "",      "",   "Sheppard",    "2000"},
239           {"Callirrhoe", "XVII",  "Jupiter",    "24100",     "0",           "",      "",   "Sheppard",    "2000"},
240           {"Megaclite",  "XIX",   "Jupiter",    "23911",     "0",           "",      "",   "Sheppard",    "2000"},
241           {"Isonoe",     "XXVI",  "Jupiter",    "23078",     "0",           "",      "",   "Sheppard",    "2000"},
242           {"Erinome",    "XXV",   "Jupiter",    "23168",     "0",           "",      "",   "Sheppard",    "2000"},
243           {"Pan",        "XVIII",  "Saturn",      "134",     "0.58",    "0.00",  "0.00",  "Showalter",    "1990"},
244           {"Atlas",      "XV",     "Saturn",      "138",     "0.60",    "0.00",  "0.00",    "Terrile",    "1980"},
245           {"Prometheus", "XVI",    "Saturn",      "139",     "0.61",    "0.00",  "0.00",    "Collins",    "1980"},
246           {"Pandora",    "XVII",   "Saturn",      "142",     "0.63",    "0.00",  "0.00",    "Collins",    "1980"},
247           {"Epimetheus", "XI",     "Saturn",      "151",     "0.69",    "0.34",  "0.01",     "Walker",    "1980"},
248           {"Janus",      "X",      "Saturn",      "151",     "0.69",    "0.14",  "0.01",    "Dollfus",    "1966"},
249           {"Mimas",      "I",      "Saturn",      "186",     "0.94",    "1.53",  "0.02",   "Herschel",    "1789"},
250           {"Enceladus",  "II",     "Saturn",      "238",     "1.37",    "0.02",  "0.00",   "Herschel",    "1789"},
251           {"Tethys",     "III",    "Saturn",      "295",     "1.89",    "1.09",  "0.00",    "Cassini",    "1684"},
252           {"Telesto",    "XIII",   "Saturn",      "295",     "1.89",    "0.00",  "0.00",      "Smith",    "1980"},
253           {"Calypso",    "XIV",    "Saturn",      "295",     "1.89",    "0.00",  "0.00",      "Pascu",    "1980"},
254           {"Dione",      "IV",     "Saturn",      "377",     "2.74",    "0.02",  "0.00",    "Cassini",    "1684"},
255           {"Helene",     "XII",    "Saturn",      "377",     "2.74",    "0.20",  "0.01",     "Laques",    "1980"},
256           {"Rhea",       "V",      "Saturn",      "527",     "4.52",    "0.35",  "0.00",    "Cassini",    "1672"},
257           {"Titan",      "VI",     "Saturn",     "1222",    "15.95",    "0.33",  "0.03",    "Huygens",    "1655"},
258           {"Hyperion",   "VII",    "Saturn",     "1481",    "21.28",    "0.43",  "0.10",       "Bond",    "1848"},
259           {"Iapetus",    "VIII",   "Saturn",     "3561",    "79.33",   "14.72",  "0.03",    "Cassini",    "1671"},
260           {"Phoebe",     "IX",     "Saturn",    "12952",  "-550.48",  "175.30",  "0.16",  "Pickering",    "1898"},
261           {"Cordelia",   "VI",     "Uranus",       "50",     "0.34",    "0.14",  "0.00",  "Voyager 2",    "1986"},
262           {"Ophelia",    "VII",    "Uranus",       "54",     "0.38",    "0.09",  "0.00",  "Voyager 2",    "1986"},
263           {"Bianca",     "VIII",   "Uranus",       "59",     "0.43",    "0.16",  "0.00",  "Voyager 2",    "1986"},
264           {"Cressida",   "IX",     "Uranus",       "62",     "0.46",    "0.04",  "0.00",  "Voyager 2",    "1986"},
265           {"Desdemona",  "X",      "Uranus",       "63",     "0.47",    "0.16",  "0.00",  "Voyager 2",    "1986"},
266           {"Juliet",     "XI",     "Uranus",       "64",     "0.49",    "0.06",  "0.00",  "Voyager 2",    "1986"},
267           {"Portia",     "XII",    "Uranus",       "66",     "0.51",    "0.09",  "0.00",  "Voyager 2",    "1986"},
268           {"Rosalind",   "XIII",   "Uranus",       "70",     "0.56",    "0.28",  "0.00",  "Voyager 2",    "1986"},
269           {"Belinda",    "XIV",    "Uranus",       "75",     "0.62",    "0.03",  "0.00",  "Voyager 2",    "1986"},
270           {"1986U10",    "",       "Uranus",       "76",     "0.64",        "",      "", "Karkoschka",    "1999"},
271           {"Puck",       "XV",     "Uranus",       "86",     "0.76",    "0.31",  "0.00",  "Voyager 2",    "1985"},
272           {"Miranda",    "V",      "Uranus",      "130",     "1.41",    "4.22",  "0.00",     "Kuiper",    "1948"},
273           {"Ariel",      "I",      "Uranus",      "191",     "2.52",    "0.00",  "0.00",    "Lassell",    "1851"},
274           {"Umbriel",    "II",     "Uranus",      "266",     "4.14",    "0.00",  "0.00",    "Lassell",    "1851"},
275           {"Titania",    "III",    "Uranus",      "436",     "8.71",    "0.00",  "0.00",   "Herschel",    "1787"},
276           {"Oberon",     "IV",     "Uranus",      "583",    "13.46",    "0.00",  "0.00",   "Herschel",    "1787"},
277           {"Caliban",    "XVI",    "Uranus",     "7169",  "-580",     "140.",    "0.08",    "Gladman",    "1997"},
278           {"Stephano",   "XX",     "Uranus",     "7948",  "-674",     "143.",    "0.24",    "Gladman",    "1999"},
279           {"Sycorax",    "XVII" ,  "Uranus",    "12213", "-1289",     "153.",    "0.51",  "Nicholson",    "1997"},
280           {"Prospero",   "XVIII",  "Uranus",    "16568", "-2019",     "152.",    "0.44",     "Holman",    "1999"},
281           {"Setebos",    "XIX",    "Uranus",    "17681", "-2239",     "158.",    "0.57",  "Kavelaars",    "1999"},
282           {"Naiad",      "III",   "Neptune",       "48",     "0.29",    "0.00",  "0.00",  "Voyager 2",    "1989"},
283           {"Thalassa",   "IV",    "Neptune",       "50",     "0.31",    "4.50",  "0.00",  "Voyager 2",    "1989"},
284           {"Despina",    "V",     "Neptune",       "53",     "0.33",    "0.00",  "0.00",  "Voyager 2",    "1989"},
285           {"Galatea",    "VI",    "Neptune",       "62",     "0.43",    "0.00",  "0.00",  "Voyager 2",    "1989"},
286           {"Larissa",    "VII",   "Neptune",       "74",     "0.55",    "0.00",  "0.00",  "Reitsema",     "1989"},
287           {"Proteus",    "VIII",  "Neptune",      "118",     "1.12",    "0.00",  "0.00",  "Voyager 2",    "1989"},
288           {"Triton",     "I",     "Neptune",      "355",    "-5.88",  "157.00",  "0.00",    "Lassell",    "1846"},
289           {"Nereid",     "II",    "Neptune",     "5513",   "360.13",   "29.00",  "0.75",     "Kuiper",    "1949"},
290           {"Charon",     "I",       "Pluto",       "20",     "6.39",   "98.80",  "0.00",    "Christy",    "1978"}
291         };
292 
293 }