001    package org.apache.myfaces.tobago.example.demo.model.solar;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one or more
005     * contributor license agreements.  See the NOTICE file distributed with
006     * this work for additional information regarding copyright ownership.
007     * The ASF licenses this file to You under the Apache License, Version 2.0
008     * (the "License"); you may not use this file except in compliance with
009     * the License.  You may obtain a copy of the License at
010     *
011     *      http://www.apache.org/licenses/LICENSE-2.0
012     *
013     * Unless required by applicable law or agreed to in writing, software
014     * distributed under the License is distributed on an "AS IS" BASIS,
015     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016     * See the License for the specific language governing permissions and
017     * limitations under the License.
018     */
019    
020    /**
021     * User: weber
022     * Date: Nov 5, 2002
023     * Time: 7:15:14 PM
024     */
025    
026    import java.util.ArrayList;
027    import java.util.List;
028    
029    public class SolarObject {
030    
031      private String name;
032    
033      private String number;
034    
035      private String orbit;
036    
037      private Integer distance;
038    
039      private Double period;
040    
041      private Double incl;
042    
043      private Double eccen;
044    
045      private String discoverer;
046    
047      private Integer discoverYear;
048    
049      private String population;
050    
051      public SolarObject(String[] strings) {
052        this.name = strings[0];
053        this.number = strings[1];
054        this.orbit = strings[2];
055        try {
056          this.distance = Integer.valueOf(strings[3]);
057        } catch (NumberFormatException e) {
058          new Integer(0);
059        }
060        try {
061          this.period = Double.valueOf(strings[4]);
062        } catch (NumberFormatException e) {
063          new Double(0);
064        }
065        try {
066          this.incl = Double.valueOf(strings[5]);
067        } catch (NumberFormatException e) {
068          new Double(0);
069        }
070        try {
071          this.eccen = Double.valueOf(strings[6]);
072        } catch (NumberFormatException e) {
073          new Double(0);
074        }
075        this.discoverer = strings[7];
076        try {
077          this.discoverYear = Integer.valueOf(strings[8]);
078        } catch (NumberFormatException e) {
079          new Integer(0);
080        }
081        if (strings[0].equals("Earth")) {
082          population = "ca.5500000000";
083        } else {
084          population = "0";
085        }
086      }
087    
088      public String getName() {
089        return name;
090      }
091    
092      public void setName(String name) {
093        this.name = name;
094      }
095    
096      public String getNumber() {
097        return number;
098      }
099    
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    }