@Override public Class<?> getNativeDataTypeClass() throws KettleValueException { // Not implemented for base class throw new KettleValueException( getTypeDesc() + " does not implement this method" ); } }
@Override public Object cloneValueData( Object object ) throws KettleValueException { InetAddress inetAddress = getInternetAddress( object ); if ( inetAddress == null ) { return null; } try { return InetAddress.getByAddress( inetAddress.getAddress() ); } catch ( Exception e ) { throw new KettleValueException( "Unable to clone Internet Address", e ); } }
@Override public Boolean getBoolean( Object object ) throws KettleValueException { throw new KettleValueException( toStringMeta() + ": it's not possible to convert from an Internet Address to a Boolean" ); }
@Override public Enum<?> string2enum( Class<?> enumClass, String v ) throws KettleValueException { // For SystemDataMeta, enum should be a SystemDataTypes SystemDataTypes type = SystemDataTypes.getTypeFromString( v ); if ( !SystemDataTypes.TYPE_SYSTEM_INFO_NONE.toString().equals( v ) && type == SystemDataTypes.TYPE_SYSTEM_INFO_NONE ) { // Throw exception to let user know entered string was not valid SystemDataType throw new KettleValueException( "Unknown value '" + v + "' for enum " + enumClass ); } else { return type; } } }
public Date getDate( String valueName, Date def ) throws KettleValueException { int idx = rowMeta.indexOfValue( valueName ); if ( idx < 0 ) { throw new KettleValueException( "Unknown column '" + valueName + "'" ); } return getDate( idx, def ); }
public long getInteger( String valueName, long def ) throws KettleValueException { int idx = rowMeta.indexOfValue( valueName ); if ( idx < 0 ) { throw new KettleValueException( "Unknown column '" + valueName + "'" ); } return getInteger( idx, def ); }
public double getNumber( String valueName, double def ) throws KettleValueException { int idx = rowMeta.indexOfValue( valueName ); if ( idx < 0 ) { throw new KettleValueException( "Unknown column '" + valueName + "'" ); } return getNumber( idx, def ); }
public String getString( String valueName, String def ) throws KettleValueException { int idx = rowMeta.indexOfValue( valueName ); if ( idx < 0 ) { throw new KettleValueException( "Unknown column '" + valueName + "'" ); } return getString( idx, def ); }
public void removeValue( String valueName ) throws KettleValueException { int index = rowMeta.indexOfValue( valueName ); if ( index < 0 ) { throw new KettleValueException( "Unable to find '" + valueName + "' in the row" ); } removeValue( index ); }
public Value sin() throws KettleValueException { if ( isNull() ) { return this; } if ( isNumeric() ) { setValue( Math.sin( getNumber() ) ); } else { throw new KettleValueException( "Function SIN only works with a number" ); } return this; }
public Value sqrt() throws KettleValueException { if ( isNull() ) { return this; } if ( isNumeric() ) { setValue( Math.sqrt( getNumber() ) ); } else { throw new KettleValueException( "Function SQRT only works with a number" ); } return this; }
public Value tan() throws KettleValueException { if ( isNull() ) { return this; } if ( isNumeric() ) { setValue( Math.tan( getNumber() ) ); } else { throw new KettleValueException( "Function TAN only works on a number" ); } return this; }
public Value acos() throws KettleValueException { if ( isNull() ) { return this; } if ( isNumeric() ) { setValue( Math.acos( getNumber() ) ); } else { throw new KettleValueException( "Function ACOS only works with numeric data" ); } return this; }
public Value atan2( double arg0 ) throws KettleValueException { if ( isNull() ) { return this; } if ( isNumeric() ) { setValue( Math.atan2( getNumber(), arg0 ) ); } else { throw new KettleValueException( "Function ATAN2 only works with numbers" ); } return this; }
public Value log() throws KettleValueException { if ( isNull() ) { return this; } if ( isNumeric() ) { setValue( Math.log( getNumber() ) ); } else { throw new KettleValueException( "Function LOG only works with a number" ); } return this; }
public Value atan() throws KettleValueException { if ( isNull() ) { return this; } if ( isNumeric() ) { setValue( Math.atan( getNumber() ) ); } else { throw new KettleValueException( "Function ATAN only works with numeric data" ); } return this; }
public Value ceil() throws KettleValueException { if ( isNull() ) { return this; } if ( isNumeric() ) { setValue( Math.ceil( getNumber() ) ); } else { throw new KettleValueException( "Function CEIL only works with a number" ); } return this; }
public Value cos() throws KettleValueException { if ( isNull() ) { return this; } if ( isNumeric() ) { setValue( Math.cos( getNumber() ) ); } else { throw new KettleValueException( "Function COS only works with a number" ); } return this; }
public Value floor() throws KettleValueException { if ( isNull() ) { return this; } if ( isNumeric() ) { setValue( Math.floor( getNumber() ) ); } else { throw new KettleValueException( "Function FLOOR only works with a number" ); } return this; }
@Test public void getNativeDataTypeSimpleName_Unknown() throws Exception { KettleValueException e = new KettleValueException(); ValueMetaInterface v = mock( ValueMetaInterface.class ); doThrow( e ).when( v ).getNativeDataTypeClass(); LogChannel log = mock( LogChannel.class ); whenNew( LogChannel.class ).withAnyArguments().thenReturn( log ); assertEquals( "Object", FieldHelper.getNativeDataTypeSimpleName( v ) ); verify( log, times( 1 ) ).logDebug( "Unable to get name from data type" ); }