Java Code Examples for org.pentaho.di.core.Const#rtrim()
The following examples show how to use
org.pentaho.di.core.Const#rtrim() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ValueMetaBase.java From pentaho-kettle with Apache License 2.0 | 6 votes |
protected String trim( String string ) { switch ( getTrimType() ) { case TRIM_TYPE_NONE: break; case TRIM_TYPE_RIGHT: string = Const.rtrim( string ); break; case TRIM_TYPE_LEFT: string = Const.ltrim( string ); break; case TRIM_TYPE_BOTH: string = Const.trim( string ); break; default: break; } return string; }
Example 2
Source File: Value.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public Value rtrim() { if ( isNull() ) { setType( VALUE_TYPE_STRING ); } else { String s; if ( getType() == VALUE_TYPE_STRING ) { s = Const.rtrim( getString() ); } else { s = Const.rtrim( toString() ); } setValue( s ); } return this; }
Example 3
Source File: XMLInputSaxDataRetriever.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void setValueToRow( String value, int fieldnr ) throws KettleValueException { XMLInputSaxField xmlInputField = fields.get( fieldnr ); switch ( xmlInputField.getTrimType() ) { case XMLInputSaxField.TYPE_TRIM_LEFT: value = Const.ltrim( value ); break; case XMLInputSaxField.TYPE_TRIM_RIGHT: value = Const.rtrim( value ); break; case XMLInputSaxField.TYPE_TRIM_BOTH: value = Const.trim( value ); break; default: break; } // DO CONVERSIONS... ValueMetaInterface targetValueMeta = data.outputRowMeta.getValueMeta( fieldnr ); ValueMetaInterface sourceValueMeta = data.convertRowMeta.getValueMeta( fieldnr ); row[fieldnr] = targetValueMeta.convertData( sourceValueMeta, value ); // Do we need to repeat this field if it is null? if ( xmlInputField.isRepeated() ) { if ( row[fieldnr] == null && data.previousRow != null ) { Object previous = data.previousRow[fieldnr]; row[fieldnr] = previous; } } }
Example 4
Source File: LDAPInput.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private Object getAttributeValue( LDAPInputField field, Attribute attr, int i, Object outputRowData ) throws Exception { if ( field.getType() == ValueMetaInterface.TYPE_BINARY ) { // It's a binary field // no need to convert, just return the value as it try { return attr.get(); } catch ( java.lang.ClassCastException e ) { return attr.get().toString().getBytes(); } } String retval = null; if ( field.getReturnType() == LDAPInputField.FETCH_ATTRIBUTE_AS_BINARY && field.getType() == ValueMetaInterface.TYPE_STRING ) { // Convert byte[] to string return LDAPConnection.extractBytesAndConvertToString( attr, field.isObjectSid() ); } // extract as string retval = extractString( attr ); // DO Trimming! switch ( field.getTrimType() ) { case LDAPInputField.TYPE_TRIM_LEFT: retval = Const.ltrim( retval ); break; case LDAPInputField.TYPE_TRIM_RIGHT: retval = Const.rtrim( retval ); break; case LDAPInputField.TYPE_TRIM_BOTH: retval = Const.trim( retval ); break; default: break; } // DO CONVERSIONS... // ValueMetaInterface targetValueMeta = data.outputRowMeta.getValueMeta( i ); ValueMetaInterface sourceValueMeta = data.convertRowMeta.getValueMeta( i ); return targetValueMeta.convertData( sourceValueMeta, retval ); }
Example 5
Source File: Value.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * Compare 2 values of the same or different type! * * @param v * the value to compare with. * @param caseInsensitive * True if you want the comparison to be case insensitive * @return -1 if The value was smaller, 1 bigger and 0 if both values are equal. */ public int compare( Value v, boolean caseInsensitive ) { boolean n1 = isNull() || ( isString() && ( getString() == null || getString().length() == 0 ) ) || ( isDate() && getDate() == null ) || ( isBigNumber() && getBigNumber() == null ); boolean n2 = v.isNull() || ( v.isString() && ( v.getString() == null || v.getString().length() == 0 ) ) || ( v.isDate() && v.getDate() == null ) || ( v.isBigNumber() && v.getBigNumber() == null ); // null is always smaller! if ( n1 && !n2 ) { return -1; } if ( !n1 && n2 ) { return 1; } if ( n1 && n2 ) { return 0; } switch ( getType() ) { case VALUE_TYPE_STRING: { String one = Const.rtrim( getString() ); String two = Const.rtrim( v.getString() ); int cmp = 0; if ( caseInsensitive ) { cmp = one.compareToIgnoreCase( two ); } else { cmp = one.compareTo( two ); } return cmp; } case VALUE_TYPE_INTEGER: { return Double.compare( getNumber(), v.getNumber() ); } case VALUE_TYPE_DATE: { return Double.compare( getNumber(), v.getNumber() ); } case VALUE_TYPE_BOOLEAN: { if ( getBoolean() && v.getBoolean() || !getBoolean() && !v.getBoolean() ) { return 0; // true == true, false == false } if ( getBoolean() && !v.getBoolean() ) { return 1; // true > false } return -1; // false < true } case VALUE_TYPE_NUMBER: { return Double.compare( getNumber(), v.getNumber() ); } case VALUE_TYPE_BIGNUMBER: { return getBigNumber().compareTo( v.getBigNumber() ); } default: break; } // Still here? Not possible! But hey, give back 0, mkay? return 0; }
Example 6
Source File: ValueDataUtil.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * @deprecated Use {@link Const#rtrim(String)} instead */ @Deprecated public static final String rightTrim( String string ) { return Const.rtrim( string ); }