org.pentaho.di.core.Const.trim()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(172)

本文整理了Java中org.pentaho.di.core.Const.trim()方法的一些代码示例,展示了Const.trim()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Const.trim()方法的具体详情如下:
包路径:org.pentaho.di.core.Const
类名称:Const
方法名:trim

Const.trim介绍

[英]Trims a string: removes the leading and trailing spaces of a String.
[中]修剪字符串:删除字符串的前导空格和尾随空格。

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

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;
}

代码示例来源:origin: pentaho/pentaho-kettle

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;
}

代码示例来源:origin: pentaho/pentaho-kettle

/**
 * 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 );
}

代码示例来源:origin: pentaho/pentaho-kettle

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;
}

代码示例来源:origin: pentaho/pentaho-kettle

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;
}

代码示例来源:origin: pentaho/pentaho-kettle

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;
}

代码示例来源:origin: pentaho/pentaho-kettle

public String getRealMaximumTimeout() {
 return Const.trim( environmentSubstitute( getMaximumTimeout() ) );
}

代码示例来源:origin: pentaho/pentaho-kettle

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() );
  }
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

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;
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

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();
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

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;
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

/**
 * 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;
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

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;
}

代码示例来源:origin: pentaho/pentaho-kettle

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 );
    }
   }
  }
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

/**
 * 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;
}

代码示例来源:origin: pentaho/pentaho-kettle

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;
}

代码示例来源:origin: pentaho/pentaho-kettle

fieldNames[ i ] = Const.trim( fieldNames[ i ] );
if ( !meta.hasHeader() ) {
 final DecimalFormat df = new DecimalFormat( "000" );
fieldNames[ i ] = Const.trim( fieldNames[ i ] );
fieldNames[ i ] = massageFieldName( fieldNames[ i ] );

代码示例来源:origin: pentaho/pentaho-kettle

break;
case LDAPInputField.TYPE_TRIM_BOTH:
 retval = Const.trim( retval );
 break;
default:

代码示例来源:origin: pentaho/pentaho-kettle

public void cleanupLogRecords( LogTableCoreInterface logTable ) throws KettleDatabaseException {
 double timeout = Const.toDouble( Const.trim( environmentSubstitute( logTable.getTimeoutInDays() ) ), 0.0 );
 if ( timeout < 0.000001 ) {

代码示例来源:origin: pentaho/pentaho-kettle

@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 );
 }
}

相关文章