@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( "DOUBLE", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO" ), "", "", false, false, false ) ); assertEquals( "DECIMAL(5)", nativeMeta.getFieldDefinition( new ValueMetaInteger( "FOO", 5, 0 ), "", "", false, false, false ) ); assertEquals( "DECIMAL(5, 3)", nativeMeta.getFieldDefinition( new ValueMetaNumber( "FOO", 5, 3 ), "", "", false, false, false ) ); assertEquals( "DECIMAL", nativeMeta.getFieldDefinition( new ValueMetaBigNumber( "FOO", 0, 3 ), "", "", false, false, false ) ); assertEquals( "CLOB", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", DatabaseMeta.CLOB_LENGTH + 1, 0 ), "", "", false, false, false ) ); assertEquals( String.format( "VARCHAR(%d)", ( nativeMeta.getMaxVARCHARLength() - 1 ) ), nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", nativeMeta.getMaxVARCHARLength() - 1, 0 ), "", "", false, false, false ) ); assertEquals( "CLOB", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", nativeMeta.getMaxVARCHARLength() + 1, 0 ), "", "", false, false, false ) ); assertEquals( "CLOB", nativeMeta.getFieldDefinition( new ValueMetaString( "FOO", DatabaseMeta.CLOB_LENGTH - 1, 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 ( length <= 0 && precision <= 0 ) { retval += "DOUBLE"; } else { retval += "DECIMAL"; if ( length > 0 ) { retval += "(" + length; if ( precision > 0 ) { retval += ", " + precision; } retval += ")"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > getMaxVARCHARLength() || length >= DatabaseMeta.CLOB_LENGTH ) { retval += "CLOB"; } else { retval += "VARCHAR"; if ( length > 0 ) { retval += "(" + length; } else { retval += "("; } retval += ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }
AS400DatabaseMeta 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 ( length <= 0 && precision <= 0 ) { retval += "DOUBLE"; } else { retval += "DECIMAL"; if ( length > 0 ) { retval += "(" + length; if ( precision > 0 ) { retval += ", " + precision; } retval += ")"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > getMaxVARCHARLength() || length >= DatabaseMeta.CLOB_LENGTH ) { retval += "CLOB"; } else { retval += "VARCHAR"; if ( length > 0 ) { retval += "(" + length; } else { retval += "("; } retval += ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; } }
AS400DatabaseMeta 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 ( length <= 0 && precision <= 0 ) { retval += "DOUBLE"; } else { retval += "DECIMAL"; if ( length > 0 ) { retval += "(" + length; if ( precision > 0 ) { retval += ", " + precision; } retval += ")"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > getMaxVARCHARLength() || length >= DatabaseMeta.CLOB_LENGTH ) { retval += "CLOB"; } else { retval += "VARCHAR"; if ( length > 0 ) { retval += "(" + length; } else { retval += "("; } retval += ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  }
AS400DatabaseMeta 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 ( length <= 0 && precision <= 0 ) { retval += "DOUBLE"; } else { retval += "DECIMAL"; if ( length > 0 ) { retval += "(" + length; if ( precision > 0 ) { retval += ", " + precision; } retval += ")"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > getMaxVARCHARLength() || length >= DatabaseMeta.CLOB_LENGTH ) { retval += "CLOB"; } else { retval += "VARCHAR"; if ( length > 0 ) { retval += "(" + length; } else { retval += "("; } retval += ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  @Override int[] getAccessTypeList(); @Override String getDriverClass(); @Override int getMaxTextFieldLength(); @Override String getURL( String hostname, String port, String database ); @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[] getReservedWords(); @Override String[] getUsedLibraries(); @Override boolean supportsFloatRoundingOnUpdate(); @Override int getMaxVARCHARLength(); @Override boolean supportsSequences(); @Override String getSQLListOfSequences(); @Override String getSQLSequenceExists( String sequenceName ); @Override String getSQLCurrentSequenceValue( String sequenceName ); @Override String getSQLNextSequenceValue( String sequenceName ); @Override boolean supportsSequenceNoMaxValueOption(); }
AS400DatabaseMeta 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 ( length <= 0 && precision <= 0 ) { retval += "DOUBLE"; } else { retval += "DECIMAL"; if ( length > 0 ) { retval += "(" + length; if ( precision > 0 ) { retval += ", " + precision; } retval += ")"; } } break; case ValueMetaInterface.TYPE_STRING: if ( length > getMaxVARCHARLength() || length >= DatabaseMeta.CLOB_LENGTH ) { retval += "CLOB"; } else { retval += "VARCHAR"; if ( length > 0 ) { retval += "(" + length; } else { retval += "("; } retval += ")"; } break; default: retval += " UNKNOWN"; break; } if ( add_cr ) { retval += Const.CR; } return retval; }  @Override int[] getAccessTypeList(); @Override String getDriverClass(); @Override int getMaxTextFieldLength(); @Override String getURL( String hostname, String port, String database ); @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[] getReservedWords(); @Override String[] getUsedLibraries(); @Override boolean supportsFloatRoundingOnUpdate(); @Override int getMaxVARCHARLength(); @Override boolean supportsSequences(); @Override String getSQLListOfSequences(); @Override String getSQLSequenceExists( String sequenceName ); @Override String getSQLCurrentSequenceValue( String sequenceName ); @Override String getSQLNextSequenceValue( String sequenceName ); @Override boolean supportsSequenceNoMaxValueOption();  }