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 asin() throws KettleValueException { if ( isNull() ) { return this; } if ( isNumeric() ) { setValue( Math.asin( getNumber() ) ); } else { throw new KettleValueException( "Function ASIN only works with numeric data" ); } return this; }
public Value exp() throws KettleValueException { if ( isNull() ) { return this; } if ( isNumeric() ) { setValue( Math.exp( getNumber() ) ); } else { throw new KettleValueException( "Function EXP only works with 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 mod( double arg0 ) throws KettleValueException { if ( isNull() ) { return this; } if ( isNumeric() ) { double n1 = getNumber(); double n2 = arg0; setValue( n1 - ( n2 * Math.floor( n1 / n2 ) ) ); } else { throw new KettleValueException( "Function MOD only works with numeric data" ); } 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; }
public Value power( Value v ) throws KettleValueException { if ( isNull() ) { return this; } else if ( isNumeric() ) { setValue( Math.pow( getNumber(), v.getNumber() ) ); } else { throw new KettleValueException( "Function POWER only works with numeric data" ); } return this; }
/** * Rounds off to the nearest integer. * <p> * See also: java.lang.Math.round() * * @return The rounded Number value. */ public Value round() throws KettleValueException { if ( isNull() ) { return this; } if ( isNumeric() ) { setValue( (double) Math.round( getNumber() ) ); } else { throw new KettleValueException( "Function ROUND only works with a number" ); } return this; }
public Value num2dat() throws KettleValueException { if ( isNull() ) { setType( VALUE_TYPE_DATE ); } else { if ( isNumeric() ) { setValue( new Date( getInteger() ) ); setLength( -1, -1 ); } else { throw new KettleValueException( "Function NUM2DAT only works on a number" ); } } return this; }
/** * Rounds the Number value to a certain number decimal places. * * @param decimalPlaces * @return The rounded Number Value * @throws KettleValueException * in case it's not a number (or other problem). */ public Value round( int decimalPlaces ) throws KettleValueException { if ( isNull() ) { return this; } if ( isNumeric() ) { if ( isBigNumber() ) { // Multiply by 10^decimalPlaces // For example 123.458343938437, Decimalplaces = 2 // BigDecimal bigDec = getBigNumber(); // System.out.println("ROUND decimalPlaces : "+decimalPlaces+", bigNumber = "+bigDec); bigDec = bigDec.setScale( decimalPlaces, BigDecimal.ROUND_HALF_EVEN ); // System.out.println("ROUND finished result : "+bigDec); setValue( bigDec ); } else { setValue( Const.round( getNumber(), decimalPlaces ) ); } } else { throw new KettleValueException( "Function ROUND only works with a number" ); } return this; }