
/**
* Titre : Sesame
* Description : Resolves names in Simbad, VizieR and/or NED
* Copyright : Copyright (c) 2002-2003
* Société : Centre de Données Astronomique de Strasbourg
* @author André Schaaff
* @version 1.0
*/
// package generated with the following command
// java org.apache.axis.wsdl.WSDL2Java http://cdsws.u-strasbg.fr/axis/services/Sesame?wsdl

package uk.ac.roe.wfau;

import java.rmi.RemoteException;
import java.util.StringTokenizer;

import javax.xml.rpc.ServiceException;

import sesame_pkg.Sesame;
import sesame_pkg.SesameService;
import sesame_pkg.SesameServiceLocator;

public class SesameClient{
String ra;
String dec;
String sexagesimalRA;
String sexagesimalDec;

double raValue=-999;
double decValue=-999;
  public SesameClient(String name) throws ServiceException,RemoteException,NumberFormatException,Exception{

    

      // locator creation
      SesameService locator = new SesameServiceLocator();

      // Sesame object
      Sesame myv = locator.getSesame();

      // resolves the name for m31 and XML result format
      try {
      String result = myv.sesame(name, "u");
      
      String sub = result.substring(result.indexOf("%J")+2,result.indexOf("\n",result.indexOf("%J"))).trim();
      //System.out.println(sub);
      StringTokenizer st = new StringTokenizer(sub," =");
      ra=st.nextToken();
      dec=st.nextToken();
     
      //sexagesimalRA=st.nextToken();
      //sexagesimalDec=st.nextToken();
 
      /*
      System.out.println(ra);
      System.out.println(dec);
      System.out.println(sexagesimalRA);
      System.out.println(sexagesimalDec);
      */
	  raValue = Double.parseDouble(ra);
  	  decValue = Double.parseDouble(dec);
      /*
      System.out.println(raValue);
      System.out.println(decValue);
      */
      }
      catch (Exception e) {
          throw new Exception("Unable to resolve name into valid RA/Dec");
      }
  }
  public String getRA() {
      return ra;
  }
  public String getDec() {
      return dec;
  }
  public static void main(String [] args) throws Exception {
    new SesameClient("ngc300");
  }
}  