edu.jhu.pha.ivoa
Class WSRetrievalChooser

java.lang.Object
  |
  +--edu.jhu.pha.ivoa.WSRetrievalChooser
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, java.beans.PropertyChangeListener

public class WSRetrievalChooser
extends java.lang.Object
implements java.awt.event.ActionListener, java.beans.PropertyChangeListener

   Current Version
   ===============
   ID:            $Id: WSRetrievalChooser.html,v 1.3 2003/08/18 18:05:02 carliles Exp $
   Revision:      $Revision: 1.3 $
   Date/time:     $Date: 2003/08/18 18:05:02 $
   
This class provides a graphical interface with which a user can perform Cone Searches and queries against the SDSS CAS. Really the class doesn't perform the searches, but rather constructs URLs from which InputStreams can be opened and read. The registry used by WSRetrievalChooser can be set to a non-default value by specifying the value of the system property "registry" using the -Dregistry="http://www.starfleet.edu/registry/" flag to the JVM, where, of course, the value shown here is entirely fictitious. The following is a simple example of how to use this class.
   import java.io.*;
   import java.net.*;

   import edu.jhu.pha.ivoa.*;

   public class WSRetrievalChooserTester
   {
     public static void main(String[] args) throws Exception
     {
       WSRetrievalChooser chooser = new WSRetrievalChooser();
       int status = APPROVE_OPTION;

       while(status == APPROVE_OPTION)
       {
         try
         {
           status = chooser.showRetrieveDialog(null);

           if(status == APPROVE_OPTION)
           {
             NameURLPair[] urls = chooser.getNameURLPairs();

             for(int i = 0; i < urls.length; ++i)
             {
               BufferedReader in =
                 new BufferedReader(new InputStreamReader((InputStream)urls[i].
                                                          getURL().
                                                          getContent()));

               for(String line = in.readLine(); line != null; line = in.readLine())
               {
                 System.out.println(line);
               }
               System.out.flush();
             }
           }
         }
         catch(Exception e)
         {
           e.printStackTrace();
         }
       }
     }
   }
   


Field Summary
static int APPROVE_OPTION
           
static int CANCEL_OPTION
           
static java.lang.String DEFAULT_REGISTRY_URL
           
static int ERROR_OPTION
           
 
Constructor Summary
WSRetrievalChooser()
           
WSRetrievalChooser(java.lang.String updateMessage)
          A constructor which allows a non-default message to be given to the user if WSRetrievalChooser determines that this version is too old and should be updated.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void dispose()
           
static edu.jhu.pha.ivoa.NameURLPair[] getImageNameURLPairs(java.io.InputStream siapStream, java.lang.String namePrefix)
           
 edu.jhu.pha.ivoa.NameURLPair[] getNameURLPairs()
           
 edu.jhu.pha.ivoa.NameURLPair[] getSIAPNameURLPairs()
           
static void main(java.lang.String[] args)
          For testing purposes.
 boolean prefetchImages()
           
 void propertyChange(java.beans.PropertyChangeEvent e)
           
static java.lang.String revision()
           
 int showRetrieveDialog(javax.swing.JComponent parent)
          Pops up the JDialog which prompts the user for Cone or CAS search parameters.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_REGISTRY_URL

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

APPROVE_OPTION

public static final int APPROVE_OPTION
See Also:
Constant Field Values

CANCEL_OPTION

public static final int CANCEL_OPTION
See Also:
Constant Field Values

ERROR_OPTION

public static final int ERROR_OPTION
See Also:
Constant Field Values
Constructor Detail

WSRetrievalChooser

public WSRetrievalChooser()
                   throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

WSRetrievalChooser

public WSRetrievalChooser(java.lang.String updateMessage)
                   throws java.rmi.RemoteException
A constructor which allows a non-default message to be given to the user if WSRetrievalChooser determines that this version is too old and should be updated. This is useful in the case where WSRetrievalChooser may be distributed as a component of another piece of software, and the user should get an updated version of that software rather than just of this package.

If the default registry location value is overridden by setting the "registry" system property, the specified registry is tried first. If retrieval of data from this registry fails for some reason, the user is notified and connection to the default registry is attempted. If this fails, the user is notified that they probably need to download a new version of the software (since registry connection failures will usually result from updating the WSDL description for the registry), and any further use of the instance of this class that's returned will result in undefined behavior.

Throws:
java.rmi.RemoteException
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
For testing purposes.

Throws:
java.lang.Exception

showRetrieveDialog

public int showRetrieveDialog(javax.swing.JComponent parent)
                       throws java.lang.Exception
Pops up the JDialog which prompts the user for Cone or CAS search parameters.

Parameters:
parent - The (possibly null) parent JComponent of the JDialog that will be popped up.
Returns:
The option the user selected for the operation, one of APPROVE_OPTION, CANCEL_OPTION, or ERROR_OPTION.
Throws:
java.lang.Exception

getNameURLPairs

public edu.jhu.pha.ivoa.NameURLPair[] getNameURLPairs()
Returns:
An array of NameURLPairs encapsulating all of the URLs required to fulfill the user's request, along with reasonably short yet descriptive names for each URL.

getSIAPNameURLPairs

public edu.jhu.pha.ivoa.NameURLPair[] getSIAPNameURLPairs()

getImageNameURLPairs

public static edu.jhu.pha.ivoa.NameURLPair[] getImageNameURLPairs(java.io.InputStream siapStream,
                                                                  java.lang.String namePrefix)
                                                           throws java.lang.Exception
java.lang.Exception

prefetchImages

public boolean prefetchImages()

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

dispose

public void dispose()

revision

public static java.lang.String revision()
Returns:
CVS Revision number.