@Test public void testSetPreparedStatementStringValueLogTruncated() throws KettleDatabaseException { ValueMetaBase valueMetaString = new ValueMetaBase( "LOG_FIELD", ValueMetaInterface.TYPE_STRING, LOG_FIELD.length(), 0 ); DatabaseMeta databaseMeta = Mockito.mock( DatabaseMeta.class ); PreparedStatement preparedStatement = Mockito.mock( PreparedStatement.class ); Mockito.when( databaseMeta.getMaxTextFieldLength() ).thenReturn( MAX_TEXT_FIELD_LEN ); List<KettleLoggingEvent> events = listener.getEvents(); assertEquals( 0, events.size() ); valueMetaString.setPreparedStatementValue( databaseMeta, preparedStatement, 0, LOG_FIELD ); assertEquals( 1, events.size() ); }
@Override public void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement, int index, Object data ) throws KettleDatabaseException { try { switch ( getType() ) { case ValueMetaInterface.TYPE_NUMBER: if ( !isNull( data ) ) { double num = getNumber( data ).doubleValue(); if ( databaseMeta.supportsFloatRoundingOnUpdate() && getPrecision() >= 0 ) { num = Const.round( num, getPrecision() ); } preparedStatement.setDouble( index, num ); } else { preparedStatement.setNull( index, java.sql.Types.DOUBLE ); } break; case ValueMetaInterface.TYPE_INTEGER: if ( !isNull( data ) ) { if ( databaseMeta.supportsSetLong() ) { preparedStatement.setLong( index, getInteger( data ).longValue() ); } else { double d = getNumber( data ).doubleValue(); if ( databaseMeta.supportsFloatRoundingOnUpdate() && getPrecision() >= 0 ) { preparedStatement.setDouble( index, d ); } else { preparedStatement.setDouble( index, Const.round( d, getPrecision() ) ); } } } else { preparedStatement.setNull( index, java.sql.Types.INTEGER ); } break; case ValueMetaInterface.TYPE_STRING: if ( getLength() < databaseMeta.getMaxTextFieldLength() ) { if ( !isNull( data ) ) { preparedStatement.setString( index, getString( data ) ); } else { preparedStatement.setNull( index, java.sql.Types.VARCHAR ); } } else { if ( !isNull( data ) ) { String string = getString( data ); int maxlen = databaseMeta.getMaxTextFieldLength(); int len = string.length(); int begin = Math.max( len - maxlen, 0 ); if ( begin > 0 ) { log.logMinimal( String.format( "Truncating %d symbols of original message in '%s' field", begin, getName() ) ); string = string.substring( begin ); } if ( databaseMeta.supportsSetCharacterStream() ) { StringReader sr = new StringReader( string ); preparedStatement.setCharacterStream( index, sr, string.length() ); } else { preparedStatement.setString( index, string ); } } else { preparedStatement.setNull( index, java.sql.Types.VARCHAR ); } } break; case ValueMetaInterface.TYPE_DATE: if ( !isNull( data ) ) { if ( getPrecision() == 1 || !databaseMeta.supportsTimeStampToDateConversion() ) { long dat = getInteger( data ).longValue(); java.sql.Date ddate = new java.sql.Date( dat ); if ( ignoreTimezone || this.getDateFormatTimeZone() == null ) { preparedStatement.setDate( index, ddate ); } else { preparedStatement.setDate( index, ddate, Calendar.getInstance( this.getDateFormatTimeZone() ) ); } } else { if ( data instanceof java.sql.Timestamp ) { if ( ignoreTimezone || this.getDateFormatTimeZone() == null ) { preparedStatement.setTimestamp( index, (java.sql.Timestamp) data ); } else { preparedStatement.setTimestamp( index, (java.sql.Timestamp) data, Calendar.getInstance( this .getDateFormatTimeZone() ) ); } } else { long dat = getInteger( data ).longValue(); java.sql.Timestamp sdate = new java.sql.Timestamp( dat ); if ( ignoreTimezone || this.getDateFormatTimeZone() == null ) { preparedStatement.setTimestamp( index, sdate ); } else { preparedStatement.setTimestamp( index, sdate, Calendar.getInstance( this.getDateFormatTimeZone() ) ); } } } } else { if ( getPrecision() == 1 || !databaseMeta.supportsTimeStampToDateConversion() ) { preparedStatement.setNull( index, java.sql.Types.DATE ); } else { preparedStatement.setNull( index, java.sql.Types.TIMESTAMP ); } } break; case ValueMetaInterface.TYPE_BOOLEAN: if ( databaseMeta.supportsBooleanDataType() ) { if ( !isNull( data ) ) { preparedStatement.setBoolean( index, getBoolean( data ).booleanValue() ); } else { preparedStatement.setNull( index, java.sql.Types.BOOLEAN ); } } else { if ( !isNull( data ) ) { preparedStatement.setString( index, getBoolean( data ).booleanValue() ? "Y" : "N" ); } else { preparedStatement.setNull( index, java.sql.Types.CHAR ); } } break; case ValueMetaInterface.TYPE_BIGNUMBER: if ( !isNull( data ) ) { preparedStatement.setBigDecimal( index, getBigNumber( data ) ); } else { preparedStatement.setNull( index, java.sql.Types.DECIMAL ); } break; case ValueMetaInterface.TYPE_BINARY: if ( !isNull( data ) ) { preparedStatement.setBytes( index, getBinary( data ) ); } else { preparedStatement.setNull( index, java.sql.Types.BINARY ); } break; default: preparedStatement.setNull( index, java.sql.Types.VARCHAR ); break; } } catch ( Exception e ) { throw new KettleDatabaseException( "Error setting value #" + index + " [" + toStringMeta() + "] on prepared statement", e ); } }
ValueMetaBase implements ValueMetaInterface { @Override public void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement, int index, Object data ) throws KettleDatabaseException { try { switch ( getType() ) { case ValueMetaInterface.TYPE_NUMBER: if ( !isNull( data ) ) { double num = getNumber( data ).doubleValue(); if ( databaseMeta.supportsFloatRoundingOnUpdate() && getPrecision() >= 0 ) { num = Const.round( num, getPrecision() ); } preparedStatement.setDouble( index, num ); } else { preparedStatement.setNull( index, java.sql.Types.DOUBLE ); } break; case ValueMetaInterface.TYPE_INTEGER: if ( !isNull( data ) ) { if ( databaseMeta.supportsSetLong() ) { preparedStatement.setLong( index, getInteger( data ).longValue() ); } else { double d = getNumber( data ).doubleValue(); if ( databaseMeta.supportsFloatRoundingOnUpdate() && getPrecision() >= 0 ) { preparedStatement.setDouble( index, d ); } else { preparedStatement.setDouble( index, Const.round( d, getPrecision() ) ); } } } else { preparedStatement.setNull( index, java.sql.Types.INTEGER ); } break; case ValueMetaInterface.TYPE_STRING: if ( getLength() < databaseMeta.getMaxTextFieldLength() ) { if ( !isNull( data ) ) { preparedStatement.setString( index, getString( data ) ); } else { preparedStatement.setNull( index, java.sql.Types.VARCHAR ); } } else { if ( !isNull( data ) ) { String string = getString( data ); int maxlen = databaseMeta.getMaxTextFieldLength(); int len = string.length(); int begin = Math.max( len - maxlen, 0 ); if ( begin > 0 ) { log.logMinimal( String.format( "Truncating %d symbols of original message in '%s' field", begin, getName() ) ); string = string.substring( begin ); } if ( databaseMeta.supportsSetCharacterStream() ) { StringReader sr = new StringReader( string ); preparedStatement.setCharacterStream( index, sr, string.length() ); } else { preparedStatement.setString( index, string ); } } else { preparedStatement.setNull( index, java.sql.Types.VARCHAR ); } } break; case ValueMetaInterface.TYPE_DATE: if ( !isNull( data ) ) { if ( getPrecision() == 1 || !databaseMeta.supportsTimeStampToDateConversion() ) { long dat = getInteger( data ).longValue(); java.sql.Date ddate = new java.sql.Date( dat ); if ( ignoreTimezone || this.getDateFormatTimeZone() == null ) { preparedStatement.setDate( index, ddate ); } else { preparedStatement.setDate( index, ddate, Calendar.getInstance( this.getDateFormatTimeZone() ) ); } } else { if ( data instanceof java.sql.Timestamp ) { if ( ignoreTimezone || this.getDateFormatTimeZone() == null ) { preparedStatement.setTimestamp( index, (java.sql.Timestamp) data ); } else { preparedStatement.setTimestamp( index, (java.sql.Timestamp) data, Calendar.getInstance( this .getDateFormatTimeZone() ) ); } } else { long dat = getInteger( data ).longValue(); java.sql.Timestamp sdate = new java.sql.Timestamp( dat ); if ( ignoreTimezone || this.getDateFormatTimeZone() == null ) { preparedStatement.setTimestamp( index, sdate ); } else { preparedStatement.setTimestamp( index, sdate, Calendar.getInstance( this.getDateFormatTimeZone() ) ); } } } } else { if ( getPrecision() == 1 || !databaseMeta.supportsTimeStampToDateConversion() ) { preparedStatement.setNull( index, java.sql.Types.DATE ); } else { preparedStatement.setNull( index, java.sql.Types.TIMESTAMP ); } } break; case ValueMetaInterface.TYPE_BOOLEAN: if ( databaseMeta.supportsBooleanDataType() ) { if ( !isNull( data ) ) { preparedStatement.setBoolean( index, getBoolean( data ).booleanValue() ); } else { preparedStatement.setNull( index, java.sql.Types.BOOLEAN ); } } else { if ( !isNull( data ) ) { preparedStatement.setString( index, getBoolean( data ).booleanValue() ? "Y" : "N" ); } else { preparedStatement.setNull( index, java.sql.Types.CHAR ); } } break; case ValueMetaInterface.TYPE_BIGNUMBER: if ( !isNull( data ) ) { preparedStatement.setBigDecimal( index, getBigNumber( data ) ); } else { preparedStatement.setNull( index, java.sql.Types.DECIMAL ); } break; case ValueMetaInterface.TYPE_BINARY: if ( !isNull( data ) ) { preparedStatement.setBytes( index, getBinary( data ) ); } else { preparedStatement.setNull( index, java.sql.Types.BINARY ); } break; default: preparedStatement.setNull( index, java.sql.Types.VARCHAR ); break; } } catch ( Exception e ) { throw new KettleDatabaseException( "Error setting value #" + index + " [" + toStringMeta() + "] on prepared statement", e ); } } }
ValueMetaBase implements ValueMetaInterface { @Override public void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement, int index, Object data ) throws KettleDatabaseException { try { switch ( getType() ) { case ValueMetaInterface.TYPE_NUMBER: if ( !isNull( data ) ) { double num = getNumber( data ).doubleValue(); if ( databaseMeta.supportsFloatRoundingOnUpdate() && getPrecision() >= 0 ) { num = Const.round( num, getPrecision() ); } preparedStatement.setDouble( index, num ); } else { preparedStatement.setNull( index, java.sql.Types.DOUBLE ); } break; case ValueMetaInterface.TYPE_INTEGER: if ( !isNull( data ) ) { if ( databaseMeta.supportsSetLong() ) { preparedStatement.setLong( index, getInteger( data ).longValue() ); } else { double d = getNumber( data ).doubleValue(); if ( databaseMeta.supportsFloatRoundingOnUpdate() && getPrecision() >= 0 ) { preparedStatement.setDouble( index, d ); } else { preparedStatement.setDouble( index, Const.round( d, getPrecision() ) ); } } } else { preparedStatement.setNull( index, java.sql.Types.INTEGER ); } break; case ValueMetaInterface.TYPE_STRING: if ( getLength() < databaseMeta.getMaxTextFieldLength() ) { if ( !isNull( data ) ) { preparedStatement.setString( index, getString( data ) ); } else { preparedStatement.setNull( index, java.sql.Types.VARCHAR ); } } else { if ( !isNull( data ) ) { String string = getString( data ); int maxlen = databaseMeta.getMaxTextFieldLength(); int len = string.length(); int begin = Math.max( len - maxlen, 0 ); if ( begin > 0 ) { log.logMinimal( String.format( "Truncating %d symbols of original message in '%s' field", begin, getName() ) ); string = string.substring( begin ); } if ( databaseMeta.supportsSetCharacterStream() ) { StringReader sr = new StringReader( string ); preparedStatement.setCharacterStream( index, sr, string.length() ); } else { preparedStatement.setString( index, string ); } } else { preparedStatement.setNull( index, java.sql.Types.VARCHAR ); } } break; case ValueMetaInterface.TYPE_DATE: if ( !isNull( data ) ) { if ( getPrecision() == 1 || !databaseMeta.supportsTimeStampToDateConversion() ) { long dat = getInteger( data ).longValue(); java.sql.Date ddate = new java.sql.Date( dat ); if ( ignoreTimezone || this.getDateFormatTimeZone() == null ) { preparedStatement.setDate( index, ddate ); } else { preparedStatement.setDate( index, ddate, Calendar.getInstance( this.getDateFormatTimeZone() ) ); } } else { if ( data instanceof java.sql.Timestamp ) { if ( ignoreTimezone || this.getDateFormatTimeZone() == null ) { preparedStatement.setTimestamp( index, (java.sql.Timestamp) data ); } else { preparedStatement.setTimestamp( index, (java.sql.Timestamp) data, Calendar.getInstance( this .getDateFormatTimeZone() ) ); } } else { long dat = getInteger( data ).longValue(); java.sql.Timestamp sdate = new java.sql.Timestamp( dat ); if ( ignoreTimezone || this.getDateFormatTimeZone() == null ) { preparedStatement.setTimestamp( index, sdate ); } else { preparedStatement.setTimestamp( index, sdate, Calendar.getInstance( this.getDateFormatTimeZone() ) ); } } } } else { if ( getPrecision() == 1 || !databaseMeta.supportsTimeStampToDateConversion() ) { preparedStatement.setNull( index, java.sql.Types.DATE ); } else { preparedStatement.setNull( index, java.sql.Types.TIMESTAMP ); } } break; case ValueMetaInterface.TYPE_BOOLEAN: if ( databaseMeta.supportsBooleanDataType() ) { if ( !isNull( data ) ) { preparedStatement.setBoolean( index, getBoolean( data ).booleanValue() ); } else { preparedStatement.setNull( index, java.sql.Types.BOOLEAN ); } } else { if ( !isNull( data ) ) { preparedStatement.setString( index, getBoolean( data ).booleanValue() ? "Y" : "N" ); } else { preparedStatement.setNull( index, java.sql.Types.CHAR ); } } break; case ValueMetaInterface.TYPE_BIGNUMBER: if ( !isNull( data ) ) { preparedStatement.setBigDecimal( index, getBigNumber( data ) ); } else { preparedStatement.setNull( index, java.sql.Types.DECIMAL ); } break; case ValueMetaInterface.TYPE_BINARY: if ( !isNull( data ) ) { preparedStatement.setBytes( index, getBinary( data ) ); } else { preparedStatement.setNull( index, java.sql.Types.BINARY ); } break; default: preparedStatement.setNull( index, java.sql.Types.VARCHAR ); break; } } catch ( Exception e ) { throw new KettleDatabaseException( "Error setting value #" + index + " [" + toStringMeta() + "] on prepared statement", e ); } } ValueMetaBase();  ValueMetaBase( String name );  ValueMetaBase( String name, int type );  ValueMetaBase( String name, int type, int length, int precision );  ValueMetaBase( Node node ); @Deprecated  ValueMetaBase( DataInputStream inputStream ); @Deprecated  ValueMetaBase( String name, int type, int storageType ); }
ValueMetaBase implements ValueMetaInterface { @Override public void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement, int index, Object data ) throws KettleDatabaseException { try { switch ( getType() ) { case ValueMetaInterface.TYPE_NUMBER: if ( !isNull( data ) ) { double num = getNumber( data ).doubleValue(); if ( databaseMeta.supportsFloatRoundingOnUpdate() && getPrecision() >= 0 ) { num = Const.round( num, getPrecision() ); } preparedStatement.setDouble( index, num ); } else { preparedStatement.setNull( index, java.sql.Types.DOUBLE ); } break; case ValueMetaInterface.TYPE_INTEGER: if ( !isNull( data ) ) { if ( databaseMeta.supportsSetLong() ) { preparedStatement.setLong( index, getInteger( data ).longValue() ); } else { double d = getNumber( data ).doubleValue(); if ( databaseMeta.supportsFloatRoundingOnUpdate() && getPrecision() >= 0 ) { preparedStatement.setDouble( index, d ); } else { preparedStatement.setDouble( index, Const.round( d, getPrecision() ) ); } } } else { preparedStatement.setNull( index, java.sql.Types.INTEGER ); } break; case ValueMetaInterface.TYPE_STRING: if ( getLength() < databaseMeta.getMaxTextFieldLength() ) { if ( !isNull( data ) ) { preparedStatement.setString( index, getString( data ) ); } else { preparedStatement.setNull( index, java.sql.Types.VARCHAR ); } } else { if ( !isNull( data ) ) { String string = getString( data ); int maxlen = databaseMeta.getMaxTextFieldLength(); int len = string.length(); int begin = Math.max( len - maxlen, 0 ); if ( begin > 0 ) { log.logMinimal( String.format( "Truncating %d symbols of original message in '%s' field", begin, getName() ) ); string = string.substring( begin ); } if ( databaseMeta.supportsSetCharacterStream() ) { StringReader sr = new StringReader( string ); preparedStatement.setCharacterStream( index, sr, string.length() ); } else { preparedStatement.setString( index, string ); } } else { preparedStatement.setNull( index, java.sql.Types.VARCHAR ); } } break; case ValueMetaInterface.TYPE_DATE: if ( !isNull( data ) ) { if ( getPrecision() == 1 || !databaseMeta.supportsTimeStampToDateConversion() ) { long dat = getInteger( data ).longValue(); java.sql.Date ddate = new java.sql.Date( dat ); if ( ignoreTimezone || this.getDateFormatTimeZone() == null ) { preparedStatement.setDate( index, ddate ); } else { preparedStatement.setDate( index, ddate, Calendar.getInstance( this.getDateFormatTimeZone() ) ); } } else { if ( data instanceof java.sql.Timestamp ) { if ( ignoreTimezone || this.getDateFormatTimeZone() == null ) { preparedStatement.setTimestamp( index, (java.sql.Timestamp) data ); } else { preparedStatement.setTimestamp( index, (java.sql.Timestamp) data, Calendar.getInstance( this .getDateFormatTimeZone() ) ); } } else { long dat = getInteger( data ).longValue(); java.sql.Timestamp sdate = new java.sql.Timestamp( dat ); if ( ignoreTimezone || this.getDateFormatTimeZone() == null ) { preparedStatement.setTimestamp( index, sdate ); } else { preparedStatement.setTimestamp( index, sdate, Calendar.getInstance( this.getDateFormatTimeZone() ) ); } } } } else { if ( getPrecision() == 1 || !databaseMeta.supportsTimeStampToDateConversion() ) { preparedStatement.setNull( index, java.sql.Types.DATE ); } else { preparedStatement.setNull( index, java.sql.Types.TIMESTAMP ); } } break; case ValueMetaInterface.TYPE_BOOLEAN: if ( databaseMeta.supportsBooleanDataType() ) { if ( !isNull( data ) ) { preparedStatement.setBoolean( index, getBoolean( data ).booleanValue() ); } else { preparedStatement.setNull( index, java.sql.Types.BOOLEAN ); } } else { if ( !isNull( data ) ) { preparedStatement.setString( index, getBoolean( data ).booleanValue() ? "Y" : "N" ); } else { preparedStatement.setNull( index, java.sql.Types.CHAR ); } } break; case ValueMetaInterface.TYPE_BIGNUMBER: if ( !isNull( data ) ) { preparedStatement.setBigDecimal( index, getBigNumber( data ) ); } else { preparedStatement.setNull( index, java.sql.Types.DECIMAL ); } break; case ValueMetaInterface.TYPE_BINARY: if ( !isNull( data ) ) { preparedStatement.setBytes( index, getBinary( data ) ); } else { preparedStatement.setNull( index, java.sql.Types.BINARY ); } break; default: preparedStatement.setNull( index, java.sql.Types.VARCHAR ); break; } } catch ( Exception e ) { throw new KettleDatabaseException( "Error setting value #" + index + " [" + toStringMeta() + "] on prepared statement", e ); } } ValueMetaBase();  ValueMetaBase( String name );  ValueMetaBase( String name, int type );  ValueMetaBase( String name, int type, int length, int precision );  ValueMetaBase( Node node ); @Deprecated  ValueMetaBase( DataInputStream inputStream ); @Deprecated  ValueMetaBase( String name, int type, int storageType ); @Override ValueMetaBase clone(); @Override String getComments(); @Override void setComments( String comments ); @Override Object[] getIndex(); @Override void setIndex( Object[] index ); @Override int getLength(); @Override void setLength( int length ); @Override void setLength( int length, int precision ); @Override String getName(); @Override void setName( String name ); @Override String getOrigin(); @Override void setOrigin( String origin ); @Override int getPrecision(); @Override void setPrecision( int precision ); @Override int getStorageType(); @Override void setStorageType( int storageType ); @Override boolean isStorageNormal(); @Override boolean isStorageIndexed(); @Override boolean isStorageBinaryString(); @Override int getType(); @Override @Deprecated void setType( int type ); @Override @Deprecated String getConversionMask(); @Override void setConversionMask( String conversionMask ); @Override String getStringEncoding(); @Override void setStringEncoding( String encoding ); @Override String getDecimalSymbol(); @Override void setDecimalSymbol( String decimalSymbol ); @Override String getGroupingSymbol(); @Override void setGroupingSymbol( String groupingSymbol ); @Override String getCurrencySymbol(); @Override void setCurrencySymbol( String currencySymbol ); @Override boolean isCaseInsensitive(); @Override void setCaseInsensitive( boolean caseInsensitive ); @Override boolean isCollatorDisabled(); @Override void setCollatorDisabled( boolean collatorDisabled ); @Override Locale getCollatorLocale(); @Override void setCollatorLocale( Locale locale ); @Override int getCollatorStrength(); @Override void setCollatorStrength( int collatorStrength ); @Override boolean isSortedDescending(); @Override void setSortedDescending( boolean sortedDescending ); @Override boolean isOutputPaddingEnabled(); @Override void setOutputPaddingEnabled( boolean outputPaddingEnabled ); @Override boolean isLargeTextField(); @Override void setLargeTextField( boolean largeTextField ); @Override boolean isDateFormatLenient(); @Override void setDateFormatLenient( boolean dateFormatLenient ); @Override Locale getDateFormatLocale(); @Override void setDateFormatLocale( Locale dateFormatLocale ); @Override synchronized SimpleDateFormat getDateFormat(); @Override synchronized DecimalFormat getDecimalFormat(); @Override synchronized DecimalFormat getDecimalFormat( boolean useBigDecimal ); @Override String getFormatMask(); static Boolean convertStringToBoolean( String string ); @Override Object convertToNormalStorageType( Object object ); @Override Object convertToBinaryStringStorageType( Object object ); @Override Object convertBinaryStringToNativeType( byte[] binary ); @Override Object convertNormalStorageTypeToBinaryString( Object object ); @Override Object cloneValueData( Object object ); @Override String getCompatibleString( Object object ); @Override String getString( Object object ); @Override Double getNumber( Object object ); @Override Long getInteger( Object object ); @Override BigDecimal getBigNumber( Object object ); @Override Boolean getBoolean( Object object ); @Override Date getDate( Object object ); @Override byte[] getBinary( Object object ); @Override byte[] getBinaryString( Object object ); @Override boolean isString(); @Override boolean isDate(); @Override boolean isBigNumber(); @Override boolean isNumber(); @Override boolean isBoolean(); @Override boolean isSerializableType(); @Override boolean isBinary(); @Override boolean isInteger(); @Override boolean isNumeric(); static final boolean isNumeric( int t ); boolean isSortedAscending(); @Override String getTypeDesc(); String getStorageTypeDesc(); @Override String toString(); @Override String toStringMeta(); @Override void writeData( DataOutputStream outputStream, Object object ); @Override Object readData( DataInputStream inputStream ); @Override void writeMeta( DataOutputStream outputStream ); @Override void readMetaData( DataInputStream inputStream ); @Override String getMetaXML(); @Override String getDataXML( Object object ); @Override Object getValue( Node node ); static final String[] getTypes(); static final String[] getAllTypes(); static final String getTypeDesc( int type ); static final int getType( String desc ); static final int getStorageType( String desc ); static final String getStorageTypeCode( int storageType ); @Override boolean isNull( Object data ); @Override int compare( Object data1, Object data2 ); @Override int compare( Object data1, ValueMetaInterface meta2, Object data2 ); @Override Object convertData( ValueMetaInterface meta2, Object data2 ); @Override Object convertDataCompatible( ValueMetaInterface meta2, Object data2 ); @Override Object convertDataUsingConversionMetaData( Object data ); @Override Object convertDataFromString( String pol, ValueMetaInterface convertMeta, String nullIf, String ifNull,
      int trim_type ); @Override int hashCode( Object object ); @Override Value createOriginalValue( Object data ); @Override Object getValueData( Value value ); @Override ValueMetaInterface getStorageMetadata(); @Override void setStorageMetadata( ValueMetaInterface storageMetadata ); @Override int getTrimType(); @Override void setTrimType( int trimType ); static final int getTrimTypeByCode( String tt ); static final int getTrimTypeByDesc( String tt ); static final String getTrimTypeCode( int i ); static final String getTrimTypeDesc( int i ); @Override ValueMetaInterface getConversionMetadata(); @Override void setConversionMetadata( ValueMetaInterface conversionMetadata ); @Override boolean isSingleByteEncoding(); @Override long getNumberOfBinaryStringConversions(); @Override void setNumberOfBinaryStringConversions( long numberOfBinaryStringConversions ); @Override boolean isOriginalAutoIncrement(); @Override void setOriginalAutoIncrement( boolean originalAutoIncrement ); @Override int getOriginalColumnType(); @Override void setOriginalColumnType( int originalColumnType ); @Override String getOriginalColumnTypeName(); @Override void setOriginalColumnTypeName( String originalColumnTypeName ); @Override int isOriginalNullable(); @Override void setOriginalNullable( int originalNullable ); @Override int getOriginalPrecision(); @Override void setOriginalPrecision( int originalPrecision ); @Override int getOriginalScale(); @Override void setOriginalScale( int originalScale ); @Override boolean isOriginalSigned(); @Override void setOriginalSigned( boolean originalSigned ); boolean isBigNumberFormatting(); void setBigNumberFormatting( boolean bigNumberFormatting ); static String[] getTrimTypeCodes(); static String[] getTrimTypeDescriptions(); @Override boolean requiresRealClone(); @Override boolean isLenientStringToNumber(); @Override void setLenientStringToNumber( boolean lenientStringToNumber ); @Override TimeZone getDateFormatTimeZone(); @Override void setDateFormatTimeZone( TimeZone dateFormatTimeZone ); @Override void drawValue( PrimitiveGCInterface gc, Object value ); @SuppressWarnings( "fallthrough" ) @Override ValueMetaInterface getValueFromSQLType( DatabaseMeta databaseMeta, String name, java.sql.ResultSetMetaData rm,
      int index, boolean ignoreLength, boolean lazyConversion ); @Override Object getValueFromResultSet( DatabaseInterface databaseInterface, ResultSet resultSet, int index ); @Override void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement, int index,
      Object data ); @Override Object getNativeDataType( Object object ); @Override String getDatabaseColumnTypeDefinition( DatabaseInterface databaseInterface, String tk, String pk,
      boolean use_autoinc, boolean add_fieldname, boolean add_cr ); @Override Class<?> getNativeDataTypeClass(); }
ValueMetaBase implements ValueMetaInterface { @Override public void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement, int index, Object data ) throws KettleDatabaseException { try { switch ( getType() ) { case ValueMetaInterface.TYPE_NUMBER: if ( !isNull( data ) ) { double num = getNumber( data ).doubleValue(); if ( databaseMeta.supportsFloatRoundingOnUpdate() && getPrecision() >= 0 ) { num = Const.round( num, getPrecision() ); } preparedStatement.setDouble( index, num ); } else { preparedStatement.setNull( index, java.sql.Types.DOUBLE ); } break; case ValueMetaInterface.TYPE_INTEGER: if ( !isNull( data ) ) { if ( databaseMeta.supportsSetLong() ) { preparedStatement.setLong( index, getInteger( data ).longValue() ); } else { double d = getNumber( data ).doubleValue(); if ( databaseMeta.supportsFloatRoundingOnUpdate() && getPrecision() >= 0 ) { preparedStatement.setDouble( index, d ); } else { preparedStatement.setDouble( index, Const.round( d, getPrecision() ) ); } } } else { preparedStatement.setNull( index, java.sql.Types.INTEGER ); } break; case ValueMetaInterface.TYPE_STRING: if ( getLength() < databaseMeta.getMaxTextFieldLength() ) { if ( !isNull( data ) ) { preparedStatement.setString( index, getString( data ) ); } else { preparedStatement.setNull( index, java.sql.Types.VARCHAR ); } } else { if ( !isNull( data ) ) { String string = getString( data ); int maxlen = databaseMeta.getMaxTextFieldLength(); int len = string.length(); int begin = Math.max( len - maxlen, 0 ); if ( begin > 0 ) { log.logMinimal( String.format( "Truncating %d symbols of original message in '%s' field", begin, getName() ) ); string = string.substring( begin ); } if ( databaseMeta.supportsSetCharacterStream() ) { StringReader sr = new StringReader( string ); preparedStatement.setCharacterStream( index, sr, string.length() ); } else { preparedStatement.setString( index, string ); } } else { preparedStatement.setNull( index, java.sql.Types.VARCHAR ); } } break; case ValueMetaInterface.TYPE_DATE: if ( !isNull( data ) ) { if ( getPrecision() == 1 || !databaseMeta.supportsTimeStampToDateConversion() ) { long dat = getInteger( data ).longValue(); java.sql.Date ddate = new java.sql.Date( dat ); if ( ignoreTimezone || this.getDateFormatTimeZone() == null ) { preparedStatement.setDate( index, ddate ); } else { preparedStatement.setDate( index, ddate, Calendar.getInstance( this.getDateFormatTimeZone() ) ); } } else { if ( data instanceof java.sql.Timestamp ) { if ( ignoreTimezone || this.getDateFormatTimeZone() == null ) { preparedStatement.setTimestamp( index, (java.sql.Timestamp) data ); } else { preparedStatement.setTimestamp( index, (java.sql.Timestamp) data, Calendar.getInstance( this .getDateFormatTimeZone() ) ); } } else { long dat = getInteger( data ).longValue(); java.sql.Timestamp sdate = new java.sql.Timestamp( dat ); if ( ignoreTimezone || this.getDateFormatTimeZone() == null ) { preparedStatement.setTimestamp( index, sdate ); } else { preparedStatement.setTimestamp( index, sdate, Calendar.getInstance( this.getDateFormatTimeZone() ) ); } } } } else { if ( getPrecision() == 1 || !databaseMeta.supportsTimeStampToDateConversion() ) { preparedStatement.setNull( index, java.sql.Types.DATE ); } else { preparedStatement.setNull( index, java.sql.Types.TIMESTAMP ); } } break; case ValueMetaInterface.TYPE_BOOLEAN: if ( databaseMeta.supportsBooleanDataType() ) { if ( !isNull( data ) ) { preparedStatement.setBoolean( index, getBoolean( data ).booleanValue() ); } else { preparedStatement.setNull( index, java.sql.Types.BOOLEAN ); } } else { if ( !isNull( data ) ) { preparedStatement.setString( index, getBoolean( data ).booleanValue() ? "Y" : "N" ); } else { preparedStatement.setNull( index, java.sql.Types.CHAR ); } } break; case ValueMetaInterface.TYPE_BIGNUMBER: if ( !isNull( data ) ) { preparedStatement.setBigDecimal( index, getBigNumber( data ) ); } else { preparedStatement.setNull( index, java.sql.Types.DECIMAL ); } break; case ValueMetaInterface.TYPE_BINARY: if ( !isNull( data ) ) { preparedStatement.setBytes( index, getBinary( data ) ); } else { preparedStatement.setNull( index, java.sql.Types.BINARY ); } break; default: preparedStatement.setNull( index, java.sql.Types.VARCHAR ); break; } } catch ( Exception e ) { throw new KettleDatabaseException( "Error setting value #" + index + " [" + toStringMeta() + "] on prepared statement", e ); } } ValueMetaBase();  ValueMetaBase( String name );  ValueMetaBase( String name, int type );  ValueMetaBase( String name, int type, int length, int precision );  ValueMetaBase( Node node ); @Deprecated  ValueMetaBase( DataInputStream inputStream ); @Deprecated  ValueMetaBase( String name, int type, int storageType ); @Override ValueMetaBase clone(); @Override String getComments(); @Override void setComments( String comments ); @Override Object[] getIndex(); @Override void setIndex( Object[] index ); @Override int getLength(); @Override void setLength( int length ); @Override void setLength( int length, int precision ); @Override String getName(); @Override void setName( String name ); @Override String getOrigin(); @Override void setOrigin( String origin ); @Override int getPrecision(); @Override void setPrecision( int precision ); @Override int getStorageType(); @Override void setStorageType( int storageType ); @Override boolean isStorageNormal(); @Override boolean isStorageIndexed(); @Override boolean isStorageBinaryString(); @Override int getType(); @Override @Deprecated void setType( int type ); @Override @Deprecated String getConversionMask(); @Override void setConversionMask( String conversionMask ); @Override String getStringEncoding(); @Override void setStringEncoding( String encoding ); @Override String getDecimalSymbol(); @Override void setDecimalSymbol( String decimalSymbol ); @Override String getGroupingSymbol(); @Override void setGroupingSymbol( String groupingSymbol ); @Override String getCurrencySymbol(); @Override void setCurrencySymbol( String currencySymbol ); @Override boolean isCaseInsensitive(); @Override void setCaseInsensitive( boolean caseInsensitive ); @Override boolean isCollatorDisabled(); @Override void setCollatorDisabled( boolean collatorDisabled ); @Override Locale getCollatorLocale(); @Override void setCollatorLocale( Locale locale ); @Override int getCollatorStrength(); @Override void setCollatorStrength( int collatorStrength ); @Override boolean isSortedDescending(); @Override void setSortedDescending( boolean sortedDescending ); @Override boolean isOutputPaddingEnabled(); @Override void setOutputPaddingEnabled( boolean outputPaddingEnabled ); @Override boolean isLargeTextField(); @Override void setLargeTextField( boolean largeTextField ); @Override boolean isDateFormatLenient(); @Override void setDateFormatLenient( boolean dateFormatLenient ); @Override Locale getDateFormatLocale(); @Override void setDateFormatLocale( Locale dateFormatLocale ); @Override synchronized SimpleDateFormat getDateFormat(); @Override synchronized DecimalFormat getDecimalFormat(); @Override synchronized DecimalFormat getDecimalFormat( boolean useBigDecimal ); @Override String getFormatMask(); static Boolean convertStringToBoolean( String string ); @Override Object convertToNormalStorageType( Object object ); @Override Object convertToBinaryStringStorageType( Object object ); @Override Object convertBinaryStringToNativeType( byte[] binary ); @Override Object convertNormalStorageTypeToBinaryString( Object object ); @Override Object cloneValueData( Object object ); @Override String getCompatibleString( Object object ); @Override String getString( Object object ); @Override Double getNumber( Object object ); @Override Long getInteger( Object object ); @Override BigDecimal getBigNumber( Object object ); @Override Boolean getBoolean( Object object ); @Override Date getDate( Object object ); @Override byte[] getBinary( Object object ); @Override byte[] getBinaryString( Object object ); @Override boolean isString(); @Override boolean isDate(); @Override boolean isBigNumber(); @Override boolean isNumber(); @Override boolean isBoolean(); @Override boolean isSerializableType(); @Override boolean isBinary(); @Override boolean isInteger(); @Override boolean isNumeric(); static final boolean isNumeric( int t ); boolean isSortedAscending(); @Override String getTypeDesc(); String getStorageTypeDesc(); @Override String toString(); @Override String toStringMeta(); @Override void writeData( DataOutputStream outputStream, Object object ); @Override Object readData( DataInputStream inputStream ); @Override void writeMeta( DataOutputStream outputStream ); @Override void readMetaData( DataInputStream inputStream ); @Override String getMetaXML(); @Override String getDataXML( Object object ); @Override Object getValue( Node node ); static final String[] getTypes(); static final String[] getAllTypes(); static final String getTypeDesc( int type ); static final int getType( String desc ); static final int getStorageType( String desc ); static final String getStorageTypeCode( int storageType ); @Override boolean isNull( Object data ); @Override int compare( Object data1, Object data2 ); @Override int compare( Object data1, ValueMetaInterface meta2, Object data2 ); @Override Object convertData( ValueMetaInterface meta2, Object data2 ); @Override Object convertDataCompatible( ValueMetaInterface meta2, Object data2 ); @Override Object convertDataUsingConversionMetaData( Object data ); @Override Object convertDataFromString( String pol, ValueMetaInterface convertMeta, String nullIf, String ifNull,
      int trim_type ); @Override int hashCode( Object object ); @Override Value createOriginalValue( Object data ); @Override Object getValueData( Value value ); @Override ValueMetaInterface getStorageMetadata(); @Override void setStorageMetadata( ValueMetaInterface storageMetadata ); @Override int getTrimType(); @Override void setTrimType( int trimType ); static final int getTrimTypeByCode( String tt ); static final int getTrimTypeByDesc( String tt ); static final String getTrimTypeCode( int i ); static final String getTrimTypeDesc( int i ); @Override ValueMetaInterface getConversionMetadata(); @Override void setConversionMetadata( ValueMetaInterface conversionMetadata ); @Override boolean isSingleByteEncoding(); @Override long getNumberOfBinaryStringConversions(); @Override void setNumberOfBinaryStringConversions( long numberOfBinaryStringConversions ); @Override boolean isOriginalAutoIncrement(); @Override void setOriginalAutoIncrement( boolean originalAutoIncrement ); @Override int getOriginalColumnType(); @Override void setOriginalColumnType( int originalColumnType ); @Override String getOriginalColumnTypeName(); @Override void setOriginalColumnTypeName( String originalColumnTypeName ); @Override int isOriginalNullable(); @Override void setOriginalNullable( int originalNullable ); @Override int getOriginalPrecision(); @Override void setOriginalPrecision( int originalPrecision ); @Override int getOriginalScale(); @Override void setOriginalScale( int originalScale ); @Override boolean isOriginalSigned(); @Override void setOriginalSigned( boolean originalSigned ); boolean isBigNumberFormatting(); void setBigNumberFormatting( boolean bigNumberFormatting ); static String[] getTrimTypeCodes(); static String[] getTrimTypeDescriptions(); @Override boolean requiresRealClone(); @Override boolean isLenientStringToNumber(); @Override void setLenientStringToNumber( boolean lenientStringToNumber ); @Override TimeZone getDateFormatTimeZone(); @Override void setDateFormatTimeZone( TimeZone dateFormatTimeZone ); @Override void drawValue( PrimitiveGCInterface gc, Object value ); @SuppressWarnings( "fallthrough" ) @Override ValueMetaInterface getValueFromSQLType( DatabaseMeta databaseMeta, String name, java.sql.ResultSetMetaData rm,
      int index, boolean ignoreLength, boolean lazyConversion ); @Override Object getValueFromResultSet( DatabaseInterface databaseInterface, ResultSet resultSet, int index ); @Override void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement, int index,
      Object data ); @Override Object getNativeDataType( Object object ); @Override String getDatabaseColumnTypeDefinition( DatabaseInterface databaseInterface, String tk, String pk,
      boolean use_autoinc, boolean add_fieldname, boolean add_cr ); @Override Class<?> getNativeDataTypeClass(); static final String DEFAULT_INTEGER_PARSE_MASK; static final String DEFAULT_NUMBER_PARSE_MASK; static final String DEFAULT_BIGNUMBER_PARSE_MASK; static final String DEFAULT_DATE_PARSE_MASK; static final String DEFAULT_TIMESTAMP_PARSE_MASK; static final String DEFAULT_INTEGER_FORMAT_MASK; static final String DEFAULT_NUMBER_FORMAT_MASK; static final String DEFAULT_BIG_NUMBER_FORMAT_MASK; static final String DEFAULT_DATE_FORMAT_MASK; static final String DEFAULT_TIMESTAMP_FORMAT_MASK; static final String XML_META_TAG; static final String XML_DATA_TAG; static final String COMPATIBLE_DATE_FORMAT_PATTERN; static final boolean EMPTY_STRING_AND_NULL_ARE_DIFFERENT; static final String[] trimTypeCode; static final String[] trimTypeDesc; static final String[] SINGLE_BYTE_ENCODINGS; }