cds.sql
Class SQLRepository

java.lang.Object
  extended bycds.sql.SQLRepository

public class SQLRepository
extends java.lang.Object

Objects of this class manage parameterized lists of SQL commands, which are easily available for building complete queries.
Such a repository is kept in a Parameters file, with the following conventions :

Version:
1.0 April 2003
2.0 July 2003 (SJ) : traitement des attributs des parametres (getParamDetail) (+ chgt nom getParameterDescription en getParameterAttributes) + ajout methode getTablesName
Author:
Marc Wenger/CDS, Sylvaine Jaehn

Field Summary
static char PARAM_CHAR
           
private  Parameters sqlList
           
 
Constructor Summary
SQLRepository(java.lang.String pname)
          Constructor.
 
Method Summary
 java.lang.String generate(java.lang.String commandName, java.util.Hashtable params)
          Generates an SQL command.
 java.lang.String generate(java.lang.String commandName, java.lang.String[] params)
          Generates an SQL command.
 java.lang.String getDescription(java.lang.String commandName)
          Returns the description of a command
 java.lang.String getParameterAttributes(java.lang.String commandName, java.lang.String parameter)
          Returns the attributes of a particular parameter
 java.lang.String getParameterDetail(java.lang.String commandName, java.lang.String parameter, java.lang.String attribute)
          Valeur d'un attribut du parametre
 java.lang.String[] getParameters(java.lang.String commandName)
          Returns the list of the parameters
 java.util.ArrayList getTablesName(java.lang.String commandName, java.lang.String paramName)
          Liste des tables figurant dans l'attribut type d'un parametre liste de champs
 java.util.Iterator interator()
          Get an iterator on the commands
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAM_CHAR

public static final char PARAM_CHAR
See Also:
Constant Field Values

sqlList

private Parameters sqlList
Constructor Detail

SQLRepository

public SQLRepository(java.lang.String pname)
Constructor.

Parameters:
pname - file name of a Parameters file
Method Detail

generate

public java.lang.String generate(java.lang.String commandName,
                                 java.lang.String[] params)
Generates an SQL command.

Parameters:
commandName - name of the sql command in the repository
params - array of the parameters. Each parameter occupies two consecutive strings containing the parameter name and its value. The array size must be an even number
Returns:
the sql command

generate

public java.lang.String generate(java.lang.String commandName,
                                 java.util.Hashtable params)
Generates an SQL command.

Parameters:
commandName - name of the sql command in the repository
params - Hashtable containing the parameters
Returns:
the sql command

getDescription

public java.lang.String getDescription(java.lang.String commandName)
Returns the description of a command

Parameters:
commandName - name of the sql command in the repository
Returns:
the description text

getParameters

public java.lang.String[] getParameters(java.lang.String commandName)
Returns the list of the parameters

Parameters:
commandName - name of the sql command in the repository
Returns:
an array of all the parameters

getParameterAttributes

public java.lang.String getParameterAttributes(java.lang.String commandName,
                                               java.lang.String parameter)
Returns the attributes of a particular parameter

Parameters:
commandName - name of the sql template in the repository
parameter - a parameter existing in the sql template
Returns:
the attributes string of this parameter

interator

public java.util.Iterator interator()
Get an iterator on the commands

Returns:
an iterator on the command names

getParameterDetail

public java.lang.String getParameterDetail(java.lang.String commandName,
                                           java.lang.String parameter,
                                           java.lang.String attribute)
Valeur d'un attribut du parametre

Parameters:
commandName - nom de la commande
parameter - nom du parametre
attribute - attribut du parametre
Returns:
valeur de l'attribut du parametre

getTablesName

public java.util.ArrayList getTablesName(java.lang.String commandName,
                                         java.lang.String paramName)
Liste des tables figurant dans l'attribut type d'un parametre liste de champs

Parameters:
commandName - nom de la commande
paramName - nom du parametre
Returns:
liste contenant les tables figurant dans l'attribut type d'une parametre liste de champs

main

public static void main(java.lang.String[] args)