@Test public void testGetFieldDefinition() { assertEquals( "FOO DATETIME NULL", nativeMeta.getFieldDefinition( new ValueMetaDate( "FOO" ), "", "", false, true, false ) ); assertEquals( "DATETIME NULL", nativeMeta.getFieldDefinition( new ValueMetaTimestamp( "FOO" ), "", "", false, false, false ) ); assertEquals( "INTEGER NOT NULL", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 10, 0 ), "FOO", "", false, false, false ) ); assertEquals( "INTEGER NOT NULL", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 8, 0 ), "", "FOO", false, false, false ) ); assertEquals( "INTEGER", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", -8, -3 ), "", "", false, false, false ) ); assertEquals( "DOUBLE PRECISION", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", -8, -3 ), "", "", false, false, false ) ); assertEquals( "DOUBLE PRECISION", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 10, 3 ), "", "", false, false, false ) ); assertEquals( "DOUBLE PRECISION", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 10, 0 ), "", "", false, false, false ) ); assertEquals( "INTEGER", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 9, 0 ), "", "", false, false, false ) ); assertEquals( "LONG VARCHAR", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 255, 0 ), "", "", false, false, false ) ); assertEquals( "LONG VARCHAR", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", -33, 0 ), "", "", false, false, false ) ); assertEquals( "VARCHAR(15)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 15, 0 ), "", "", false, false, false ) ); assertEquals( "VARCHAR(0)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 0, 0 ), "", "", false, false, false ) ); assertEquals( " UNKNOWN", nativeMeta.getFieldDefinition( new ValueMetaInternetAddress( "FOO" ), "", "", false, false, false ) ); assertEquals( " UNKNOWN" + System.getProperty( "line.separator" ), nativeMeta.getFieldDefinition( new ValueMetaInternetAddress( "FOO" ), "", "", false, false, true ) ); }
@Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { String retval = ""; String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval += fieldname + " "; } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: case ValueMetaInterface.TYPE_DATE: retval += "DATETIME NULL"; break; case ValueMetaInterface.TYPE_BOOLEAN: retval += "CHAR(1)"; break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( fieldname.equalsIgnoreCase( tk ) || fieldname.equalsIgnoreCase( pk ) ) { retval += "INTEGER NOT NULL"; } else { if ( ( length < 0 && precision < 0 ) || precision > 0 || length > 9 ) { retval += "DOUBLE PRECISION"; } else { retval += "INTEGER"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 254 || length < 0 ) { retval += "LONG VARCHAR"; } else { retval += "VARCHAR(" + length + ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }
GuptaDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { String retval = ""; String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval += fieldname + " "; } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: case ValueMetaInterface.TYPE_DATE: retval += "DATETIME NULL"; break; case ValueMetaInterface.TYPE_BOOLEAN: retval += "CHAR(1)"; break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( fieldname.equalsIgnoreCase( tk ) || fieldname.equalsIgnoreCase( pk ) ) { retval += "INTEGER NOT NULL"; } else { if ( ( length < 0 && precision < 0 ) || precision > 0 || length > 9 ) { retval += "DOUBLE PRECISION"; } else { retval += "INTEGER"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 254 || length < 0 ) { retval += "LONG VARCHAR"; } else { retval += "VARCHAR(" + length + ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; } }
GuptaDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { String retval = ""; String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval += fieldname + " "; } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: case ValueMetaInterface.TYPE_DATE: retval += "DATETIME NULL"; break; case ValueMetaInterface.TYPE_BOOLEAN: retval += "CHAR(1)"; break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( fieldname.equalsIgnoreCase( tk ) || fieldname.equalsIgnoreCase( pk ) ) { retval += "INTEGER NOT NULL"; } else { if ( ( length < 0 && precision < 0 ) || precision > 0 || length > 9 ) { retval += "DOUBLE PRECISION"; } else { retval += "INTEGER"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 254 || length < 0 ) { retval += "LONG VARCHAR"; } else { retval += "VARCHAR(" + length + ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  }
GuptaDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { String retval = ""; String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval += fieldname + " "; } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: case ValueMetaInterface.TYPE_DATE: retval += "DATETIME NULL"; break; case ValueMetaInterface.TYPE_BOOLEAN: retval += "CHAR(1)"; break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( fieldname.equalsIgnoreCase( tk ) || fieldname.equalsIgnoreCase( pk ) ) { retval += "INTEGER NOT NULL"; } else { if ( ( length < 0 && precision < 0 ) || precision > 0 || length > 9 ) { retval += "DOUBLE PRECISION"; } else { retval += "INTEGER"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 254 || length < 0 ) { retval += "LONG VARCHAR"; } else { retval += "VARCHAR(" + length + ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  @Override int[] getAccessTypeList(); @Override int getDefaultDatabasePort(); @Override boolean supportsAutoInc(); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override boolean isFetchSizeSupported(); @Override boolean supportsBitmapIndex(); @Override boolean supportsCatalogs(); @Override boolean supportsTimeStampToDateConversion(); @Override String getAddColumnStatement( String tablename, ValueMetaInterface v, String tk, boolean use_autoinc,
    String pk, boolean semicolon ); @Override String getModifyColumnStatement( String tablename, ValueMetaInterface v, String tk, boolean use_autoinc,
    String pk, boolean semicolon ); @Override String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc,
    boolean add_fieldname, boolean add_cr ); @Override String[] getUsedLibraries(); @Override boolean isSystemTable( String tableName ); @Override boolean supportsPreparedStatementMetadataRetrieval(); }
GuptaDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { String retval = ""; String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval += fieldname + " "; } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: case ValueMetaInterface.TYPE_DATE: retval += "DATETIME NULL"; break; case ValueMetaInterface.TYPE_BOOLEAN: retval += "CHAR(1)"; break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_INTEGER: case ValueMetaInterface.TYPE_BIGNUMBER: if ( fieldname.equalsIgnoreCase( tk ) || fieldname.equalsIgnoreCase( pk ) ) { retval += "INTEGER NOT NULL"; } else { if ( ( length < 0 && precision < 0 ) || precision > 0 || length > 9 ) { retval += "DOUBLE PRECISION"; } else { retval += "INTEGER"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 254 || length < 0 ) { retval += "LONG VARCHAR"; } else { retval += "VARCHAR(" + length + ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  @Override int[] getAccessTypeList(); @Override int getDefaultDatabasePort(); @Override boolean supportsAutoInc(); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override boolean isFetchSizeSupported(); @Override boolean supportsBitmapIndex(); @Override boolean supportsCatalogs(); @Override boolean supportsTimeStampToDateConversion(); @Override String getAddColumnStatement( String tablename, ValueMetaInterface v, String tk, boolean use_autoinc,
    String pk, boolean semicolon ); @Override String getModifyColumnStatement( String tablename, ValueMetaInterface v, String tk, boolean use_autoinc,
    String pk, boolean semicolon ); @Override String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc,
    boolean add_fieldname, boolean add_cr ); @Override String[] getUsedLibraries(); @Override boolean isSystemTable( String tableName ); @Override boolean supportsPreparedStatementMetadataRetrieval();  }