jsky.catalog.astrocat
Class AstroCatConfig

java.lang.Object
  extended by jsky.catalog.AbstractCatalogDirectory
      extended by jsky.catalog.astrocat.AstroCatConfig
All Implemented Interfaces:
java.lang.Cloneable, javax.swing.tree.TreeModel, Catalog, CatalogDirectory, QueryResult

public class AstroCatConfig
extends AbstractCatalogDirectory

Reads an AstroCat XML catalog description file and stores information about the catalogs defined there. Since catalog config files may point to other catalog config files to form a hierarchy, this class also implements the CatalogDirectory interface.

Version:
$Revision: 1.1 $
Author:
Allan Brighton

Field Summary
 
Fields inherited from interface jsky.catalog.Catalog
ARCHIVE, CATALOG, DIRECTORY, IMAGE_SERVER, LOCAL, NAME_SERVER
 
Constructor Summary
AstroCatConfig(java.lang.String configFileOrURL)
          Parse the given AstroCat XML file or URL.
AstroCatConfig(java.lang.String name, java.lang.String configFileOrURL)
          Parse the given AstroCat XML file or URL.
AstroCatConfig(java.lang.String name, java.net.URL url)
          Parse the AstroCat XML catalog config file pointed to by the given URL.
AstroCatConfig(java.net.URL url, HTMLQueryResultHandler handler)
          Parse the AstroCat XML file from the already opened input stream.
 
Method Summary
 void addCatalogDirectory(java.lang.String urlStr)
          Add a catalog directory to the catalog list.
static AstroCatConfig getConfigFile()
          If the catalog config file has already been loaded, return an object describing the contents, otherwise search for an AstroCat XML catalog config file, load the contents if found, and return the object for it.
static CatalogDirectory getDirectory()
          This method is called once at startup to load the top level catalog directory
 java.util.List getNameServers()
          Return a list of name servers (Catalogs with serv_type equal to "namesvr") to use to resolve astronomical object names.
 CatalogDirectory loadSubDir(java.net.URL url)
          Attempt to read a catalog subdirectory from the given URL and return a CatalogDirectory object for it.
static void main(java.lang.String[] args)
          Test cases
 CatalogDirectory reload()
          Reload the catalog config file and return the new object for it.
 void save()
          Save the catalog list in the default location (~/.jsky/AstroCat.xml)
 void save(java.lang.String filename)
          Save the catalog list to the given file (in the AstroCat XML format).
static void setConfigFile(java.net.URL url)
          Set the URL to use for the default catalog config file.
 
Methods inherited from class jsky.catalog.AbstractCatalogDirectory
addCatalog, addCatalog, addTreeModelListener, clone, getCatalog, getCatalog, getCatalogList, getCatalogs, getChild, getChildCount, getDescription, getDocURL, getHTMLQueryResultHandler, getId, getIndexOfChild, getName, getNumCatalogs, getNumParams, getParamDesc, getParamDesc, getParent, getPath, getPath, getRoot, getRootCatalogDirectory, getTitle, getType, getURL, indexOf, isImageServer, isLeaf, isLocal, moveCatalog, moveCatalogToEnd, query, removeCatalog, removeTreeModelListener, replaceCatalog, setCatalogs, setHTMLQueryResultHandler, setId, setName, setParent, setRegionArgs, setURL, toString, valueForPathChanged
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AstroCatConfig

public AstroCatConfig(java.lang.String name,
                      java.net.URL url)
Parse the AstroCat XML catalog config file pointed to by the given URL.

Parameters:
name - the display name for the config file
url - the URL of the config file

AstroCatConfig

public AstroCatConfig(java.lang.String name,
                      java.lang.String configFileOrURL)
Parse the given AstroCat XML file or URL.

Parameters:
name - the display name for the config file
configFileOrURL - the file name or URL of the config file

AstroCatConfig

public AstroCatConfig(java.lang.String configFileOrURL)
Parse the given AstroCat XML file or URL.

Parameters:
configFileOrURL - the file name or URL of the config file

AstroCatConfig

public AstroCatConfig(java.net.URL url,
                      HTMLQueryResultHandler handler)
Parse the AstroCat XML file from the already opened input stream. The URL is passed as a reference.

Parameters:
url - the URL of the config file
handler - used to report HTML errors from the HTTP server
Method Detail

getDirectory

public static CatalogDirectory getDirectory()
This method is called once at startup to load the top level catalog directory


getConfigFile

public static AstroCatConfig getConfigFile()
If the catalog config file has already been loaded, return an object describing the contents, otherwise search for an AstroCat XML catalog config file, load the contents if found, and return the object for it.

First the jsky.catalog.astrocat.config system property is checked. If set, it should be the URL string or file name of the config file.

Next, the file ~/.jsky/AstroCat.xml is checked. This file is created automatically when the user makes any changes in the catalog configuration or plot symbol settings in the table display/configure window.

Finally, a default URL s used. It may be set by calling "setConfigFile" and defaults to a config file included in this package (as a resource file: jsky/catalog/astrocat/conf/AstroCat.xml).

Returns:
a AstroCatConfig object constructed from the file.

reload

public CatalogDirectory reload()
Reload the catalog config file and return the new object for it.


loadSubDir

public CatalogDirectory loadSubDir(java.net.URL url)
Attempt to read a catalog subdirectory from the given URL and return a CatalogDirectory object for it.

Returns:
the new CatalogDirectory
Throws:
java.lang.RuntimeException - if the catalog directory could not be created

setConfigFile

public static void setConfigFile(java.net.URL url)
Set the URL to use for the default catalog config file.

Parameters:
url - points to the AstroCat XML catalog config file

addCatalogDirectory

public void addCatalogDirectory(java.lang.String urlStr)
Add a catalog directory to the catalog list.

Parameters:
urlStr - the URL of a catalog config file.

getNameServers

public java.util.List getNameServers()
Return a list of name servers (Catalogs with serv_type equal to "namesvr") to use to resolve astronomical object names.

Specified by:
getNameServers in interface CatalogDirectory
Overrides:
getNameServers in class AbstractCatalogDirectory

save

public void save()
Save the catalog list in the default location (~/.jsky/AstroCat.xml)


save

public void save(java.lang.String filename)
Save the catalog list to the given file (in the AstroCat XML format). Since the user can only edit the catalog list and the symbol definitions, only that information is actually saved. The rest of the details are still read from the original, default XML file.

Parameters:
filename - the file name in which to store the catalog information

main

public static void main(java.lang.String[] args)
Test cases