public static final int getOperator( String description ) { if ( description == null ) { return OPERATOR_NONE; } for ( int i = 1; i < operators.length; i++ ) { if ( operators[i].equalsIgnoreCase( Const.trim( description ) ) ) { return i; } } return OPERATOR_NONE; }
public static final int getFunction( String description ) { for ( int i = 1; i < functions.length; i++ ) { if ( functions[i].equalsIgnoreCase( Const.trim( description ) ) ) { return i; } } return FUNC_EQUAL; }
/** * Trims a string: removes the leading and trailing spaces of a String. * * @param string * The string to trim * @return The trimmed string. * @deprecated Use {@link Const#trim(String)} instead */ @Deprecated public static final String trim( String string ) { return Const.trim( string ); }
private String MysqlString( String listcolumns ) { /* * handle forbiden char like ' */ String ReturnString = ""; String[] split = listcolumns.split( "," ); for ( int i = 0; i < split.length; i++ ) { if ( ReturnString.equals( "" ) ) { ReturnString = "`" + Const.trim( split[i] ) + "`"; } else { ReturnString = ReturnString + ", `" + Const.trim( split[i] ) + "`"; } } return ReturnString; }
private String MysqlString( String listcolumns ) { /* * Handle forbiden char like ' */ String returnString = ""; String[] split = listcolumns.split( "," ); for ( int i = 0; i < split.length; i++ ) { if ( returnString.equals( "" ) ) { returnString = "`" + Const.trim( split[i] ) + "`"; } else { returnString = returnString + ", `" + Const.trim( split[i] ) + "`"; } } return returnString; }
public static String trim( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext ) { String sRC = ""; if ( ArgList.length == 1 ) { try { if ( isNull( ArgList[0] ) ) { return null; } else if ( isUndefined( ArgList[0] ) ) { return (String) undefinedValue; } sRC = (String) ArgList[0]; sRC = Const.trim( sRC ); } catch ( Exception e ) { throw new RuntimeException( "The function call trim is not valid : " + e.getMessage() ); } } else { throw new RuntimeException( "The function call trim requires 1 argument." ); } return sRC; }
public String getRealMaximumTimeout() { return Const.trim( environmentSubstitute( getMaximumTimeout() ) ); }
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 void guessTrimType() { boolean spaces_before = false; boolean spaces_after = false; for ( int i = 0; i < samples.length; i++ ) { spaces_before |= Const.nrSpacesBefore( samples[i] ) > 0; spaces_after |= Const.nrSpacesAfter( samples[i] ) > 0; samples[i] = Const.trim( samples[i] ); } trimtype = ValueMetaInterface.TRIM_TYPE_NONE; if ( spaces_before ) { trimtype |= ValueMetaInterface.TRIM_TYPE_LEFT; } if ( spaces_after ) { trimtype |= ValueMetaInterface.TRIM_TYPE_RIGHT; } }
public static Number jsToNumber( Object value, String classType ) { if ( classType.equalsIgnoreCase( "org.mozilla.javascript.Undefined" ) ) { return null; } else if ( classType.equalsIgnoreCase( "org.mozilla.javascript.NativeJavaObject" ) ) { try { // Is it a java Value class ? Value v = (Value) Context.jsToJava( value, Value.class ); return v.getNumber(); } catch ( Exception e ) { String string = Context.toString( value ); return Double.parseDouble( Const.trim( string ) ); } } else if ( classType.equalsIgnoreCase( "org.mozilla.javascript.NativeNumber" ) ) { Number nb = Context.toNumber( value ); return nb.doubleValue(); } else { Number nb = (Number) value; return nb.doubleValue(); } }
public void guessTrimType() { boolean spaces_before = false; boolean spaces_after = false; for ( int i = 0; i < samples.length; i++ ) { spaces_before |= Const.nrSpacesBefore( samples[i] ) > 0; spaces_after |= Const.nrSpacesAfter( samples[i] ) > 0; samples[i] = Const.trim( samples[i] ); } trimtype = ValueMetaInterface.TRIM_TYPE_NONE; if ( spaces_before ) { trimtype |= ValueMetaInterface.TRIM_TYPE_LEFT; } if ( spaces_after ) { trimtype |= ValueMetaInterface.TRIM_TYPE_RIGHT; } }
/** * Return the input string trimmed as specified. * * @param string * String to be trimmed * @param trimType * Type of trimming * * @return Trimmed string. */ public static String trimToType( String string, int trimType ) { switch ( trimType ) { case ValueMetaInterface.TRIM_TYPE_BOTH: return trim( string ); case ValueMetaInterface.TRIM_TYPE_LEFT: return ltrim( string ); case ValueMetaInterface.TRIM_TYPE_RIGHT: return rtrim( string ); case ValueMetaInterface.TRIM_TYPE_NONE: default: return string; } }
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; }
public void prepareFieldNamesParameters( String[] parameters, String[] parameterFieldNames, String[] parameterValues, NamedParams namedParam, JobEntryTrans jobEntryTrans ) throws UnknownParamException { for ( int idx = 0; idx < parameters.length; idx++ ) { // Grab the parameter value set in the Trans job entry // Set fieldNameParameter only if exists and if it is not declared any staticValue( parameterValues array ) // String thisValue = namedParam.getParameterValue( parameters[ idx ] ); // Set value only if is not empty at namedParam and exists in parameterFieldNames if ( !Utils.isEmpty( thisValue ) && idx < parameterFieldNames.length ) { // If exists then ask if is not empty if ( !Utils.isEmpty( Const.trim( parameterFieldNames[ idx ] ) ) ) { // If is not empty then we have to ask if it exists too in parameterValues array, since the values in // parameterValues prevail over parameterFieldNames if ( idx < parameterValues.length ) { // If is empty at parameterValues array, then we can finally add that variable with that value if ( Utils.isEmpty( Const.trim( parameterValues[ idx ] ) ) ) { jobEntryTrans.setVariable( parameters[ idx ], thisValue ); } } else { // Or if not in parameterValues then we can add that variable with that value too jobEntryTrans.setVariable( parameters[ idx ], thisValue ); } } } } }
/** * Performs a right and left trim of spaces in the string. If the value is not a string a conversion to String is * performed first. * * @return The trimmed string value. */ public Value trim() { if ( isNull() ) { setType( VALUE_TYPE_STRING ); return this; } String str = Const.trim( getString() ); setValue( str ); return this; }
public static String trim( Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext ) { String sRC = ""; if ( ArgList.length == 1 ) { try { if ( isNull( ArgList[0] ) ) { return null; } else if ( isUndefined( ArgList[0] ) ) { return (String) Context.getUndefinedValue(); } sRC = Context.toString( ArgList[0] ); sRC = Const.trim( sRC ); } catch ( Exception e ) { throw Context.reportRuntimeError( "The function call trim is not valid : " + e.getMessage() ); } } else { throw Context.reportRuntimeError( "The function call trim requires 1 argument." ); } return sRC; }
break; case LDAPInputField.TYPE_TRIM_BOTH: retval = Const.trim( retval ); break; default:
public void cleanupLogRecords( LogTableCoreInterface logTable ) throws KettleDatabaseException { double timeout = Const.toDouble( Const.trim( environmentSubstitute( logTable.getTimeoutInDays() ) ), 0.0 ); if ( timeout < 0.000001 ) {
@Override public void readRep( Repository rep, ObjectId id_step, List<DatabaseMeta> databases, Map<String, Counter> counters ) throws KettleException { try { String name = rep.getStepAttributeString( id_step, 0, "value_name" ); String typedesc = rep.getStepAttributeString( id_step, 0, "value_type" ); String text = rep.getStepAttributeString( id_step, 0, "value_text" ); boolean isnull = rep.getStepAttributeBoolean( id_step, 0, "value_null" ); int length = (int) rep.getStepAttributeInteger( id_step, 0, "value_length" ); int precision = (int) rep.getStepAttributeInteger( id_step, 0, "value_precision" ); int type = ValueMetaFactory.getIdForValueMeta( typedesc ); value = new ValueMetaAndData( new ValueMeta( name, type ), null ); value.getValueMeta().setLength( length ); value.getValueMeta().setPrecision( precision ); if ( isnull ) { value.setValueData( null ); } else { ValueMetaInterface stringMeta = new ValueMetaString( name ); if ( type != ValueMetaInterface.TYPE_STRING ) { text = Const.trim( text ); } value.setValueData( value.getValueMeta().convertData( stringMeta, text ) ); } } catch ( KettleDatabaseException dbe ) { throw new KettleException( "error reading step with id_step=" + id_step + " from the repository", dbe ); } catch ( Exception e ) { throw new KettleException( "Unexpected error reading step with id_step=" + id_step + " from the repository", e ); } }