edu.ucsb.nceas.metacat
Class MetaCatUtil

java.lang.Object
  |
  +--edu.ucsb.nceas.metacat.MetaCatUtil

public class MetaCatUtil
extends java.lang.Object

A suite of utility classes for the metadata catalog server


Field Summary
static AbstractDatabase dbAdapter
           
 
Constructor Summary
MetaCatUtil()
           
 
Method Summary
 void closeConnections()
           
static java.lang.Object createObject(java.lang.String className)
          Instantiate a class using the name of the class at runtime
static void debugMessage(int flag)
          Utility method to print debugging messages
static void debugMessage(java.lang.String msg)
          Utility method to print debugging messages
static java.net.URL fileToURL(java.io.File file)
          Utility method to convert a file handle into a URL
 java.sql.Connection getConnection()
           
 java.util.Hashtable getConnectionPool()
           
static java.lang.String getOption(java.lang.String optionName)
          Utility method to get an option value from the properties file
 java.lang.String getOption(java.lang.String optionName, java.lang.String propFile)
          Utility method to get an option value from a properties file
 int getPoolSize()
           
 java.sql.Connection openDBConnection()
          Utility method to establish a JDBC database connection using connection info from the properties file
static java.sql.Connection openDBConnection(java.lang.String dbDriver, java.lang.String connection, java.lang.String user, java.lang.String password)
          Utility method to establish a JDBC database connection
static java.util.Hashtable parseQuery(java.lang.String query)
          Utility method to parse the query part of a URL into parameters.
 void returnConnection(java.sql.Connection returned)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbAdapter

public static AbstractDatabase dbAdapter
Constructor Detail

MetaCatUtil

public MetaCatUtil()
Method Detail

createObject

public static java.lang.Object createObject(java.lang.String className)
                                     throws java.lang.Exception
Instantiate a class using the name of the class at runtime
Parameters:
className - the fully qualified name of the class to instantiate

getOption

public static java.lang.String getOption(java.lang.String optionName)
Utility method to get an option value from the properties file
Parameters:
optionName - the name of the option requested

getOption

public java.lang.String getOption(java.lang.String optionName,
                                  java.lang.String propFile)
Utility method to get an option value from a properties file
Parameters:
optionName - the name of the option requested
propFile - the name of the file where to get the properties from

openDBConnection

public java.sql.Connection openDBConnection()
                                     throws java.sql.SQLException,
                                            java.lang.ClassNotFoundException
Utility method to establish a JDBC database connection using connection info from the properties file

openDBConnection

public static java.sql.Connection openDBConnection(java.lang.String dbDriver,
                                                   java.lang.String connection,
                                                   java.lang.String user,
                                                   java.lang.String password)
                                            throws java.sql.SQLException,
                                                   java.lang.ClassNotFoundException
Utility method to establish a JDBC database connection
Parameters:
dbDriver - the string representing the database driver
connection - the string representing the database connectin parameters
user - name of the user to use for database connection
password - password for the user to use for database connection

getConnectionPool

public java.util.Hashtable getConnectionPool()
                                      throws java.sql.SQLException,
                                             java.lang.ClassNotFoundException

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException,
                                         java.lang.ClassNotFoundException,
                                         java.lang.Exception

returnConnection

public void returnConnection(java.sql.Connection returned)

getPoolSize

public int getPoolSize()

closeConnections

public void closeConnections()

fileToURL

public static java.net.URL fileToURL(java.io.File file)
Utility method to convert a file handle into a URL

parseQuery

public static java.util.Hashtable parseQuery(java.lang.String query)
                                      throws java.net.MalformedURLException
Utility method to parse the query part of a URL into parameters. This method assumes the format of the query par tof the url is an ampersand separated list of name/value pairs, with equal signs separating the name from the value (e.g., name=tom&zip=99801 ). Returns a has of the name value pairs, hashed on name.

debugMessage

public static void debugMessage(int flag)
Utility method to print debugging messages
Parameters:
flag - an integer indicating the message number

debugMessage

public static void debugMessage(java.lang.String msg)
Utility method to print debugging messages
Parameters:
flag - an integer indicating the message number


Copyright © 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.