com.hardcode.gdbms.driver.foodriver
Class FooDriver

java.lang.Object
  extended by com.hardcode.gdbms.driver.foodriver.FooDriver
All Implemented Interfaces:
com.hardcode.driverManager.Driver, AlphanumericDBDriver, DBDriver, GDBMSDriver, ReadAccess, TypeConverter, ValueWriter

public class FooDriver
extends java.lang.Object
implements AlphanumericDBDriver


Field Summary
 
Fields inherited from interface com.hardcode.gdbms.engine.values.ValueWriter
internalValueWriter
 
Constructor Summary
FooDriver()
           
 
Method Summary
 java.lang.String check(Field field, Value value)
          Checks if a given value is suitable for the specified field
 void close()
          Free any resource reserved in the open method
 void createSource(DBSource source, DriverMetadata driverMetadata)
          Creates a new table.
 void execute(java.sql.Connection con, java.lang.String sql)
          Executes an instruction against the server
 java.lang.String[] getAvailableTypes()
          Gets a string identificator for each type a field can have
 java.lang.String[] getAvailableTypes(java.lang.String host, int port, java.lang.String dbName, java.lang.String user, java.lang.String password)
           
 java.sql.Connection getConnection(java.lang.String host, int port, java.lang.String dbName, java.lang.String user, java.lang.String password)
          Método mediante el cual el driver surte de conexiones a la base de datos.
 DriverMetadata getDriverMetadata()
          Gets the driver specific metadata
 java.util.HashMap getDriverProperties()
           
 int getFieldCount()
           
 java.lang.String getFieldName(int fieldId)
           
 int getFieldType(int i)
           
 Value getFieldValue(long rowIndex, int fieldId)
          Obtiene el valor que se encuentra en la fila y columna indicada
 java.lang.String getInternalTableName(java.lang.String tablename)
           
 java.sql.ResultSetMetaData getMetadata()
           
 java.lang.String getName()
           
 java.lang.String getNullStatementString()
          Gets the string of the binary param as it would appear in a SQL statement
 java.lang.String[] getParameters(java.lang.String driverType)
          Gets the parameters used in creating the type
 java.lang.String[] getParameters(java.lang.String host, int port, java.lang.String dbName, java.lang.String user, java.lang.String password, java.lang.String driverType)
           
 long getRowCount()
          Obtiene el número de registros del DataSource
 java.lang.String getStatementString(boolean b)
          Gets the string of the binary param as it would appear in a SQL statement
 java.lang.String getStatementString(byte[] binary)
          Gets the string of the binary param as it would appear in a SQL statement
 java.lang.String getStatementString(java.sql.Date d)
          Gets the string of the param as it would appear in a SQL statement
 java.lang.String getStatementString(double d, int sqlType)
          Gets the string of the d param as it would appear in a SQL statement
 java.lang.String getStatementString(Geometry g)
          Gets the string representation of the geometry as it would appear in a SQL statement
 java.lang.String getStatementString(int i, int sqlType)
          Gets the string of the i param as it would appear in a SQL statement
 java.lang.String getStatementString(long i)
          Gets the string of the i param as it would appear in a SQL statement
 java.lang.String getStatementString(java.lang.String str, int sqlType)
          Gets the string of the str param as it would appear in a SQL statement
 java.lang.String getStatementString(java.sql.Time t)
          Gets the string of the param as it would appear in a SQL statement
 java.lang.String getStatementString(java.sql.Timestamp ts)
          Gets the string of the param as it would appear in a SQL statement
 int getType(java.lang.String driverType)
          Gets the suitable GDBMS type for the given driver specific type
 java.lang.String getTypeInAddColumnStatement(java.lang.String driverType, java.util.HashMap<java.lang.String,java.lang.String> params)
          Gets a statement to create the specified field on the given table
 boolean isReadOnly(int i)
          Returns true if the specified field is read only
 boolean isValidParameter(java.lang.String driverType, java.lang.String paramName, java.lang.String paramValue)
          Returns if the given value (paramValue) for the parameter called paramName of the given driver specific type is valid or not
 void open(java.sql.Connection con, java.lang.String tableName, java.lang.String orderFieldName)
          Connects to the data source and reads the specified table in the specified order
 void setDataSourceFactory(DataSourceFactory dsf)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FooDriver

public FooDriver()
Method Detail

getConnection

public java.sql.Connection getConnection(java.lang.String host,
                                         int port,
                                         java.lang.String dbName,
                                         java.lang.String user,
                                         java.lang.String password)
                                  throws java.sql.SQLException
Description copied from interface: DBDriver
Método mediante el cual el driver surte de conexiones a la base de datos.

Specified by:
getConnection in interface DBDriver
Parameters:
host - nombre o dirección IP del host al que se quiere conectar
port - puerto al que se quiere conectar. -1 si es el puerto por defecto
dbName - Nombre de la base de datos a la que se quiere conectar
user - Usuario de la conexión
password - Password del usuario
Returns:
Connection
Throws:
java.sql.SQLException - Si se produce algún error

open

public void open(java.sql.Connection con,
                 java.lang.String tableName,
                 java.lang.String orderFieldName)
          throws DriverException
Description copied from interface: AlphanumericDBDriver
Connects to the data source and reads the specified table in the specified order

Specified by:
open in interface AlphanumericDBDriver
Parameters:
con - Connection to use
tableName - Name of the table where the data is in
orderFieldName - Name of the order field. Can be null
Throws:
DriverException

execute

public void execute(java.sql.Connection con,
                    java.lang.String sql)
             throws java.sql.SQLException
Description copied from interface: DBDriver
Executes an instruction against the server

Specified by:
execute in interface DBDriver
Parameters:
con - Connection used to execute the instruction
sql - Instruction to execute
Throws:
java.sql.SQLException - If the execution fails

close

public void close()
           throws DriverException
Description copied from interface: DBDriver
Free any resource reserved in the open method

Specified by:
close in interface DBDriver
Throws:
DriverException

getInternalTableName

public java.lang.String getInternalTableName(java.lang.String tablename)

getFieldValue

public Value getFieldValue(long rowIndex,
                           int fieldId)
                    throws DriverException
Description copied from interface: ReadAccess
Obtiene el valor que se encuentra en la fila y columna indicada

Specified by:
getFieldValue in interface ReadAccess
Parameters:
rowIndex - fila
fieldId - columna
Returns:
subclase de Value con el valor del origen de datos. Never null (use ValueFactory.createNullValue() instead)
Throws:
DriverException - Si se produce un error accediendo al DataSource

getFieldCount

public int getFieldCount()
                  throws DriverException
Throws:
DriverException

getFieldName

public java.lang.String getFieldName(int fieldId)
                              throws DriverException
Throws:
DriverException

getRowCount

public long getRowCount()
                 throws DriverException
Description copied from interface: ReadAccess
Obtiene el número de registros del DataSource

Specified by:
getRowCount in interface ReadAccess
Returns:
Throws:
DriverException - Si se produce algún error accediendo al DataSource

getFieldType

public int getFieldType(int i)
                 throws DriverException
Throws:
DriverException

getName

public java.lang.String getName()
Specified by:
getName in interface com.hardcode.driverManager.Driver

getStatementString

public java.lang.String getStatementString(long i)
Description copied from interface: ValueWriter
Gets the string of the i param as it would appear in a SQL statement

Specified by:
getStatementString in interface ValueWriter
Parameters:
i - long to format
Returns:
String

getStatementString

public java.lang.String getStatementString(int i,
                                           int sqlType)
Description copied from interface: ValueWriter
Gets the string of the i param as it would appear in a SQL statement

Specified by:
getStatementString in interface ValueWriter
Parameters:
i - integer to format
sqlType - SQL type of the parameter. Any of the following java.sql.Types constants: INTEGER, SMALLINT, TINYINT
Returns:
String

getStatementString

public java.lang.String getStatementString(double d,
                                           int sqlType)
Description copied from interface: ValueWriter
Gets the string of the d param as it would appear in a SQL statement

Specified by:
getStatementString in interface ValueWriter
Parameters:
d - double to format
sqlType - SQL type of the parameter. Any of the following java.sql.Types constants: DOUBLE, FLOAT, REAL, NUMERIC, DECIMAL
Returns:
String

getStatementString

public java.lang.String getStatementString(java.lang.String str,
                                           int sqlType)
Description copied from interface: ValueWriter
Gets the string of the str param as it would appear in a SQL statement

Specified by:
getStatementString in interface ValueWriter
Parameters:
str - string to format
sqlType - SQL type of the parameter. Any of the following java.sql.Types constants: CHAR, VARCHAR, LONGVARCHAR
Returns:
String

getStatementString

public java.lang.String getStatementString(java.sql.Date d)
Description copied from interface: ValueWriter
Gets the string of the param as it would appear in a SQL statement

Specified by:
getStatementString in interface ValueWriter
Parameters:
d - Date to format
Returns:
String

getStatementString

public java.lang.String getStatementString(java.sql.Time t)
Description copied from interface: ValueWriter
Gets the string of the param as it would appear in a SQL statement

Specified by:
getStatementString in interface ValueWriter
Parameters:
t - Time to format
Returns:
String

getStatementString

public java.lang.String getStatementString(java.sql.Timestamp ts)
Description copied from interface: ValueWriter
Gets the string of the param as it would appear in a SQL statement

Specified by:
getStatementString in interface ValueWriter
Parameters:
ts - timestamp to format
Returns:
String

getStatementString

public java.lang.String getStatementString(byte[] binary)
Description copied from interface: ValueWriter
Gets the string of the binary param as it would appear in a SQL statement

Specified by:
getStatementString in interface ValueWriter
Parameters:
binary - byte array to format
Returns:
String

getStatementString

public java.lang.String getStatementString(boolean b)
Description copied from interface: ValueWriter
Gets the string of the binary param as it would appear in a SQL statement

Specified by:
getStatementString in interface ValueWriter
Parameters:
b - byte array to format
Returns:
String

getNullStatementString

public java.lang.String getNullStatementString()
Description copied from interface: ValueWriter
Gets the string of the binary param as it would appear in a SQL statement

Specified by:
getNullStatementString in interface ValueWriter
Returns:
String

getDriverProperties

public java.util.HashMap getDriverProperties()

setDataSourceFactory

public void setDataSourceFactory(DataSourceFactory dsf)
Specified by:
setDataSourceFactory in interface GDBMSDriver

getMetadata

public java.sql.ResultSetMetaData getMetadata()
                                       throws java.sql.SQLException
Throws:
java.sql.SQLException

getStatementString

public java.lang.String getStatementString(Geometry g)
Description copied from interface: ValueWriter
Gets the string representation of the geometry as it would appear in a SQL statement

Specified by:
getStatementString in interface ValueWriter
Parameters:
g - Geometry
Returns:
String

getDriverMetadata

public DriverMetadata getDriverMetadata()
                                 throws DriverException
Description copied from interface: GDBMSDriver
Gets the driver specific metadata

Specified by:
getDriverMetadata in interface GDBMSDriver
Returns:
Throws:
DriverException

getType

public int getType(java.lang.String driverType)
Description copied from interface: TypeConverter
Gets the suitable GDBMS type for the given driver specific type

Specified by:
getType in interface TypeConverter
Returns:

getTypeInAddColumnStatement

public java.lang.String getTypeInAddColumnStatement(java.lang.String driverType,
                                                    java.util.HashMap<java.lang.String,java.lang.String> params)
Description copied from interface: DBDriver
Gets a statement to create the specified field on the given table

Specified by:
getTypeInAddColumnStatement in interface DBDriver
Returns:

getAvailableTypes

public java.lang.String[] getAvailableTypes()
                                     throws DriverException
Description copied from interface: GDBMSDriver
Gets a string identificator for each type a field can have

Specified by:
getAvailableTypes in interface GDBMSDriver
Returns:
Throws:
DriverException

getParameters

public java.lang.String[] getParameters(java.lang.String driverType)
                                 throws DriverException
Description copied from interface: GDBMSDriver
Gets the parameters used in creating the type

Specified by:
getParameters in interface GDBMSDriver
Returns:
Throws:
DriverException

createSource

public void createSource(DBSource source,
                         DriverMetadata driverMetadata)
                  throws DriverException
Description copied from interface: AlphanumericDBDriver
Creates a new table. The source argument provides information about the name of the table to be created and the host, port and database where the table has to be created

Specified by:
createSource in interface AlphanumericDBDriver
Throws:
DriverException - TODO

getAvailableTypes

public java.lang.String[] getAvailableTypes(java.lang.String host,
                                            int port,
                                            java.lang.String dbName,
                                            java.lang.String user,
                                            java.lang.String password)
                                     throws java.sql.SQLException
Throws:
java.sql.SQLException

getParameters

public java.lang.String[] getParameters(java.lang.String host,
                                        int port,
                                        java.lang.String dbName,
                                        java.lang.String user,
                                        java.lang.String password,
                                        java.lang.String driverType)
                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

check

public java.lang.String check(Field field,
                              Value value)
                       throws DriverException
Description copied from interface: GDBMSDriver
Checks if a given value is suitable for the specified field

Specified by:
check in interface GDBMSDriver
Returns:
Throws:
DriverException

isReadOnly

public boolean isReadOnly(int i)
Description copied from interface: GDBMSDriver
Returns true if the specified field is read only

Specified by:
isReadOnly in interface GDBMSDriver
Returns:

isValidParameter

public boolean isValidParameter(java.lang.String driverType,
                                java.lang.String paramName,
                                java.lang.String paramValue)
Description copied from interface: GDBMSDriver
Returns if the given value (paramValue) for the parameter called paramName of the given driver specific type is valid or not

Specified by:
isValidParameter in interface GDBMSDriver
paramValue - null if the parameter is not specified
Returns:


Copyright © 2005-2006 . All Rights Reserved.