Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.impl.tools.ij
Class util  view util download util.java

java.lang.Object
  extended byorg.apache.derby.impl.tools.ij.util
All Implemented Interfaces:
java.security.PrivilegedAction

public class util
extends java.lang.Object
implements java.security.PrivilegedAction

Methods used to control setup for apps as well as display some internal ij structures.


Field Summary
private static java.lang.Class[] DS_GET_CONN_TYPES
           
private static boolean HAVE_BIG_DECIMAL
           
private static java.lang.Class[] INT_P
           
private  java.lang.String key
           
private static java.lang.String[][] protocolDrivers
           
private static java.lang.Class[] STRING_P
           
 
Constructor Summary
private util()
           
 
Method Summary
static void DisplayMulti(org.apache.derby.iapi.tools.i18n.LocalizedOutput out, java.sql.PreparedStatement ps, java.sql.ResultSet rs, java.sql.Connection conn)
          Display a statement that takes parameters by stuffing it with rows from the result set and displaying each result each time through.
static void DisplayVector(org.apache.derby.iapi.tools.i18n.LocalizedOutput out, java.util.Vector v)
          Display a vector of strings to the out stream.
static java.lang.String getArg(java.lang.String param, java.lang.String[] args)
          Find the argument that follows the specified parameter.
static java.util.Properties getConnAttributeArg(java.lang.String[] args)
          ij is started with "-ca[r] file OtherArgs"; the file contains connection attibute properties to pass to getConnection
static java.lang.String getFileArg(java.lang.String[] args)
          Return the name of the ij command file or null if none is specified.
static java.lang.String getInputResourceNameArg(java.lang.String[] args)
          Return the name of a resource containing input commands or null iff none has been specified.
static boolean getPropertyArg(java.lang.String[] args)
          ij is started with "-p[r] file OtherArgs"; the file contains properties to control the driver and database used to run ij, and can provide additional system properties.
static java.io.InputStream getResourceAsStream(java.lang.String resourceName)
          Convenience routine to get a resource as a BufferedInputStream.
static java.lang.String getSystemProperty(java.lang.String propertyName)
           
static boolean invalidArgs(java.lang.String[] args, boolean gotProp, java.lang.String file, java.lang.String inputResourceName)
          Verify the ij line arguments command arguments.
private static boolean isJCCFramework()
          Used to determine if this is a JCC testing framework So that retrieveMessages can be sent.
static void loadDriver(java.lang.String driverClass)
          Load a driver given a class name.
static void loadDriverIfKnown(java.lang.String jdbcProtocol)
          Find the appropriate driver and load it, given a JDBC URL.
private static void loadWithTrimmedValues(java.io.InputStream iStr, java.util.Properties prop)
          Read a set of properties from the received input stream, strip off any excess white space that exists in those property values, and then add those newly-read properties to the received Properties object; not explicitly removing the whitespace here can lead to problems.
(package private) static java.lang.String qualifyResourceName(java.lang.String resourceName, boolean absolute)
          Convenience routine to qualify a resource name with "ij.defaultPackageName" if it is not qualified (does not begin with a "/").
 java.lang.Object run()
          This method performs an operation that requires higher privileges to perform.
static void setupDataSource(java.lang.Object ds)
           
static java.sql.Connection startJBMS()
          Utility interface that defaults driver and database to null.
static java.sql.Connection startJBMS(java.lang.String defaultDriver, java.lang.String defaultURL)
          Utility interface that defaults connInfo to null
static java.sql.Connection startJBMS(java.lang.String defaultDriver, java.lang.String defaultURL, java.util.Properties connInfo)
          This will look for the System properties "ij.driver" and "ij.database" and return a java.sql.Connection if it successfully connects.
static java.util.Properties updateConnInfo(java.lang.String user, java.lang.String password, java.util.Properties connInfo)
           
(package private) static void Usage(org.apache.derby.iapi.tools.i18n.LocalizedOutput out)
          print a usage message for invocations of main().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HAVE_BIG_DECIMAL

private static boolean HAVE_BIG_DECIMAL

DS_GET_CONN_TYPES

private static final java.lang.Class[] DS_GET_CONN_TYPES

STRING_P

private static final java.lang.Class[] STRING_P

INT_P

private static final java.lang.Class[] INT_P

key

private java.lang.String key

protocolDrivers

private static final java.lang.String[][] protocolDrivers
Constructor Detail

util

private util()
Method Detail

getArg

public static java.lang.String getArg(java.lang.String param,
                                      java.lang.String[] args)
Find the argument that follows the specified parameter.


getPropertyArg

public static boolean getPropertyArg(java.lang.String[] args)
                              throws java.io.IOException
ij is started with "-p[r] file OtherArgs"; the file contains properties to control the driver and database used to run ij, and can provide additional system properties.

getPropertyArg will look at the args and take out a "-p " pair, reading the file into the system properties.

If there was a -p without a following , no action is taken.


getConnAttributeArg

public static java.util.Properties getConnAttributeArg(java.lang.String[] args)
                                                throws java.io.IOException
ij is started with "-ca[r] file OtherArgs"; the file contains connection attibute properties to pass to getConnection

getConnAttributeArg will look at the args and take out a "-ca[r] " pair and returning the Properties


qualifyResourceName

static java.lang.String qualifyResourceName(java.lang.String resourceName,
                                            boolean absolute)
Convenience routine to qualify a resource name with "ij.defaultPackageName" if it is not qualified (does not begin with a "/").


getResourceAsStream

public static java.io.InputStream getResourceAsStream(java.lang.String resourceName)
Convenience routine to get a resource as a BufferedInputStream. If the resourceName is not absolute (does not begin with a "/") this qualifies the name with the "ij.defaultResourcePackage" name.


getFileArg

public static java.lang.String getFileArg(java.lang.String[] args)
                                   throws java.io.IOException
Return the name of the ij command file or null if none is specified. The command file may be proceeded with -f flag on the command line. Alternatively, the command file may be specified without a -f flag. In this case we assume the first unknown argument is the command file.

This should only be called after calling invalidArgs.

If there is no such argument, a null is returned.


getInputResourceNameArg

public static java.lang.String getInputResourceNameArg(java.lang.String[] args)
Return the name of a resource containing input commands or null iff none has been specified.


invalidArgs

public static boolean invalidArgs(java.lang.String[] args,
                                  boolean gotProp,
                                  java.lang.String file,
                                  java.lang.String inputResourceName)
Verify the ij line arguments command arguments.


Usage

static void Usage(org.apache.derby.iapi.tools.i18n.LocalizedOutput out)
print a usage message for invocations of main().


setupDataSource

public static void setupDataSource(java.lang.Object ds)
                            throws java.lang.Exception

startJBMS

public static java.sql.Connection startJBMS(java.lang.String defaultDriver,
                                            java.lang.String defaultURL,
                                            java.util.Properties connInfo)
                                     throws java.sql.SQLException,
                                            java.lang.ClassNotFoundException,
                                            java.lang.InstantiationException,
                                            java.lang.IllegalAccessException
This will look for the System properties "ij.driver" and "ij.database" and return a java.sql.Connection if it successfully connects. The deprecated driver and database properties are examined first.

If no connection was possible, it will return a null.

Failure to load the driver class is quietly ignored.


updateConnInfo

public static java.util.Properties updateConnInfo(java.lang.String user,
                                                  java.lang.String password,
                                                  java.util.Properties connInfo)

startJBMS

public static java.sql.Connection startJBMS()
                                     throws java.sql.SQLException,
                                            java.lang.ClassNotFoundException,
                                            java.lang.InstantiationException,
                                            java.lang.IllegalAccessException
Utility interface that defaults driver and database to null.


startJBMS

public static java.sql.Connection startJBMS(java.lang.String defaultDriver,
                                            java.lang.String defaultURL)
                                     throws java.sql.SQLException,
                                            java.lang.ClassNotFoundException,
                                            java.lang.InstantiationException,
                                            java.lang.IllegalAccessException
Utility interface that defaults connInfo to null


DisplayVector

public static void DisplayVector(org.apache.derby.iapi.tools.i18n.LocalizedOutput out,
                                 java.util.Vector v)
Display a vector of strings to the out stream.


DisplayMulti

public static void DisplayMulti(org.apache.derby.iapi.tools.i18n.LocalizedOutput out,
                                java.sql.PreparedStatement ps,
                                java.sql.ResultSet rs,
                                java.sql.Connection conn)
                         throws java.sql.SQLException,
                                ijException
Display a statement that takes parameters by stuffing it with rows from the result set and displaying each result each time through. Deal with autocommit behavior along the way.


getSystemProperty

public static final java.lang.String getSystemProperty(java.lang.String propertyName)

run

public final java.lang.Object run()
Description copied from interface: java.security.PrivilegedAction
This method performs an operation that requires higher privileges to perform. It is called when a section of code invokes AccessController.doPrivileged().

Specified by:
run in interface java.security.PrivilegedAction

loadWithTrimmedValues

private static void loadWithTrimmedValues(java.io.InputStream iStr,
                                          java.util.Properties prop)
                                   throws java.io.IOException
Read a set of properties from the received input stream, strip off any excess white space that exists in those property values, and then add those newly-read properties to the received Properties object; not explicitly removing the whitespace here can lead to problems. This method exists because of the manner in which the jvm reads properties from file--extra spaces are ignored after a _key_, but if they exist at the _end_ of a property decl line (i.e. as part of a _value_), they are preserved, as outlined in the Java API: "Any whitespace after the key is skipped; if the first non- whitespace character after the key is = or :, then it is ignored and any whitespace characters after it are also skipped. All remaining characters on the line become part of the associated element string."


loadDriverIfKnown

public static void loadDriverIfKnown(java.lang.String jdbcProtocol)
                              throws java.lang.ClassNotFoundException,
                                     java.lang.InstantiationException,
                                     java.lang.IllegalAccessException
Find the appropriate driver and load it, given a JDBC URL. No action if no driver known for a given URL.


loadDriver

public static void loadDriver(java.lang.String driverClass)
                       throws java.lang.ClassNotFoundException,
                              java.lang.InstantiationException,
                              java.lang.IllegalAccessException
Load a driver given a class name.


isJCCFramework

private static boolean isJCCFramework()
Used to determine if this is a JCC testing framework So that retrieveMessages can be sent. The plan is to have ij will retrieve messages by default and not look at the testing frameworks. So, ulitmately this function will look at the driver rather than the framework.