@Test public void testGetFieldDefinition() throws Exception { assertEquals( "FOO DATE", nativeMeta.getFieldDefinition( new ValueMetaDate( "FOO" ), "", "", false, true, false ) ); assertEquals( "DATE", nativeMeta.getFieldDefinition( new ValueMetaTimestamp( "FOO" ), "", "", false, false, false ) ); assertEquals( "CHAR(1)", nativeMeta.getFieldDefinition( new ValueMetaBoolean( "FOO" ), "", "", false, false, false ) ); assertEquals( "NUMBER(5, 3)", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 5, 3 ), "", "", false, false, false ) ); assertEquals( "NUMBER(5)", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 5, 0 ), "", "", false, false, false ) ); assertEquals( "INTEGER", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 17, 0 ), "", "", false, false, false ) ); assertEquals( "CLOB", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", DatabaseMeta.CLOB_LENGTH, 0 ), "", "", false, false, false ) ); assertEquals( "CHAR(1)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 1, 0 ), "", "", false, false, false ) ); assertEquals( "VARCHAR2(15)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", 15, 0 ), "", "", false, false, false ) ); assertEquals( "VARCHAR2(2000)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO" ), "", "", false, false, false ) ); assertEquals( "VARCHAR2(2000)", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", nativeMeta.getMaxVARCHARLength(), 0 ), "", "", false, false, false ) ); assertEquals( "CLOB", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", nativeMeta.getMaxVARCHARLength() + 1, 0 ), "", "", false, false, false ) ); assertEquals( "BLOB", nativeMeta.getFieldDefinition( new ValueMetaBinary( "FOO", 45, 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 ) { StringBuilder retval = new StringBuilder( 128 ); String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval.append( fieldname ).append( ' ' ); } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: if ( supportsTimestampDataType() ) { retval.append( "TIMESTAMP" ); } else { retval.append( "DATE" ); } break; case ValueMetaInterface.TYPE_DATE: retval.append( "DATE" ); break; case ValueMetaInterface.TYPE_BOOLEAN: retval.append( "CHAR(1)" ); break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_BIGNUMBER: retval.append( "NUMBER" ); if ( length > 0 ) { retval.append( '(' ).append( length ); if ( precision > 0 ) { retval.append( ", " ).append( precision ); } retval.append( ')' ); } break; case ValueMetaInterface.TYPE_INTEGER: retval.append( "INTEGER" ); break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval.append( "CLOB" ); } else { if ( length == 1 ) { retval.append( "CHAR(1)" ); } else if ( length > 0 && length <= getMaxVARCHARLength() ) { retval.append( "VARCHAR2(" ).append( length ).append( ')' ); } else { if ( length <= 0 ) { retval.append( "VARCHAR2(2000)" ); } else { retval.append( "CLOB" ); } } } break; case ValueMetaInterface.TYPE_BINARY: retval.append( "BLOB" ); break; default: retval.append( " UNKNOWN" ); break; } if ( add_cr ) { retval.append( Const.CR ); } return retval.toString(); }
OracleDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { StringBuilder retval = new StringBuilder( 128 ); String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval.append( fieldname ).append( ' ' ); } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: if ( supportsTimestampDataType() ) { retval.append( "TIMESTAMP" ); } else { retval.append( "DATE" ); } break; case ValueMetaInterface.TYPE_DATE: retval.append( "DATE" ); break; case ValueMetaInterface.TYPE_BOOLEAN: retval.append( "CHAR(1)" ); break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_BIGNUMBER: retval.append( "NUMBER" ); if ( length > 0 ) { retval.append( '(' ).append( length ); if ( precision > 0 ) { retval.append( ", " ).append( precision ); } retval.append( ')' ); } break; case ValueMetaInterface.TYPE_INTEGER: retval.append( "INTEGER" ); break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval.append( "CLOB" ); } else { if ( length == 1 ) { retval.append( "CHAR(1)" ); } else if ( length > 0 && length <= getMaxVARCHARLength() ) { retval.append( "VARCHAR2(" ).append( length ).append( ')' ); } else { if ( length <= 0 ) { retval.append( "VARCHAR2(2000)" ); } else { retval.append( "CLOB" ); } } } break; case ValueMetaInterface.TYPE_BINARY: retval.append( "BLOB" ); break; default: retval.append( " UNKNOWN" ); break; } if ( add_cr ) { retval.append( Const.CR ); } return retval.toString(); } }
OracleDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { StringBuilder retval = new StringBuilder( 128 ); String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval.append( fieldname ).append( ' ' ); } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: if ( supportsTimestampDataType() ) { retval.append( "TIMESTAMP" ); } else { retval.append( "DATE" ); } break; case ValueMetaInterface.TYPE_DATE: retval.append( "DATE" ); break; case ValueMetaInterface.TYPE_BOOLEAN: retval.append( "CHAR(1)" ); break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_BIGNUMBER: retval.append( "NUMBER" ); if ( length > 0 ) { retval.append( '(' ).append( length ); if ( precision > 0 ) { retval.append( ", " ).append( precision ); } retval.append( ')' ); } break; case ValueMetaInterface.TYPE_INTEGER: retval.append( "INTEGER" ); break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval.append( "CLOB" ); } else { if ( length == 1 ) { retval.append( "CHAR(1)" ); } else if ( length > 0 && length <= getMaxVARCHARLength() ) { retval.append( "VARCHAR2(" ).append( length ).append( ')' ); } else { if ( length <= 0 ) { retval.append( "VARCHAR2(2000)" ); } else { retval.append( "CLOB" ); } } } break; case ValueMetaInterface.TYPE_BINARY: retval.append( "BLOB" ); break; default: retval.append( " UNKNOWN" ); break; } if ( add_cr ) { retval.append( Const.CR ); } return retval.toString(); }  }
OracleDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { StringBuilder retval = new StringBuilder( 128 ); String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval.append( fieldname ).append( ' ' ); } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: if ( supportsTimestampDataType() ) { retval.append( "TIMESTAMP" ); } else { retval.append( "DATE" ); } break; case ValueMetaInterface.TYPE_DATE: retval.append( "DATE" ); break; case ValueMetaInterface.TYPE_BOOLEAN: retval.append( "CHAR(1)" ); break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_BIGNUMBER: retval.append( "NUMBER" ); if ( length > 0 ) { retval.append( '(' ).append( length ); if ( precision > 0 ) { retval.append( ", " ).append( precision ); } retval.append( ')' ); } break; case ValueMetaInterface.TYPE_INTEGER: retval.append( "INTEGER" ); break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval.append( "CLOB" ); } else { if ( length == 1 ) { retval.append( "CHAR(1)" ); } else if ( length > 0 && length <= getMaxVARCHARLength() ) { retval.append( "VARCHAR2(" ).append( length ).append( ')' ); } else { if ( length <= 0 ) { retval.append( "VARCHAR2(2000)" ); } else { retval.append( "CLOB" ); } } } break; case ValueMetaInterface.TYPE_BINARY: retval.append( "BLOB" ); break; default: retval.append( " UNKNOWN" ); break; } if ( add_cr ) { retval.append( Const.CR ); } return retval.toString(); }  @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 supportsSequences(); @Override String getSQLSequenceExists( String sequenceName ); @Override String getSQLCurrentSequenceValue( String sequenceName ); @Override String getSQLNextSequenceValue( String sequenceName ); @Override boolean supportsSequenceNoMaxValueOption(); @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 getSQLListOfProcedures(); @Override String getSQLLockTables( String[] tableNames ); @Override String getSQLUnlockTables( String[] tableNames ); @Override String getExtraOptionsHelpText(); @Override String[] getUsedLibraries(); @Override boolean checkIndexExists( Database database, String schemaName, String tableName, String[] idx_fields ); @Override boolean requiresCreateTablePrimaryKeyAppend(); @Override boolean supportsPreparedStatementMetadataRetrieval(); @Override int getMaxColumnsInIndex(); @Override String getSQLListOfSequences(); @Override String quoteSQLString( String string ); @Override boolean releaseSavepoint(); @Override String getTablespaceDDL( VariableSpace variables, DatabaseMeta databaseMeta, String tablespace ); @Override boolean supportsErrorHandlingOnBatchUpdates(); @Override boolean supportsRepository(); @Override int getMaxVARCHARLength(); @Override String getDropTableIfExistsStatement( String tableName ); @Override SqlScriptParser createSqlScriptParser(); boolean strictBigNumberInterpretation(); void setStrictBigNumberInterpretation( boolean strictBigNumberInterpretation ); }
OracleDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface { @Override public String getFieldDefinition( ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr ) { StringBuilder retval = new StringBuilder( 128 ); String fieldname = v.getName(); int length = v.getLength(); int precision = v.getPrecision(); if ( add_fieldname ) { retval.append( fieldname ).append( ' ' ); } int type = v.getType(); switch ( type ) { case ValueMetaInterface.TYPE_TIMESTAMP: if ( supportsTimestampDataType() ) { retval.append( "TIMESTAMP" ); } else { retval.append( "DATE" ); } break; case ValueMetaInterface.TYPE_DATE: retval.append( "DATE" ); break; case ValueMetaInterface.TYPE_BOOLEAN: retval.append( "CHAR(1)" ); break; case ValueMetaInterface.TYPE_NUMBER: case ValueMetaInterface.TYPE_BIGNUMBER: retval.append( "NUMBER" ); if ( length > 0 ) { retval.append( '(' ).append( length ); if ( precision > 0 ) { retval.append( ", " ).append( precision ); } retval.append( ')' ); } break; case ValueMetaInterface.TYPE_INTEGER: retval.append( "INTEGER" ); break; case ValueMetaInterface.TYPE_STRING: if ( length >= DatabaseMeta.CLOB_LENGTH ) { retval.append( "CLOB" ); } else { if ( length == 1 ) { retval.append( "CHAR(1)" ); } else if ( length > 0 && length <= getMaxVARCHARLength() ) { retval.append( "VARCHAR2(" ).append( length ).append( ')' ); } else { if ( length <= 0 ) { retval.append( "VARCHAR2(2000)" ); } else { retval.append( "CLOB" ); } } } break; case ValueMetaInterface.TYPE_BINARY: retval.append( "BLOB" ); break; default: retval.append( " UNKNOWN" ); break; } if ( add_cr ) { retval.append( Const.CR ); } return retval.toString(); }  @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 supportsSequences(); @Override String getSQLSequenceExists( String sequenceName ); @Override String getSQLCurrentSequenceValue( String sequenceName ); @Override String getSQLNextSequenceValue( String sequenceName ); @Override boolean supportsSequenceNoMaxValueOption(); @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 getSQLListOfProcedures(); @Override String getSQLLockTables( String[] tableNames ); @Override String getSQLUnlockTables( String[] tableNames ); @Override String getExtraOptionsHelpText(); @Override String[] getUsedLibraries(); @Override boolean checkIndexExists( Database database, String schemaName, String tableName, String[] idx_fields ); @Override boolean requiresCreateTablePrimaryKeyAppend(); @Override boolean supportsPreparedStatementMetadataRetrieval(); @Override int getMaxColumnsInIndex(); @Override String getSQLListOfSequences(); @Override String quoteSQLString( String string ); @Override boolean releaseSavepoint(); @Override String getTablespaceDDL( VariableSpace variables, DatabaseMeta databaseMeta, String tablespace ); @Override boolean supportsErrorHandlingOnBatchUpdates(); @Override boolean supportsRepository(); @Override int getMaxVARCHARLength(); @Override String getDropTableIfExistsStatement( String tableName ); @Override SqlScriptParser createSqlScriptParser(); boolean strictBigNumberInterpretation(); void setStrictBigNumberInterpretation( boolean strictBigNumberInterpretation );  }