@Test public void testGetFieldDefinition() { assertEquals( "FOO TIMESTAMP", nativeMeta.getFieldDefinition( new ValueMetaDate( "FOO" ), "", "", false, true, false ) ); assertEquals( "TIMESTAMP", nativeMeta.getFieldDefinition( new ValueMetaTimestamp( "FOO" ), "", "", false, false, false ) ); assertEquals( "CHAR(1)", nativeMeta.getFieldDefinition( new ValueMetaBoolean( "FOO" ), "", "", false, false, false ) ); assertEquals( "INTEGER NOT NULL PRIMARY KEY", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 8, 0 ), "", "FOO", true, false, false ) ); assertEquals( "INTEGER NOT NULL PRIMARY KEY", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 10, 0 ), "FOO", "", false, false, false ) ); assertEquals( "INTEGER NOT NULL PRIMARY KEY", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 8, 0 ), "", "FOO", false, false, false ) ); assertEquals( "NUMERIC(10)", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 10, 0 ), "", "", false, false, false ) ); assertEquals( "NUMERIC(18)", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 18, 0 ), "", "", false, false, false ) ); assertEquals( "INTEGER", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 9, 0 ), "", "", false, false, false ) ); assertEquals( "FLOAT", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 19, 0 ), "", "", false, false, false ) ); assertEquals( "NUMERIC(10, 5)", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 10, 5 ), "", "", false, false, false ) ); assertEquals( "FLOAT", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 19, 5 ), "", "", false, false, false ) ); assertEquals( "NUMERIC(-7)", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", -7, -2 ), "", "", false, false, false ) ); assertEquals( "NUMERIC(-7, 2)", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", -7, 2 ), "", "", false, false, false ) ); assertEquals( "VARCHAR(15)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 15, 0 ), "", "", false, false, false ) ); assertEquals( "VARCHAR(4028)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", nativeMeta.getMaxVARCHARLength(), 0 ), "", "", false, false, false ) ); assertEquals( "CHAR(4029)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 4029, 0 ), "", "", false, false, false ) ); assertEquals( "CHAR(4036)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 4036, 0 ), "", "", false, false, false ) ); assertEquals( "CLOB", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 4037, 0 ), "", "", false, false, false ) ); assertEquals( "BLOB", nativeMeta.getFieldDefinition( new ValueMetaBinary( "FOO", 4037, 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 += "TIMESTAMP"; 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 PRIMARY KEY"; } else { if ( precision == 0 ) { if ( length > 9 ) { if ( length <= 18 ) { retval += "NUMERIC(" + length + ")"; } else { retval += "FLOAT"; } } else { retval += "INTEGER"; } } else { if ( length <= 18 ) { retval += "NUMERIC(" + length; if ( precision > 0 ) { retval += ", " + precision; } retval += ")"; } else { retval += "FLOAT"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { if ( length <= 4028 ) { retval += "VARCHAR(" + length + ")"; } else if ( length <= 4036 ) { retval += "CHAR(" + length + ")"; } else { retval += "CLOB"; } } else { retval += "CHAR(1)"; } break; case ValueMetaInterface.TYPE_BINARY: retval += "BLOB"; break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }
NeoviewDatabaseMeta 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 += "TIMESTAMP"; 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 PRIMARY KEY"; } else { if ( precision == 0 ) { if ( length > 9 ) { if ( length <= 18 ) { retval += "NUMERIC(" + length + ")"; } else { retval += "FLOAT"; } } else { retval += "INTEGER"; } } else { if ( length <= 18 ) { retval += "NUMERIC(" + length; if ( precision > 0 ) { retval += ", " + precision; } retval += ")"; } else { retval += "FLOAT"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { if ( length <= 4028 ) { retval += "VARCHAR(" + length + ")"; } else if ( length <= 4036 ) { retval += "CHAR(" + length + ")"; } else { retval += "CLOB"; } } else { retval += "CHAR(1)"; } break; case ValueMetaInterface.TYPE_BINARY: retval += "BLOB"; break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; } }
NeoviewDatabaseMeta 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 += "TIMESTAMP"; 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 PRIMARY KEY"; } else { if ( precision == 0 ) { if ( length > 9 ) { if ( length <= 18 ) { retval += "NUMERIC(" + length + ")"; } else { retval += "FLOAT"; } } else { retval += "INTEGER"; } } else { if ( length <= 18 ) { retval += "NUMERIC(" + length; if ( precision > 0 ) { retval += ", " + precision; } retval += ")"; } else { retval += "FLOAT"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { if ( length <= 4028 ) { retval += "VARCHAR(" + length + ")"; } else if ( length <= 4036 ) { retval += "CHAR(" + length + ")"; } else { retval += "CLOB"; } } else { retval += "CHAR(1)"; } break; case ValueMetaInterface.TYPE_BINARY: retval += "BLOB"; break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  }
NeoviewDatabaseMeta 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 += "TIMESTAMP"; 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 PRIMARY KEY"; } else { if ( precision == 0 ) { if ( length > 9 ) { if ( length <= 18 ) { retval += "NUMERIC(" + length + ")"; } else { retval += "FLOAT"; } } else { retval += "INTEGER"; } } else { if ( length <= 18 ) { retval += "NUMERIC(" + length; if ( precision > 0 ) { retval += ", " + precision; } retval += ")"; } else { retval += "FLOAT"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { if ( length <= 4028 ) { retval += "VARCHAR(" + length + ")"; } else if ( length <= 4036 ) { retval += "CHAR(" + length + ")"; } else { retval += "CLOB"; } } else { retval += "CHAR(1)"; } break; case ValueMetaInterface.TYPE_BINARY: retval += "BLOB"; break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  @Override int[] getAccessTypeList(); @Override int getDefaultDatabasePort(); @Override boolean supportsAutoInc(); @Override String getLimitClause( int nrRows ); @Override String getSQLQueryFields( String tableName ); @Override String getSQLTableExists( String tablename ); @Override String getSQLColumnExists( String columnname, String tablename ); String getSQLQueryColumnFields( String columnname, String tableName ); @Override boolean needsToLockAllTables(); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override boolean supportsOptionsInURL(); @Override boolean useSchemaNameForTableList(); @Override boolean supportsSynonyms(); @Override String getAddColumnStatement( String tablename, ValueMetaInterface v, String tk, boolean use_autoinc,
    String pk, boolean semicolon ); @Override String getDropColumnStatement( 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[] getReservedWords(); @Override String getSQLLockTables( String[] tableNames ); @Override String getSQLUnlockTables( String[] tableNames ); @Override String getExtraOptionsHelpText(); @Override String[] getUsedLibraries(); @Override boolean supportsBitmapIndex(); @Override int getMaxVARCHARLength(); @Override String getTruncateTableStatement( String tableName ); @Override Object getValueFromResultSet( ResultSet rs, ValueMetaInterface val, int i ); }
NeoviewDatabaseMeta 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 += "TIMESTAMP"; 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 PRIMARY KEY"; } else { if ( precision == 0 ) { if ( length > 9 ) { if ( length <= 18 ) { retval += "NUMERIC(" + length + ")"; } else { retval += "FLOAT"; } } else { retval += "INTEGER"; } } else { if ( length <= 18 ) { retval += "NUMERIC(" + length; if ( precision > 0 ) { retval += ", " + precision; } retval += ")"; } else { retval += "FLOAT"; } } } break; case ValueMetaInterface.TYPE_STRING: if ( length > 0 ) { if ( length <= 4028 ) { retval += "VARCHAR(" + length + ")"; } else if ( length <= 4036 ) { retval += "CHAR(" + length + ")"; } else { retval += "CLOB"; } } else { retval += "CHAR(1)"; } break; case ValueMetaInterface.TYPE_BINARY: retval += "BLOB"; break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  @Override int[] getAccessTypeList(); @Override int getDefaultDatabasePort(); @Override boolean supportsAutoInc(); @Override String getLimitClause( int nrRows ); @Override String getSQLQueryFields( String tableName ); @Override String getSQLTableExists( String tablename ); @Override String getSQLColumnExists( String columnname, String tablename ); String getSQLQueryColumnFields( String columnname, String tableName ); @Override boolean needsToLockAllTables(); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override boolean supportsOptionsInURL(); @Override boolean useSchemaNameForTableList(); @Override boolean supportsSynonyms(); @Override String getAddColumnStatement( String tablename, ValueMetaInterface v, String tk, boolean use_autoinc,
    String pk, boolean semicolon ); @Override String getDropColumnStatement( 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[] getReservedWords(); @Override String getSQLLockTables( String[] tableNames ); @Override String getSQLUnlockTables( String[] tableNames ); @Override String getExtraOptionsHelpText(); @Override String[] getUsedLibraries(); @Override boolean supportsBitmapIndex(); @Override int getMaxVARCHARLength(); @Override String getTruncateTableStatement( String tableName ); @Override Object getValueFromResultSet( ResultSet rs, ValueMetaInterface val, int i );  }