View Javadoc

1   /*
2      CdsUcdDictionary.java
3   
4      Date      Author      Changes
5      $date$    M Hill      Created
6   
7      (c) Copyright...
8   */
9   
10  package org.astrogrid.common.ucd;
11  
12  import java.net.URL;
13  
14  /***
15   * CdsUcdDictionary.
16   *
17   * An implementation of a Ucd dictionary based on the web page provided by
18   * CDS (Centre de Donn?es Astronomiques de Strasbourg).  It will retrieve
19   * that web page and parse it to check the UCD exists on it (and to get its
20   * description if necessary).
21   * <p>
22   * A singleton - use getInstance().  This will allow us to cache the page, or
23   * indeed cache all UCDs on that page when first instantiated.
24   * <p>
25   * Not yet implemented - currently returns 'true' for all strings.
26   * <p>
27   * @version %I%
28   * @author M Hill
29   */
30     
31  public class CdsUcdDictionary implements UcdDictionary
32  {
33     private static final String cdsPage = "http://cdsweb.u-strasbg.fr/viz-bin/UCDs";
34  
35     private static final UcdDictionary INSTANCE = new CdsUcdDictionary();
36  
37     /*** Private constructor so that only getInstance() can be used to access
38      * an instance, ensuring only one instance can be made (@see Singleton)
39      */
40     private CdsUcdDictionary()
41     {
42        super();
43     }
44        
45     
46     /*** @see UcdDictionary.isUcdValid */
47     public boolean isUcdValid(String ucd)
48     {
49        // Not yet implemented
50        return true;
51     }
52     
53     /*** @see UcdDictionary.assertUcdValid */
54     public void assertUcdValid(String ucd) throws IllegalUcdException
55     {
56        if (!isUcdValid(ucd))
57           throw new IllegalUcdException(ucd, "UCD not found at CDS website '"+cdsPage+"'");
58     }
59  
60     /*** @see UcdDictionary.getUcdDescription */
61     public String getUcdDescription(String ucd) throws IllegalUcdException
62     {
63        //not yet implemented
64        return "<Unknown desc>";
65     }
66  
67     /*** Returns the singleton instance of this class. */
68     public static UcdDictionary getInstance()
69     {
70        return INSTANCE;
71     }
72  }
73