Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

MSDJapi.java

00001 //-----------------------------------------------------
00002 // MSDJapi.java
00003 //
00004 // Project: PDBe API Framework, EBI  
00005 // Module:  Implementation of User Layer Master input and final class 
00006 // needed for Java Native Interface methods to input into the javah.
00007 // This will crate MSDJapi.h automatically.
00008 // 
00009 //
00010 // 
00011 // User Layer
00012 // Last updated: 25 February 2004 10:17
00013 // (C) Siamak Sobhany
00014 //------------------------------------------------------
00015 // Instructions:
00016 // set the LD_LIBRARY_PATH for java to find native-method MSDJapi shared libraries
00017 
00018 //
00019 //gcc -E /ebi/msd/work/siamak/msd_api/include/msd_user.h > user_e.h 
00020 //crate file: jclass.cfg (to determine which structs should be converted)
00021 //javac -d . -classpath . *.java 
00022 //java structConverter.structConverter -C user_e.h
00023 
00024 import java.lang.*;
00025 // Declare a class like any other
00026 public class MSDJapi
00027 {
00028          public native int initMSDJapi();
00029          public native int rloginMSDJapi( java.lang.String loginstring );
00030          public native int attachMSDJapi( java.lang.String host );
00031          public native int beginMSDJapi( java.lang.String user, java.lang.String pass );
00032          public native int sqlinitMSDJapi( java.lang.String sql  );
00033          public native int setcriteriaMSDJapi( java.lang.String fmt, java.lang.String[] arglist );
00034          public native int getrownumMSDJapi();
00035          public native int getnextMSDJapi();
00036          public native float getfloatMSDJapi(int col);
00037          public native int getintMSDJapi(int col);
00038          public native double getdoubletMSDJapi(int col);
00039          public native java.lang.String getstrMSDJapi(int col);
00040      public native int endMSDJapi();
00041          public native int detachMSDJapi();
00042          public native int logoffMSDJapi();
00043          public native int freeMSDJapi();
00044          public native int managerMSDJapi();
00045      public native java.lang.String getAccessionCodeMSDJapi(int eID);
00046          public native int getEntryIDMSDJapi(java.lang.String acc_code);
00047          public native int getObjectEntryMSDJapi(int eID);
00048          public native int getNumOfAtomsMSDJapi();
00049          public native int printfMSDJapi( java.lang.String text );
00050          
00051          // the main method allows us to run this class as an application
00052          public static void main( String args[] )
00053          {
00054                   MSDJapi msdjapiObject = new MSDJapi();
00055                 
00056                    java.lang.String statement="SELECT " +
00057           "a.chem_comp_code, a.Orig_x, a.Orig_y, a.Orig_z, " +
00058           "a.residue_id, a.residue_pdb_seq, a.residue_pdb_insert_code, a.chain_id, " +
00059           "a.chain_code, a.Non_Assembly_Valid " +
00060           "FROM atom_data a " +
00061           "WHERE a.assembly_id = 43472 " +
00062           "AND a.entry_id = :f<int> ";
00063           java.lang.String arg1 = new java.lang.String("38175");
00064                   java.lang.String[] criteriaArgs = {arg1};
00065           int recnum, jj=0;
00066                 
00067                   if( args.length < 3 ){
00068                                 msdjapiObject.printfMSDJapi( "Enter Oracle Host, Login name and Password." );}
00069                   else {
00070                         
00071                                 msdjapiObject.initMSDJapi();
00072                                 
00073                                 msdjapiObject.attachMSDJapi( args[0] );
00074                                 
00075                                 
00076                                 msdjapiObject.beginMSDJapi(  args[1] , args[2] );
00077                
00078                                 
00079                                 
00080                                 
00081                                 msdjapiObject.sqlinitMSDJapi(  statement );
00082                 msdjapiObject.setcriteriaMSDJapi(  "i", criteriaArgs );
00083                                 
00084                 recnum = msdjapiObject.getrownumMSDJapi();
00085                 while (recnum < 26612 )  // 26612
00086                 { recnum  = msdjapiObject.getrownumMSDJapi();
00087                                   msdjapiObject.getnextMSDJapi();
00088                                   if (recnum % 1000 == 0)
00089                                         {System.out.println("\nRecord number = " + recnum + "\nFloat Value = " + msdjapiObject.getfloatMSDJapi(1) +
00090                                           "\nString value = " + msdjapiObject.getstrMSDJapi(0)
00091                                           );
00092                                          
00093                                         }
00094                                 
00095                                 }
00096                                 
00097                 
00098                                 }
00099 
00100                          System.out.println("\nACCESSION CODE for: " + msdjapiObject.getAccessionCodeMSDJapi(38175));
00101                  System.out.println("\nEntry ID for: " + msdjapiObject.getEntryIDMSDJapi("1gw5"));
00102              
00103                      msdjapiObject.endMSDJapi();
00104              msdjapiObject.detachMSDJapi();
00105                          msdjapiObject.logoffMSDJapi();
00106                          msdjapiObject.freeMSDJapi();
00107          
00108         
00109          }
00110          
00111          // the static initialization section must load the shared library
00112          static 
00113          {
00114                  
00115           String library = "MSDJapi";
00116                   try
00117                   {
00118                                 
00119                                 System.loadLibrary( library );
00120                                 
00121                   }
00122                   catch( Exception e )
00123                   {
00124                                 System.out.println( "\nERROR: Unable to load " + library + "\nException: " + e + "\n" );
00125                   }
00126          } // end static
00127 } //end class MSDJapi
00128 
00129 class MSDEnv
00130 {
00131 
00132     private int ConID;
00133 
00134     public void setConID(int lcl_arg0)
00135     {
00136         ConID = lcl_arg0;
00137     }
00138     public int getConID()
00139     {
00140         return ConID;
00141     }
00142 
00143     private int SqlID;
00144 
00145     public void setSqlID(int lcl_arg0)
00146     {
00147         SqlID = lcl_arg0;
00148     }
00149     public int getSqlID()
00150     {
00151         return SqlID;
00152     }
00153     private native static void initFIDs();
00154 
00155     static {
00156         initFIDs();
00157     }
00158 
00159 }
00160  
00161 
00162                   

Generated on Fri Apr 16 13:47:44 2004 for MSDAPI by doxygen 1.3.4-20031005