1
2
3
4
5
6
7
8
9
10 package org.astrogrid.common.units;
11
12 import java.net.URL;
13
14 /***
15 * CdsUnitDictionary...
16 *
17 * An implementation of a Unit dictionary based on a web page provided by
18 * CDS (Centre de Donn?es Astronomiques de Strasbourg) at
19 * http://vizier.u-strasbg.fr/doc/catstd-3.2.htx
20 *
21 * @version %I%
22 * @author M Hill
23 */
24
25 public class CdsUnitDictionary implements UnitDictionary
26 {
27 private static final String cdsPage = "http://vizier.u-strasbg.fr/doc/catstd-3.2.htx";
28
29 private static final UnitDictionary INSTANCE = new CdsUnitDictionary();
30
31 /*** Private so that no external objects can create it, and so ensure that
32 * it is a singleton
33 */
34 private CdsUnitDictionary()
35 {
36 super();
37 }
38
39 /*** @see UnitDictionary.isUnitValid */
40 public boolean isUnitValid(String unit)
41 {
42
43 return true;
44 }
45
46 /*** @see UnitDictionary.assertUnitValid */
47 public void assertUnitValid(String unit) throws IllegalUnitException
48 {
49 if (!isUnitValid(unit))
50 throw new IllegalUnitException(unit, "Unit not found at CDS website '"+cdsPage+"'");
51 }
52
53
54 public String getUnitDescription(String unit) throws IllegalUnitException
55 {
56
57 return "<Unknown desc>";
58 }
59
60 public String convertValue(String value, String units, String targetUnits) throws IllegalUnitException
61 {
62 assertUnitValid(units);
63 assertUnitValid(targetUnits);
64
65
66
67
68
69 return null;
70
71 }
72
73 public static UnitDictionary getInstance()
74 {
75 return INSTANCE;
76 }
77
78 }
79