/** * Check whether this value is equal to the Integer supplied. * * @param number * The Integer to check for equality * @return true if the Integer representation of the value is equal to number. */ public boolean isEqualTo( long number ) { return getInteger() == number; }
/** * Check whether this value is equal to the Integer supplied. * * @param number * The Integer to check for equality * @return true if the Integer representation of the value is equal to number. */ public boolean isEqualTo( int number ) { return getInteger() == number; }
/** * Check whether this value is equal to the Integer supplied. * * @param number * The Integer to check for equality * @return true if the Integer representation of the value is equal to number. */ public boolean isEqualTo( byte number ) { return getInteger() == number; }
public Value xor( Value v ) { long n1 = getInteger(); long n2 = v.getInteger(); long res = n1 ^ n2; setValue( res ); return this; }
public Value and( Value v ) { long n1 = getInteger(); long n2 = v.getInteger(); long res = n1 & n2; setValue( res ); return this; }
public Value or( Value v ) { long n1 = getInteger(); long n2 = v.getInteger(); long res = n1 | n2; setValue( res ); return this; }
/** * Search for a value, if it doesn't occur in the row, return the default value. * * @param valuename * The valuename to look for * @param def * The default value to return * @return The long integer representation of the value found or the default */ public long getInteger( String valuename, long def ) { Value v = searchValue( valuename ); if ( v == null ) { return def; } return v.getInteger(); }
/** * Search for a value, if it doesn't occur in the row, return the default value. * * @param valuename * The valuename to look for * @param def * The default value to return * @return The short integer representation of the value found or the default */ public long getShort( String valuename, int def ) { Value v = searchValue( valuename ); if ( v == null ) { return def; } return (int) v.getInteger(); }
public static Long jsToInteger( Object value, Class<?> clazz ) { if ( Number.class.isAssignableFrom( clazz ) ) { return ( (Number) value ).longValue(); } else { String classType = clazz.getName(); if ( classType.equalsIgnoreCase( "java.lang.String" ) ) { return ( new Long( (String) value ) ); } else if ( classType.equalsIgnoreCase( "org.mozilla.javascript.Undefined" ) ) { return null; } else if ( classType.equalsIgnoreCase( "org.mozilla.javascript.NativeNumber" ) ) { Number nb = Context.toNumber( value ); return nb.longValue(); } else if ( classType.equalsIgnoreCase( "org.mozilla.javascript.NativeJavaObject" ) ) { // Is it a Value? // try { Value v = (Value) Context.jsToJava( value, Value.class ); return v.getInteger(); } catch ( Exception e2 ) { String string = Context.toString( value ); return Long.parseLong( Const.trim( string ) ); } } else { return Long.parseLong( value.toString() ); } } }
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; }
public Value minus( Value v ) throws KettleValueException { switch ( getType() ) { case VALUE_TYPE_BIGNUMBER: value.setBigNumber( getBigNumber().subtract( v.getBigNumber() ) ); break; case VALUE_TYPE_NUMBER: value.setNumber( getNumber() - v.getNumber() ); break; case VALUE_TYPE_INTEGER: value.setInteger( getInteger() - v.getInteger() ); break; case VALUE_TYPE_BOOLEAN: case VALUE_TYPE_STRING: default: throw new KettleValueException( "Subtraction can only be done with numbers!" ); } return this; }
public Value abs() throws KettleValueException { if ( isNull() ) { return this; } if ( isBigNumber() ) { setValue( getBigNumber().abs() ); } else if ( isNumber() ) { setValue( Math.abs( getNumber() ) ); } else if ( isInteger() ) { setValue( Math.abs( getInteger() ) ); } else { throw new KettleValueException( "Function ABS only works with a number" ); } return this; }
if ( getInteger() > 0 ) { value.setInteger( 1 ); } else if ( getInteger() < 0 ) { value.setInteger( -1 ); } else {
public Value divide( Value v ) throws KettleValueException { if ( isNull() || v.isNull() ) { setNull(); } else { switch ( getType() ) { case VALUE_TYPE_BIGNUMBER: setValue( getBigNumber().divide( v.getBigNumber(), BigDecimal.ROUND_HALF_UP ) ); break; case VALUE_TYPE_NUMBER: setValue( getNumber() / v.getNumber() ); break; case VALUE_TYPE_INTEGER: setValue( getInteger() / v.getInteger() ); break; case VALUE_TYPE_BOOLEAN: case VALUE_TYPE_STRING: default: throw new KettleValueException( "Division can only be done with numeric data!" ); } } return this; }
public Value plus( Value v ) { switch ( getType() ) { case VALUE_TYPE_BIGNUMBER: setValue( getBigNumber().add( v.getBigNumber() ) ); break; case VALUE_TYPE_NUMBER: setValue( getNumber() + v.getNumber() ); break; case VALUE_TYPE_INTEGER: setValue( getInteger() + v.getInteger() ); break; case VALUE_TYPE_BOOLEAN: setValue( getBoolean() | v.getBoolean() ); break; case VALUE_TYPE_STRING: setValue( getString() + v.getString() ); break; default: break; } return this; }
s = new StringBuilder( v.getString() ); append = v.getString(); n = (int) getInteger(); } else { s = new StringBuilder( getString() ); append = getString(); n = (int) v.getInteger(); } else if ( isInteger() || v.isInteger() ) { setValue( getInteger() * v.getInteger() ); } else { throw new KettleValueException( "Multiplication can only be done with numbers or a number and a string!" );
public Value dat2num() throws KettleValueException { if ( isNull() ) { setType( VALUE_TYPE_INTEGER ); return this; } if ( getType() == VALUE_TYPE_DATE ) { if ( getString() == null ) { setNull(); setValue( 0L ); } else { setValue( getInteger() ); } } else { throw new KettleValueException( "Function DAT2NUM works only on dates" ); } return this; }
/** * Convert this Value from type String to another type * * @param newtype * The Value type to convert to. */ public void convertString( int newtype ) throws KettleValueException { switch ( newtype ) { case VALUE_TYPE_STRING: break; case VALUE_TYPE_NUMBER: setValue( getNumber() ); break; case VALUE_TYPE_DATE: setValue( getDate() ); break; case VALUE_TYPE_BOOLEAN: setValue( getBoolean() ); break; case VALUE_TYPE_INTEGER: setValue( getInteger() ); break; case VALUE_TYPE_BIGNUMBER: setValue( getBigNumber() ); break; default: throw new KettleValueException( "Please specify the type to convert to from String type." ); } }
return value.getNumber(); case ValueMetaInterface.TYPE_INTEGER: return value.getInteger(); case ValueMetaInterface.TYPE_DATE: return value.getDate();
if ( getInteger() == 0l ) { setValue( other.getInteger() );