jsky.catalog
Class AbstractCatalogDirectory

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

public abstract class AbstractCatalogDirectory
extends java.lang.Object
implements CatalogDirectory

A generic, abstract base class for catalog directory implementations.

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
AbstractCatalogDirectory(java.lang.String name)
          Initialize with the name of the catalog directory.
 
Method Summary
 void addCatalog(Catalog cat)
          Add the given catalog to the catalog list if it is not already there.
 void addCatalog(int index, Catalog cat)
          Add the given catalog to the catalog list if it is not already there.
 void addTreeModelListener(javax.swing.event.TreeModelListener l)
          Adds a listener for the TreeModelEvent posted after the tree changes.
 java.lang.Object clone()
          Implementation of the clone method (makes a shallow copy).
 Catalog getCatalog(int i)
          Return the ith catalog in the directory
 Catalog getCatalog(java.lang.String catalogName)
          Return the named catalog, if found in this directory
 TableQueryResult getCatalogList()
          Return a memory catalog describing the list of catalogs in the directory
 java.util.List getCatalogs()
          Return a copy of the list of catalogs in this catalog directory.
 java.lang.Object getChild(java.lang.Object parent, int index)
          Returns the child of parent at index index in the parent's child array.
 int getChildCount(java.lang.Object parent)
          Returns the number of children of parent.
 java.lang.String getDescription()
          Return a description of the catalog, or null if not available
 java.net.URL getDocURL()
          Return a URL pointing to documentation for the catalog, or null if not available
 HTMLQueryResultHandler getHTMLQueryResultHandler()
          Return the handler used to report HTML format errors from servers
 java.lang.String getId()
          Return the Id or short name of the catalog directory
 int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
          Returns the index of child in parent.
 java.lang.String getName()
          Return the name of the 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.
 int getNumCatalogs()
          Return the number of catalogs in this directory
 int getNumParams()
          Return the number of query parameters that this catalog accepts
 FieldDesc getParamDesc(int i)
          Return a description of the ith query parameter
 FieldDesc getParamDesc(java.lang.String name)
          Return a description of the named query parameter
 CatalogDirectory getParent()
          Return a reference to the parent catalog directory, or null if not known.
 Catalog[] getPath()
          Return an array of Catalog or CatalogDirectory objects representing the path from the root catalog directory to this catalog.
 Catalog[] getPath(Catalog cat)
          Return an array of catalogs describing the path to the given catalog or catalog directory.
 java.lang.Object getRoot()
          Returns the root of the tree.
 AbstractCatalogDirectory getRootCatalogDirectory()
          Returns the root catalog directory, casted to an AbstractCatalogDirectory.
 java.lang.String getTitle()
          Return a string to display as a title for the catalog directory in a user interface
 java.lang.String getType()
          Return the catalog type (one of the constants: CATALOG, ARCHIVE, DIRECTORY, LOCAL, IMAGE_SERVER)
 java.net.URL getURL()
          Return the URL of the file describing this catalog directory.
 int indexOf(Catalog cat)
          Return the index of the given catalog in the directory
 boolean isImageServer()
          Return true if this object represents an image server.
 boolean isLeaf(java.lang.Object node)
          Returns true if node is a leaf.
 boolean isLocal()
          Return true if this is a local catalog, and false if it requires network access or if a query could hang.
 void moveCatalog(Catalog cat, boolean up)
          Move the the given catalog up or down in the tree.
 void moveCatalogToEnd(Catalog cat, boolean up)
          Move the the given catalog all the way up or down in the tree, as far as possible.
 QueryResult query(QueryArgs queryArgs)
          This method assumes the catalog directory has no query parameters and just returns "this".
 void removeCatalog(Catalog cat)
          Remove the given catalog from the catalog list.
 void removeTreeModelListener(javax.swing.event.TreeModelListener l)
          Removes a listener previously added with addTreeModelListener.
 void replaceCatalog(Catalog oldCat, Catalog newCat)
          Replace the given old catalog with the given new catalog in the catalog list.
 void setCatalogs(java.util.List catalogs)
          Set the list of catalogs in this catalog directory.
 void setHTMLQueryResultHandler(HTMLQueryResultHandler handler)
          Optional handler, used to report HTML format errors from servers
 void setId(java.lang.String id)
          Set the Id or short name of the catalog directory
 void setName(java.lang.String name)
          Return the name of the catalog directory
 void setParent(CatalogDirectory dir)
          Set the parent catalog directory
 void setRegionArgs(QueryArgs queryArgs, CoordinateRadius region)
          This method is required to implement the Catalog interface, but does nothing here.
 void setURL(java.net.URL url)
          Set the URL of the file describing this catalog directory.
 java.lang.String toString()
          Return a string representing this object (in this case the name)
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
          Messaged when the user has altered the value for the item identified by path to newValue.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jsky.catalog.CatalogDirectory
loadSubDir, reload, save
 

Constructor Detail

AbstractCatalogDirectory

public AbstractCatalogDirectory(java.lang.String name)
Initialize with the name of the catalog directory.

Parameters:
name - the display name for the catalog directory
Method Detail

clone

public java.lang.Object clone()
Implementation of the clone method (makes a shallow copy).

Specified by:
clone in interface Catalog
Overrides:
clone in class java.lang.Object

getParent

public CatalogDirectory getParent()
Description copied from interface: Catalog
Return a reference to the parent catalog directory, or null if not known.

Specified by:
getParent in interface Catalog

setParent

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

Specified by:
setParent in interface Catalog

getHTMLQueryResultHandler

public HTMLQueryResultHandler getHTMLQueryResultHandler()
Return the handler used to report HTML format errors from servers


setHTMLQueryResultHandler

public void setHTMLQueryResultHandler(HTMLQueryResultHandler handler)
Optional handler, used to report HTML format errors from servers


toString

public java.lang.String toString()
Return a string representing this object (in this case the name)

Overrides:
toString in class java.lang.Object

addCatalog

public void addCatalog(int index,
                       Catalog cat)
Add the given catalog to the catalog list if it is not already there. If a separate catalog with the same name is in the list, the user is asked if it should be removed.


addCatalog

public void addCatalog(Catalog cat)
Add the given catalog to the catalog list if it is not already there. If a separate catalog with the same name is in the list, the user is asked if it should be removed.

Specified by:
addCatalog in interface CatalogDirectory

removeCatalog

public void removeCatalog(Catalog cat)
Remove the given catalog from the catalog list.

Specified by:
removeCatalog in interface CatalogDirectory

replaceCatalog

public void replaceCatalog(Catalog oldCat,
                           Catalog newCat)
Replace the given old catalog with the given new catalog in the catalog list.

Specified by:
replaceCatalog in interface CatalogDirectory

moveCatalog

public void moveCatalog(Catalog cat,
                        boolean up)
Move the the given catalog up or down in the tree.

Specified by:
moveCatalog in interface CatalogDirectory

moveCatalogToEnd

public void moveCatalogToEnd(Catalog cat,
                             boolean up)
Move the the given catalog all the way up or down in the tree, as far as possible.

Specified by:
moveCatalogToEnd in interface CatalogDirectory

getCatalog

public Catalog getCatalog(java.lang.String catalogName)
Return the named catalog, if found in this directory

Specified by:
getCatalog in interface CatalogDirectory

getNumCatalogs

public int getNumCatalogs()
Return the number of catalogs in this directory

Specified by:
getNumCatalogs in interface CatalogDirectory

getCatalog

public Catalog getCatalog(int i)
Return the ith catalog in the directory

Specified by:
getCatalog in interface CatalogDirectory

indexOf

public int indexOf(Catalog cat)
Return the index of the given catalog in the directory

Specified by:
indexOf in interface CatalogDirectory

setCatalogs

public void setCatalogs(java.util.List catalogs)
Set the list of catalogs in this catalog directory.


getCatalogs

public java.util.List getCatalogs()
Return a copy of the list of catalogs in this catalog directory.


getCatalogList

public TableQueryResult getCatalogList()
Return a memory catalog describing the list of catalogs in the directory

Specified by:
getCatalogList in interface CatalogDirectory

getURL

public java.net.URL getURL()
Return the URL of the file describing this catalog directory.


setURL

public void setURL(java.net.URL url)
Set the URL of the file describing this catalog directory.


getName

public java.lang.String getName()
Return the name of the catalog directory

Specified by:
getName in interface Catalog

setName

public void setName(java.lang.String name)
Return the name of the catalog directory

Specified by:
setName in interface Catalog

getTitle

public java.lang.String getTitle()
Return a string to display as a title for the catalog directory in a user interface

Specified by:
getTitle in interface Catalog

getId

public java.lang.String getId()
Return the Id or short name of the catalog directory

Specified by:
getId in interface Catalog

setId

public void setId(java.lang.String id)
Set the Id or short name of the catalog directory


getDescription

public java.lang.String getDescription()
Return a description of the catalog, or null if not available

Specified by:
getDescription in interface Catalog

getDocURL

public java.net.URL getDocURL()
Return a URL pointing to documentation for the catalog, or null if not available

Specified by:
getDocURL in interface Catalog

getNumParams

public int getNumParams()
Return the number of query parameters that this catalog accepts

Specified by:
getNumParams in interface Catalog

getParamDesc

public FieldDesc getParamDesc(int i)
Return a description of the ith query parameter

Specified by:
getParamDesc in interface Catalog

getParamDesc

public FieldDesc getParamDesc(java.lang.String name)
Return a description of the named query parameter

Specified by:
getParamDesc in interface Catalog

setRegionArgs

public void setRegionArgs(QueryArgs queryArgs,
                          CoordinateRadius region)
This method is required to implement the Catalog interface, but does nothing here.

Specified by:
setRegionArgs in interface Catalog
Parameters:
queryArgs - (in/out) describes the query arguments
region - (in) describes the query region (center and radius range)

isLocal

public boolean isLocal()
Return true if this is a local catalog, and false if it requires network access or if a query could hang. A local catalog query is run in the event dispatching thread, while others are done in a separate thread.

Specified by:
isLocal in interface Catalog

isImageServer

public boolean isImageServer()
Return true if this object represents an image server.

Specified by:
isImageServer in interface Catalog

getType

public java.lang.String getType()
Return the catalog type (one of the constants: CATALOG, ARCHIVE, DIRECTORY, LOCAL, IMAGE_SERVER)

Specified by:
getType in interface Catalog

query

public QueryResult query(QueryArgs queryArgs)
                  throws java.io.IOException
This method assumes the catalog directory has no query parameters and just returns "this".

Specified by:
query in interface Catalog
Parameters:
queryArgs - An object describing the query arguments (not used here)
Returns:
An object describing the result of the query
Throws:
java.io.IOException

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

getRootCatalogDirectory

public AbstractCatalogDirectory getRootCatalogDirectory()
Returns the root catalog directory, casted to an AbstractCatalogDirectory. This returns the same value as the getRoot() method.


getRoot

public java.lang.Object getRoot()
Returns the root of the tree. Returns null only if the tree has no nodes.

Specified by:
getRoot in interface javax.swing.tree.TreeModel
Returns:
the root of the tree

getChild

public java.lang.Object getChild(java.lang.Object parent,
                                 int index)
Returns the child of parent at index index in the parent's child array. parent must be a node previously obtained from this data source. This should not return null if index is a valid index for parent (that is index >= 0 && index < getChildCount(parent)).

Specified by:
getChild in interface javax.swing.tree.TreeModel
Parameters:
parent - a node in the tree, obtained from this data source
Returns:
the child of parent at index index

getChildCount

public int getChildCount(java.lang.Object parent)
Returns the number of children of parent. Returns 0 if the node is a leaf or if it has no children. parent must be a node previously obtained from this data source.

Specified by:
getChildCount in interface javax.swing.tree.TreeModel
Parameters:
parent - a node in the tree, obtained from this data source
Returns:
the number of children of the node parent

isLeaf

public boolean isLeaf(java.lang.Object node)
Returns true if node is a leaf. It is possible for this method to return false even if node has no children. A directory in a filesystem, for example, may contain no files; the node representing the directory is not a leaf, but it also has no children.

Specified by:
isLeaf in interface javax.swing.tree.TreeModel
Parameters:
node - a node in the tree, obtained from this data source
Returns:
true if node is a leaf

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath path,
                                java.lang.Object newValue)
Messaged when the user has altered the value for the item identified by path to newValue. If newValue signifies a truly new value the model should post a treeNodesChanged event.

Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel
Parameters:
path - path to the node that the user has altered
newValue - the new value from the TreeCellEditor

getIndexOfChild

public int getIndexOfChild(java.lang.Object parent,
                           java.lang.Object child)
Returns the index of child in parent. If parent is null or child is null, returns -1.

Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel
Parameters:
parent - a note in the tree, obtained from this data source
child - the node we are interested in
Returns:
the index of the child in the parent, or -1 if either child or parent are null

addTreeModelListener

public void addTreeModelListener(javax.swing.event.TreeModelListener l)
Adds a listener for the TreeModelEvent posted after the tree changes.

Specified by:
addTreeModelListener in interface javax.swing.tree.TreeModel
Parameters:
l - the listener to add
See Also:
removeTreeModelListener(javax.swing.event.TreeModelListener)

removeTreeModelListener

public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
Removes a listener previously added with addTreeModelListener.

Specified by:
removeTreeModelListener in interface javax.swing.tree.TreeModel
Parameters:
l - the listener to remove
See Also:
addTreeModelListener(javax.swing.event.TreeModelListener)

getPath

public Catalog[] getPath(Catalog cat)
Return an array of catalogs describing the path to the given catalog or catalog directory.

Specified by:
getPath in interface CatalogDirectory

getPath

public Catalog[] getPath()
Return an array of Catalog or CatalogDirectory objects representing the path from the root catalog directory to this catalog.

Specified by:
getPath in interface Catalog