jsky.catalog.skycat
Class SkycatConfigFile

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

public class SkycatConfigFile
extends AbstractCatalogDirectory

Reads a Skycat style catalog config 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.

See the Skycat web page for more information about the format of Skycat catalog config files.

Version:
$Revision: 1.3 $ $Date: 2005/05/02 20:55:16 $
Author:
Allan Brighton

Field Summary
static java.lang.String BACKUP1
           
static java.lang.String BACKUP2
           
static java.lang.String DEC_COL
           
static java.lang.String EQUINOX
           
static java.lang.String HELP
           
static java.lang.String ID_COL
           
static java.lang.String LONG_NAME
           
static java.lang.String RA_COL
           
static java.lang.String SEARCH_COLS
           
static java.lang.String SERV_TYPE
          Constants for some config file strings
static java.lang.String SHORT_NAME
           
static java.lang.String SYMBOL
           
static java.lang.String URL
           
static java.lang.String X_COL
           
static java.lang.String Y_COL
           
 
Fields inherited from interface jsky.catalog.Catalog
ARCHIVE, CATALOG, DIRECTORY, IMAGE_SERVER, LOCAL, NAME_SERVER
 
Constructor Summary
SkycatConfigFile(java.lang.String configFileOrURL)
          Parse the given skycat style config file or URL.
SkycatConfigFile(java.lang.String name, java.lang.String configFileOrURL)
          Parse the given skycat style config file or URL.
SkycatConfigFile(java.lang.String name, java.net.URL url)
          Parse the skycat style catalog config file pointed to by the given URL.
SkycatConfigFile(java.net.URL url, HTMLQueryResultHandler handler)
          Parse the skycat style config file from the already opened input stream.
 
Method Summary
 void addCatalogDirectory(java.lang.String urlStr)
          Add a catalog directory to the catalog list.
static SkycatConfigFile getConfigFile()
          If the catalog config file has already been loaded, return an object describing the contents, otherwise search for a skycat style 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 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 config file to a file under the user's home directory (~/.jsky/skycat.cfg) to make it permanent.
 void save(java.io.OutputStream stream)
          Save the contents of this object in skycat catalog config file format to the given stream.
 void save(java.lang.String filename)
          Save the contents of this object as a new skycat style catalog config file using the given file name.
static void setConfigFile(java.net.URL url)
          Set the URL to use for the default catalog config file.
 void setParent(CatalogDirectory dir)
          Set the parent catalog directory
 
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, setRegionArgs, setURL, toString, valueForPathChanged
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SERV_TYPE

public static final java.lang.String SERV_TYPE
Constants for some config file strings

See Also:
Constant Field Values

LONG_NAME

public static final java.lang.String LONG_NAME
See Also:
Constant Field Values

SHORT_NAME

public static final java.lang.String SHORT_NAME
See Also:
Constant Field Values

URL

public static final java.lang.String URL
See Also:
Constant Field Values

BACKUP1

public static final java.lang.String BACKUP1
See Also:
Constant Field Values

BACKUP2

public static final java.lang.String BACKUP2
See Also:
Constant Field Values

EQUINOX

public static final java.lang.String EQUINOX
See Also:
Constant Field Values

SYMBOL

public static final java.lang.String SYMBOL
See Also:
Constant Field Values

ID_COL

public static final java.lang.String ID_COL
See Also:
Constant Field Values

RA_COL

public static final java.lang.String RA_COL
See Also:
Constant Field Values

DEC_COL

public static final java.lang.String DEC_COL
See Also:
Constant Field Values

X_COL

public static final java.lang.String X_COL
See Also:
Constant Field Values

Y_COL

public static final java.lang.String Y_COL
See Also:
Constant Field Values

SEARCH_COLS

public static final java.lang.String SEARCH_COLS
See Also:
Constant Field Values

HELP

public static final java.lang.String HELP
See Also:
Constant Field Values
Constructor Detail

SkycatConfigFile

public SkycatConfigFile(java.lang.String name,
                        java.net.URL url)
Parse the skycat style 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

SkycatConfigFile

public SkycatConfigFile(java.lang.String name,
                        java.lang.String configFileOrURL)
Parse the given skycat style config file or URL.

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

SkycatConfigFile

public SkycatConfigFile(java.lang.String configFileOrURL)
Parse the given skycat style config file or URL.

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

SkycatConfigFile

public SkycatConfigFile(java.net.URL url,
                        HTMLQueryResultHandler handler)
Parse the skycat style config 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 SkycatConfigFile getConfigFile()
If the catalog config file has already been loaded, return an object describing the contents, otherwise search for a skycat style catalog config file, load the contents if found, and return the object for it.

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

Next, the file ~/.jsky/skycat.cfg is checked. This file is created when the user makes changes in the 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/skycat/skycat.cfg).

Returns:
a SkycatConfigFile 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 skycat style 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 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 config file to a file under the user's home directory (~/.jsky/skycat.cfg) to make it permanent. The information is saved in the same format used by the skycat application.


save

public void save(java.lang.String filename)
          throws java.io.IOException
Save the contents of this object as a new skycat style catalog config file using the given file name.

Throws:
java.io.IOException

save

public void save(java.io.OutputStream stream)
Save the contents of this object in skycat catalog config file format to the given stream.


setParent

public void setParent(CatalogDirectory dir)
Description copied from interface: Catalog
Set the parent catalog directory

Specified by:
setParent in interface Catalog
Overrides:
setParent in class AbstractCatalogDirectory

main

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