@Test public void testGetFieldDefinition() { assertEquals( "FOO DATETIME", nativeMeta.getFieldDefinition( new ValueMetaDate( "FOO" ), "", "", false, true, false ) ); assertEquals( "DATETIME", nativeMeta.getFieldDefinition( new ValueMetaTimestamp( "FOO" ), "", "", false, false, false ) ); assertEquals( "CHAR(1)", nativeMeta.getFieldDefinition( new ValueMetaBoolean( "FOO" ), "", "", false, false, false ) ); assertEquals( "INTEGER PRIMARY KEY AUTOINCREMENT", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 10, 0 ), "FOO", "", false, false, false ) ); assertEquals( "INTEGER PRIMARY KEY AUTOINCREMENT", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 8, 0 ), "", "FOO", false, false, false ) ); assertEquals( "NUMERIC", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 8, -6 ), "", "", false, false, false ) ); assertEquals( "NUMERIC", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", -13, 0 ), "", "", false, false, false ) ); assertEquals( "NUMERIC", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 19, 0 ), "", "", false, false, false ) ); assertEquals( "INTEGER", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 11, 0 ), "", "", false, false, false ) ); assertEquals( "TEXT", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 50, 0 ), "", "", false, false, false ) ); assertEquals( "BLOB", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", DatabaseMeta.CLOB_LENGTH + 1, 0 ), "", "", false, false, false ) ); assertEquals( "BLOB", nativeMeta.getFieldDefinition( new ValueMetaBinary( "FOO", 15, 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"; 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 PRIMARY KEY AUTOINCREMENT"; } else { if ( precision != 0 || length < 0 || length > 18 ) { retval += "NUMERIC"; } else { retval += "INTEGER"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval += "BLOB"; } else { retval += "TEXT"; } break; case ValueMetaInterface.TYPE_BINARY: retval += "BLOB"; break; default: retval += "UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }
SQLiteDatabaseMeta 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"; 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 PRIMARY KEY AUTOINCREMENT"; } else { if ( precision != 0 || length < 0 || length > 18 ) { retval += "NUMERIC"; } else { retval += "INTEGER"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval += "BLOB"; } else { retval += "TEXT"; } break; case ValueMetaInterface.TYPE_BINARY: retval += "BLOB"; break; default: retval += "UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; } }
SQLiteDatabaseMeta 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"; 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 PRIMARY KEY AUTOINCREMENT"; } else { if ( precision != 0 || length < 0 || length > 18 ) { retval += "NUMERIC"; } else { retval += "INTEGER"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval += "BLOB"; } else { retval += "TEXT"; } break; case ValueMetaInterface.TYPE_BINARY: retval += "BLOB"; break; default: retval += "UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  }
SQLiteDatabaseMeta 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"; 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 PRIMARY KEY AUTOINCREMENT"; } else { if ( precision != 0 || length < 0 || length > 18 ) { retval += "NUMERIC"; } else { retval += "INTEGER"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval += "BLOB"; } else { retval += "TEXT"; } 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 getNotFoundTK( boolean use_autoinc ); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override boolean isFetchSizeSupported(); @Override @SuppressWarnings( "deprecation" ) String getSchemaTableCombination( String schema_name, String table_part ); @Override boolean supportsBitmapIndex(); @Override String getTruncateTableStatement( String tableName ); @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 supportsErrorHandling(); }
SQLiteDatabaseMeta 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"; 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 PRIMARY KEY AUTOINCREMENT"; } else { if ( precision != 0 || length < 0 || length > 18 ) { retval += "NUMERIC"; } else { retval += "INTEGER"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval += "BLOB"; } else { retval += "TEXT"; } 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 getNotFoundTK( boolean use_autoinc ); @Override String getDriverClass(); @Override String getURL( String hostname, String port, String databaseName ); @Override boolean isFetchSizeSupported(); @Override @SuppressWarnings( "deprecation" ) String getSchemaTableCombination( String schema_name, String table_part ); @Override boolean supportsBitmapIndex(); @Override String getTruncateTableStatement( String tableName ); @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 supportsErrorHandling();  }