/** * Constructs a new Value with a name, a type, length and precision. * * @param name * Sets the name of the Value * @param valType * Sets the type of the Value (Value.VALUE_TYPE_*) * @param length * The length of the value * @param precision * The precision of the value */ public Value( String name, int valType, int length, int precision ) { this( name, valType ); setLength( length, precision ); }
setLength( dis.readInt(), dis.readInt() );
public Value lpad( int len, String padstr ) { if ( isNull() ) { setType( VALUE_TYPE_STRING ); } else { if ( getType() != VALUE_TYPE_STRING ) { // also lpad other types! setValue( getString() ); } if ( getString() != null ) { StringBuilder result = new StringBuilder( getString() ); int pad = len; int l = ( pad - result.length() ) / padstr.length() + 1; int i; for ( i = 0; i < l; i++ ) { result.insert( 0, padstr ); } // Maybe we added one or two too many! i = result.length(); while ( i > pad && pad > 0 ) { result.deleteCharAt( 0 ); i--; } setValue( result.toString() ); } else { setNull(); } } setLength( len ); return this; }
public Value rpad( int len, String padstr ) { if ( isNull() ) { setType( VALUE_TYPE_STRING ); } else { if ( getType() != VALUE_TYPE_STRING ) { // also rpad other types! setValue( getString() ); } if ( getString() != null ) { StringBuilder result = new StringBuilder( getString() ); int pad = len; int l = ( pad - result.length() ) / padstr.length() + 1; int i; for ( i = 0; i < l; i++ ) { result.append( padstr ); } // Maybe we added one or two too many! i = result.length(); while ( i > pad && pad > 0 ) { result.deleteCharAt( i - 1 ); i--; } setValue( result.toString() ); } else { setNull(); } } setLength( len ); 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; }
public Value str2dat( String arg0, String arg1 ) throws KettleValueException { if ( isNull() ) { setType( VALUE_TYPE_DATE ); } else { // System.out.println("Convert string ["+string+"] to date using pattern '"+arg0+"'"); SimpleDateFormat df = new SimpleDateFormat(); DateFormatSymbols dfs = new DateFormatSymbols(); if ( arg1 != null ) { dfs.setLocalPatternChars( arg1 ); } if ( arg0 != null ) { df.applyPattern( arg0 ); } try { value.setDate( df.parse( getString() ) ); setType( VALUE_TYPE_DATE ); setLength( -1, -1 ); } catch ( Exception e ) { setType( VALUE_TYPE_DATE ); setNull(); throw new KettleValueException( "TO_DATE Couldn't convert String to Date" + e.toString() ); } } return this; }
error_found = true; res.setLength( length[i], precision[i] );
error_found = true; res.setLength( length[i], precision[i] );
/** * 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 ); } }
setLength( len, prec );
public Value createOriginalValue( Object data ) throws KettleValueException { Value value = new Value( name, type ); value.setLength( length, precision );