@Test public void testGetFieldDefinition() { assertEquals( "FOO DATE", nativeMeta.getFieldDefinition( new ValueMetaDate( "FOO" ), "", "", false, true, false ) ); assertEquals( "DATE", nativeMeta.getFieldDefinition( new ValueMetaDate( "FOO" ), "", "", false, false, false ) ); assertEquals( "CHAR(1)", nativeMeta.getFieldDefinition( new ValueMetaBoolean( "FOO" ), "", "", false, false, false ) ); assertEquals( "INTEGER", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 10, 0 ), "FOO", "", false, false, false ) ); assertEquals( "INTEGER", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 10, 0 ), "", "FOO", false, false, false ) ); assertEquals( "DECIMAL(5, 5)", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 5, 5 ), "", "", false, false, false ) ); assertEquals( "DECIMAL(19, 0)", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 19, 0 ), "", "", false, false, false ) ); assertEquals( "INTEGER", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 18, 0 ), "", "", false, false, false ) ); assertEquals( "DOUBLE PRECISION", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", -7, -3 ), "", "", false, false, false ) ); assertEquals( "VARCHAR(15)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 15, 0 ), "", "", false, false, false ) ); assertEquals( "VARCHAR(65535)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 65537, 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_DATE: retval += "DATE"; 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"; } else { if ( length > 0 ) { if ( precision > 0 || length > 18 ) { retval += "DECIMAL(" + length + ", " + precision + ")"; } else { retval += "INTEGER"; } } else { retval += "DOUBLE PRECISION"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= MAX_VARCHAR_LENGTH || length <= 0 ) { retval += "VARCHAR(" + MAX_VARCHAR_LENGTH + ")"; } else { retval += "VARCHAR(" + length + ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }
UniVerseDatabaseMeta 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_DATE: retval += "DATE"; 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"; } else { if ( length > 0 ) { if ( precision > 0 || length > 18 ) { retval += "DECIMAL(" + length + ", " + precision + ")"; } else { retval += "INTEGER"; } } else { retval += "DOUBLE PRECISION"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= MAX_VARCHAR_LENGTH || length <= 0 ) { retval += "VARCHAR(" + MAX_VARCHAR_LENGTH + ")"; } else { retval += "VARCHAR(" + length + ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; } }
UniVerseDatabaseMeta 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_DATE: retval += "DATE"; 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"; } else { if ( length > 0 ) { if ( precision > 0 || length > 18 ) { retval += "DECIMAL(" + length + ", " + precision + ")"; } else { retval += "INTEGER"; } } else { retval += "DOUBLE PRECISION"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= MAX_VARCHAR_LENGTH || length <= 0 ) { retval += "VARCHAR(" + MAX_VARCHAR_LENGTH + ")"; } else { retval += "VARCHAR(" + length + ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  }
UniVerseDatabaseMeta 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_DATE: retval += "DATE"; 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"; } else { if ( length > 0 ) { if ( precision > 0 || length > 18 ) { retval += "DECIMAL(" + length + ", " + precision + ")"; } else { retval += "INTEGER"; } } else { retval += "DOUBLE PRECISION"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= MAX_VARCHAR_LENGTH || length <= 0 ) { retval += "VARCHAR(" + MAX_VARCHAR_LENGTH + ")"; } else { retval += "VARCHAR(" + length + ")"; } 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 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[] getReservedWords(); @Override String[] getUsedLibraries(); @Override boolean supportsNewLinesInSQL(); @Override int getMaxVARCHARLength(); }
UniVerseDatabaseMeta 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_DATE: retval += "DATE"; 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"; } else { if ( length > 0 ) { if ( precision > 0 || length > 18 ) { retval += "DECIMAL(" + length + ", " + precision + ")"; } else { retval += "INTEGER"; } } else { retval += "DOUBLE PRECISION"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length >= MAX_VARCHAR_LENGTH || length <= 0 ) { retval += "VARCHAR(" + MAX_VARCHAR_LENGTH + ")"; } else { retval += "VARCHAR(" + length + ")"; } 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 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[] getReservedWords(); @Override String[] getUsedLibraries(); @Override boolean supportsNewLinesInSQL(); @Override int getMaxVARCHARLength();  }