/** * Sets the Value to null, no type is being changed. * */ public void setNull() { setNull( true ); }
/** * Sets the Value to a byte array * * @param b * The byte array to which the Value has to be set. */ public void setValue( byte[] b ) { if ( value == null || value.getType() != VALUE_TYPE_BINARY ) { value = new ValueBinary( b ); } else { value.setBytes( b ); } if ( b == null ) { setNull( true ); } else { setNull( false ); } }
/** * Sets the Value to a String text * * @param str * The StringBuilder to get the text from */ public void setValue( StringBuilder str ) { if ( value == null || value.getType() != VALUE_TYPE_STRING ) { value = new ValueString( str.toString() ); } else { value.setString( str.toString() ); } setNull( str == null ); }
/** * Sets the Value to a String text * * @param str * The StringBuffer to get the text from */ public void setValue( StringBuffer str ) { if ( value == null || value.getType() != VALUE_TYPE_STRING ) { value = new ValueString( str.toString() ); } else { value.setString( str.toString() ); } setNull( str == null ); }
public void setSerializedValue( Serializable ser ) { if ( value == null || value.getType() != VALUE_TYPE_SERIALIZABLE ) { value = new ValueSerializable( ser ); } else { value.setSerializable( ser ); } setNull( ser == null ); }
/** * Sets the Value to a boolean * * @param bool * The boolean to set the Value to */ public void setValue( boolean bool ) { if ( value == null || value.getType() != VALUE_TYPE_BOOLEAN ) { value = new ValueBoolean( bool ); } else { value.setBoolean( bool ); } setNull( false ); }
/** * Sets the value to a BigDecimal number value. * * @param num * The number value to set the value to */ public void setValue( BigDecimal num ) { if ( value == null || value.getType() != VALUE_TYPE_BIGNUMBER ) { value = new ValueBigNumber( num ); } else { value.setBigNumber( num ); } setNull( false ); }
/** * Sets the value to a double Number value. * * @param num * The number value to set the value to */ public void setValue( double num ) { if ( value == null || value.getType() != VALUE_TYPE_NUMBER ) { value = new ValueNumber( num ); } else { value.setNumber( num ); } setNull( false ); }
/** * Sets the Value to a String text * * @param str * The String to get the text from */ public void setValue( String str ) { if ( value == null || value.getType() != VALUE_TYPE_STRING ) { value = new ValueString( str ); } else { value.setString( str ); } setNull( str == null ); }
/** * Sets the Value to a long integer * * @param l * The long integer to which the Value is set. */ public void setValue( long l ) { if ( value == null || value.getType() != VALUE_TYPE_INTEGER ) { value = new ValueInteger( l ); } else { value.setInteger( l ); } setNull( false ); }
/** * Sets the Value to a Date * * @param dat * The Date to set the Value to */ public void setValue( Date dat ) { if ( value == null || value.getType() != VALUE_TYPE_DATE ) { value = new ValueDate( dat ); } else { value.setDate( dat ); } setNull( dat == null ); }
public Value startsWith( String string ) { if ( isNull() ) { setType( VALUE_TYPE_BOOLEAN ); return this; } if ( string == null ) { setValue( false ); setNull(); return this; } setValue( getString().startsWith( string ) ); return this; }
/** * Copy the Value from another Value. It doesn't copy the name. * * @param v * The Value to copy the settings and value from */ public void setValue( Value v ) { if ( v != null ) { value = v.getValueCopy(); setNull( v.isNull() ); setOrigin( v.origin ); } else { clearValue(); } }
public Value replace( String repl, String with ) { if ( isNull() ) { return this; } if ( getString() == null ) { setNull(); } else { setValue( Const.replace( getString(), repl, with ) ); } return this; }
public Value initcap() { if ( isNull() ) { return this; } if ( getString() == null ) { setNull(); } else { setValue( Const.initCap( getString() ) ); } return this; }
/** * Constructs a new Value as a copy of another value * * @param v * The Value to be copied */ public Value( Value v ) { if ( v != null ) { // setType(v.getType()); // Is this really needed??? value = v.getValueCopy(); setName( v.getName() ); setLength( v.getLength(), v.getPrecision() ); setNull( v.isNull() ); setOrigin( v.origin ); } else { clearValue(); setNull( true ); } }
public Value substr( int from, int to ) { if ( isNull() ) { setType( VALUE_TYPE_STRING ); return this; } setValue( getString() ); if ( getString() != null ) { if ( to < 0 && from >= 0 ) { setValue( getString().substring( from ) ); } else if ( to >= 0 && from >= 0 ) { setValue( getString().substring( from, to ) ); } } else { setNull(); } if ( !isString() ) { setType( VALUE_TYPE_STRING ); } return this; }
public Value v_if( Value[] args ) throws KettleValueException { if ( getType() == VALUE_TYPE_BOOLEAN ) { if ( args.length == 1 ) { if ( getBoolean() ) { setValue( args[0] ); } else { setNull(); } } else if ( args.length == 2 ) { if ( getBoolean() ) { setValue( args[0] ); } else { setValue( args[1] ); } } } else { throw new KettleValueException( "Function DECODE can't have " + args.length + " arguments!" ); } return this; }
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; }
public Value ltrim() { if ( isNull() ) { setType( VALUE_TYPE_STRING ); } else { if ( getString() != null ) { String s; if ( getType() == VALUE_TYPE_STRING ) { s = Const.ltrim( getString() ); } else { s = Const.ltrim( toString() ); } setValue( s ); } else { setNull(); } } return this; }