当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.removeEnd方法代码示例

本文整理汇总了Java中org.apache.commons.lang.StringUtils.removeEnd方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.removeEnd方法的具体用法?Java StringUtils.removeEnd怎么用?Java StringUtils.removeEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang.StringUtils的用法示例。


在下文中一共展示了StringUtils.removeEnd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSonArrays

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * 根据字节数组拆分若干个字字节数组
 * @param data    待拆分数组
 * @param separator 分割数组
 * @return 
 */
public byte[][] getSonArrays(byte[] data,byte[] separator)
{
	if(data==null||data.length<=0||separator==null||separator.length<=0)
	{
		System.out.println("data||separator数据无效!");
		return null;
	}
	String[] dataHexArray=toHexArray(data);
	String dataHexStr=StringUtils.substringBetween(Arrays.toString(dataHexArray), "[", "]").replaceAll("\\s","");
	//System.out.println("待拆分字符串:"+dataHexStr);
	String[] separatorHexhArray=toHexArray(separator);
	String separatorHexStr=StringUtils.substringBetween(Arrays.toString(separatorHexhArray), "[", "]").replaceAll("\\s","");
	//System.out.println("字符串拆分符:"+separatorHexStr);
	//得到拆分后的数组
	String[] arrays=StringUtils.splitByWholeSeparator(dataHexStr, separatorHexStr);
	//System.out.println("拆分后的数组:"+Arrays.toString(arrays));
	if(arrays==null||arrays.length<=0)
	{
		System.out.println("注意:数组拆分为0");
		return null;
	}
	byte[][] result=new byte[arrays.length][];
	//对子数组进行重组
	for(int i=0;i<arrays.length;i++)
	{
		String arrayStr=arrays[i];
		arrayStr=StringUtils.removeStart(arrayStr, ",");//去掉两端的逗号
		arrayStr=StringUtils.removeEnd(arrayStr, ",");//去掉两端的逗号
		String[] array=arrayStr.split(",");//根据子字符串中间剩余的逗号重组为hex字符串
		result[i]=toBtyeArray(array);
	}
	return result;
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:40,代码来源:HexStrBytes.java

示例2: getsonArrays

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * 根据字节数组拆分若干个字字节数组
 * @param data
 * @param separator
 * @return
 */
public byte[][] getsonArrays(byte[] data,byte[] separator)
{
	if(data==null||data.length<=0||separator==null||separator.length<=0)
	{
		System.out.println("data||separator数据无效!");
		return null;
	}
	String[] dataHexArray=byteArrayToHexArray(data);
	String dataHexStr=StringUtils.substringBetween(Arrays.toString(dataHexArray), "[", "]").replaceAll("\\s","");
	//System.out.println("待拆分字符串:"+dataHexStr);
	String[] separatorHexhArray=byteArrayToHexArray(separator);
	String separatorHexStr=StringUtils.substringBetween(Arrays.toString(separatorHexhArray), "[", "]").replaceAll("\\s","");
	//System.out.println("字符串拆分符:"+separatorHexStr);
	//得到拆分后的数组
	String[] arrays=StringUtils.splitByWholeSeparator(dataHexStr, separatorHexStr);
	//System.out.println("拆分后的数组:"+Arrays.toString(arrays));
	if(arrays==null||arrays.length<=0)
	{
		System.out.println("注意:数组拆分为0");
		return null;
	}
	byte[][] result=new byte[arrays.length][];
	//对子数组进行重组
	for(int i=0;i<arrays.length;i++)
	{
		String arrayStr=arrays[i];
		arrayStr=StringUtils.removeStart(arrayStr, ",");//去掉两端的逗号
		arrayStr=StringUtils.removeEnd(arrayStr, ",");//去掉两端的逗号
		String[] array=arrayStr.split(",");//根据子字符串中间剩余的逗号重组为hex字符串
		result[i]=hexArrayToBtyeArray(array);
	}
	return result;
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:40,代码来源:DataTools.java

示例3: unpackFile

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private File unpackFile(HttpPipeKey key) {
    Pipeline pipeline = configClientService.findPipeline(key.getIdentity().getPipelineId());
    DataRetriever dataRetriever = dataRetrieverFactory.createRetriever(pipeline.getParameters().getRetriever(),
                                                                       key.getUrl(), downloadDir);
    File archiveFile = null;
    try {
        dataRetriever.connect();
        dataRetriever.doRetrieve();
        archiveFile = dataRetriever.getDataAsFile();
    } catch (Exception e) {
        dataRetriever.abort();
        throw new PipeException("download_error", e);
    } finally {
        dataRetriever.disconnect();
    }

    // 处理下有加密的数据
    if (StringUtils.isNotEmpty(key.getKey()) && StringUtils.isNotEmpty(key.getCrc())) {
        decodeFile(archiveFile, key.getKey(), key.getCrc());
    }

    // 去除末尾的.gzip后缀,做为解压目录
    String dir = StringUtils.removeEnd(archiveFile.getPath(),
                                       FilenameUtils.EXTENSION_SEPARATOR_STR
                                               + FilenameUtils.getExtension(archiveFile.getPath()));
    File unpackDir = new File(dir);
    // 开始解压
    getArchiveBean().unpack(archiveFile, unpackDir);
    return unpackDir;
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:31,代码来源:AttachmentHttpPipe.java

示例4: getLoadTypePrimaryKeyUIValue

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Appends primary keys using a comma
 * @param newTable
 */
private String getLoadTypePrimaryKeyUIValue(TypePrimaryKeys newTable) {
	StringBuffer stringBuffer = new StringBuffer();
	if(newTable !=null && newTable.getPrimaryKeys() !=null){
		TypeKeyFields typeKeyFields = newTable.getPrimaryKeys();
		for(TypeFieldName typeFieldName : typeKeyFields.getField()){
			stringBuffer.append(typeFieldName.getName());
			stringBuffer.append(",");
		}
	}
	return StringUtils.removeEnd(stringBuffer.toString(), ",");
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:16,代码来源:OutputMysqlUiConverter.java

示例5: getLoadTypeUpdateKeyUIValue

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 *  Appends update keys using a comma
 * @param update
 */
private String getLoadTypeUpdateKeyUIValue(TypeUpdateKeys update) {
	StringBuffer buffer=new StringBuffer();
		if(update!=null && update.getUpdateByKeys()!=null){
			TypeKeyFields keyFields=update.getUpdateByKeys();
			for(TypeFieldName fieldName:keyFields.getField()){
				buffer.append(fieldName.getName());
				buffer.append(",");
				}
		}
	
	return StringUtils.removeEnd(buffer.toString(), ",");
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:17,代码来源:OutputMysqlUiConverter.java

示例6: getLoadTypeUpdateKeyUIValue

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 *  Appends update keys using a comma
 * @param update
 */
private String getLoadTypeUpdateKeyUIValue(TypeUpdateKeys update) {
	StringBuffer buffer=new StringBuffer();
		if(update!=null && update.getUpdateByKeys()!=null){
			TypeKeyFields keyFields=update.getUpdateByKeys();
			for(TypeFieldName fieldName:keyFields.getField()){
				buffer.append(fieldName.getName());
				buffer.append(",");
				}
		}
	return StringUtils.removeEnd(buffer.toString(), ",");
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:16,代码来源:OutputTeradataUiConverter.java

示例7: getLoadTypePrimaryKeyUIValue

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 *  Appends primary keys using a comma
 * @param newTable
 * @return
 */
private String getLoadTypePrimaryKeyUIValue(TypePrimaryKeys newTable) {
	StringBuffer stringBuffer = new StringBuffer();
	if(newTable !=null && newTable.getPrimaryKeys() !=null){
		TypeKeyFields typeKeyFields = newTable.getPrimaryKeys();
		for(TypeFieldName typeFieldName : typeKeyFields.getField()){
			stringBuffer.append(typeFieldName.getName());
			stringBuffer.append(",");
		}
	}
	return StringUtils.removeEnd(stringBuffer.toString(), ",");
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:17,代码来源:OutputRedshiftUiConverter.java

示例8: getLoadTypeUpdateKeyUIValue

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 *  Appends update keys using a comma
 * @param update
 * @return
 */
private String getLoadTypeUpdateKeyUIValue(TypeUpdateKeys update) {
	StringBuffer buffer=new StringBuffer();
		if(update!=null && update.getUpdateByKeys()!=null){
			TypeKeyFields keyFields=update.getUpdateByKeys();
			for(TypeFieldName fieldName:keyFields.getField()){
				buffer.append(fieldName.getName());
				buffer.append(",");
				}
		}
	
	return StringUtils.removeEnd(buffer.toString(), ",");
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:18,代码来源:OutputRedshiftUiConverter.java

示例9: getUpdateKeyUIValue

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 *  Appends update keys using a comma
 * @param typeUpdateKeys
 */
private String getUpdateKeyUIValue(TypeUpdateKeys typeUpdateKeys) {
	StringBuffer buffer=new StringBuffer();
		if(typeUpdateKeys!=null && typeUpdateKeys.getUpdateByKeys()!=null){
			TypeKeyFields keyFields=typeUpdateKeys.getUpdateByKeys();
			for(TypeFieldName fieldName:keyFields.getField()){
				buffer.append(fieldName.getName());
				buffer.append(",");
				}
		}
	
	return StringUtils.removeEnd(buffer.toString(), ",");
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:17,代码来源:OutputDBUpdateUiConverter.java

示例10: getReleaseVersion

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public VersionPolicyResult getReleaseVersion(final VersionPolicyRequest versionPolicyRequest)
        throws PolicyException, VersionParseException {
    final String version = versionPolicyRequest.getVersion();
    final String cleanedVersion = StringUtils.removeEnd(version, snapshotPostfix);
    final String majorVersionComponent = StringUtils.substringBefore(cleanedVersion, ".");

    final String releaseVersion = matchesYear(majorVersionComponent, currentYear) ? cleanedVersion : firstOfYear();

    return new VersionPolicyResult()
            .setVersion(releaseVersion);
}
 
开发者ID:ncredinburgh,项目名称:maven-release-yearly-policy,代码行数:15,代码来源:YearlyVersionPolicy.java

示例11: getWhereClause

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Build the where clause part of a SugarCRM query.
 *
 *  @param predicates The json predicates.
 *  @return The formatted query.
 */
public static String getWhereClause(List<JsonPredicate> predicates) {
    if ((predicates == null) || (predicates.size() == 0)) {
        return StringUtils.EMPTY;
    }

    StringBuilder queryBuilder = new StringBuilder();
    String subQuery = StringUtils.EMPTY;
    for (JsonPredicate predicate : predicates)
    {
        switch(predicate.operator) {
            case Equal:
                subQuery = predicate.isNumeric ? String.format("%s = %s", predicate.jsonName, predicate.value) : String.format("%s = '%s'", predicate.jsonName, predicate.value);
                break;

            case GreaterThan:
                subQuery = predicate.isNumeric ? String.format("%s > %s", predicate.jsonName, predicate.value) : String.format("%s > '%s'", predicate.jsonName, predicate.value);
                break;

            case GreaterThanOrEqualTo:
                subQuery = predicate.isNumeric ? String.format("%s >= %s", predicate.jsonName, predicate.value) : String.format("%s >= '%s'", predicate.jsonName, predicate.value);
                break;

            case LessThan:
                subQuery = predicate.isNumeric ? String.format("%s < %s", predicate.jsonName, predicate.value) : String.format("%s < '%s'", predicate.jsonName, predicate.value);
                break;

            case LessThanOrEqualTo:
                subQuery = predicate.isNumeric ? String.format("%s <= %s", predicate.jsonName, predicate.value) : String.format("%s <= '%s'", predicate.jsonName, predicate.value);
                break;

            case Contains:
                subQuery = predicate.jsonName + " LIKE '%" + predicate.value + "%'";
                break;

            case StartsWith:
                subQuery = predicate.jsonName + " LIKE '" + predicate.value + "%'";
                break;

            case EndsWith:
                subQuery = predicate.jsonName + " LIKE '%" + predicate.value + "'";
                break;

            case Between:
                subQuery = predicate.isNumeric ? String.format("%s BETWEEN %s AND %s", predicate.jsonName, predicate.fromValue, predicate.toValue) : String.format("%s BETWEEN '%s' AND '%s'", predicate.jsonName, predicate.fromValue, predicate.toValue);
                break;

            case WhereIn:
                subQuery = String.format("%s IN (%s)", predicate.jsonName, predicate.value);
                break;
        }

        queryBuilder.append(subQuery);
        queryBuilder.append(" AND ");
    }

    String query = queryBuilder.toString();
    if (!StringUtils.isNotBlank(query))
    {
        return StringUtils.EMPTY;
    }

    query = StringUtils.removeEnd(query.trim(),"AND");
    query = " " + query.trim() + " ";
    return query;
}
 
开发者ID:mattkol,项目名称:SugarOnRest,代码行数:72,代码来源:QueryBuilder.java

示例12: readBulkWithQuery2Test

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@Test
public void readBulkWithQuery2Test() {

    SugarRestRequest request = new SugarRestRequest("Leads", RequestType.BulkRead);
    request.setUrl(TestAccount.Url);
    request.setUsername(TestAccount.Username);
    request.setPassword(TestAccount.Password);

    request.getOptions().setMaxResult(10);

    SugarRestClient client = new SugarRestClient();
    SugarRestResponse response = client.execute(request);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    List<Leads> readLeads = (List<Leads>)response.getData();
    assertNotNull(readLeads);

    // Read back with query
    // Get all identifiers
    List<String> identifiers = new ArrayList<String>();
    for (Leads lead : readLeads) {
        identifiers.add(lead.getId());
    }

    // Reset options
    request.setOptions(new Options());
    List<QueryPredicate> queryPredicates = new ArrayList<QueryPredicate>();

    // Set query in this format:
    // "leads.id IN('10d82d59-08eb-8f0d-28e0-5777b57af47c', '12037cd0-ead2-402e-e1d0-5777b5dfb965', '13d4109d-c5ca-7dd1-99f1-5777b57ef30f', '14c136e5-1a67-eeba-581c-5777b5c8c463', '14e4825e-9573-4d75-2dbe-5777b5b7ee85', '1705b33a-3fad-aa70-77ef-5777b5b081f1', '171c1d8b-e34f-3a1f-bef7-5777b5ecc823', '174a8fc4-56e6-3471-46d8-5777b565bf5b', '17c9c496-90a1-02f5-87bd-5777b51ab086', '1d210352-7a1f-2c5d-04ae-5777b5a3312f')");

    StringBuilder builder = new StringBuilder();
    for (String id : identifiers) {
        builder.append(" '" + id + "', ");
    }
    String builderResult = builder.toString().trim();
    builderResult = StringUtils.removeEnd(builderResult, ",");
    String query = "leads.id IN(" + builderResult + ")";

    // Since query is set, the query predicates will be ignore.
    request.getOptions().setQuery(query);
    queryPredicates.add(new QueryPredicate("last_name", Equal, "Johnson"));
    request.getOptions().setQueryPredicates(queryPredicates);

    response = client.execute(request);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    List<Leads> readLeadsWithQuery = (List<Leads>)response.getData();
    assertNotNull(readLeadsWithQuery);

    assertEquals(identifiers.size(), readLeads.size());
    assertEquals(identifiers.size(), readLeadsWithQuery.size());
    assertEquals(readLeads.size(), readLeadsWithQuery.size());
}
 
开发者ID:mattkol,项目名称:SugarOnRest,代码行数:59,代码来源:QueryTests.java

示例13: trim

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * 
 * This function will trim the given input string. It will not only remove the spaces and tabs at
 * the end but also compress multiple spaces and tabs to a single space
 * 
 * @param input The input string on which the trim operation needs to be performed
 * @param retainLineSeparator whether to retain the line separator.
 * 
 * @return String
 */
public static TrimmedInput trim(final String input, final boolean retainLineSeparator) {
  if (input != null) {
    String inputCopy = input;
    StringBuffer output = new StringBuffer();
    // First remove the trailing white spaces, we do not need those
    inputCopy = StringUtils.stripEnd(inputCopy, null);
    // As this parser is for optionParsing, we also need to remove
    // the trailing optionSpecifiers provided it has previous
    // options. Remove the trailing LONG_OPTION_SPECIFIERs
    // in a loop. It is necessary to check for previous options for
    // the case of non-mandatory arguments.
    // "^(.*)(\\s-+)$" - something that ends with a space followed by a series of hyphens.
    while (Pattern.matches("^(.*)(\\s-+)$", inputCopy)) {
      inputCopy = StringUtils.removeEnd(inputCopy, SyntaxConstants.SHORT_OPTION_SPECIFIER);

      // Again we need to trim the trailing white spaces
      // As we are in a loop
      inputCopy = StringUtils.stripEnd(inputCopy, null);
    }
    // Here we made use of the String class function trim to remove the
    // space and tabs if any at the
    // beginning and the end of the string
    int noOfSpacesRemoved = 0;
    {
      int length = inputCopy.length();
      inputCopy = inputCopy.trim();
      noOfSpacesRemoved += length - inputCopy.length();
    }
    // Now we need to compress the multiple spaces and tabs to single space
    // and tabs but we also need to ignore the white spaces inside the
    // quotes and parentheses

    StringBuffer buffer = new StringBuffer();

    boolean startWhiteSpace = false;
    for (int i = 0; i < inputCopy.length(); i++) {
      char ch = inputCopy.charAt(i);
      buffer.append(ch);
      if (PreprocessorUtils.isWhitespace(ch)) {
        if (PreprocessorUtils.isSyntaxValid(buffer.toString())) {
          if (startWhiteSpace) {
            noOfSpacesRemoved++;
          } else {
            startWhiteSpace = true;
            if (ch == '\n') {
              if (retainLineSeparator) {
                output.append("\n");
              }
            } else {
              output.append(" ");
            }
          }
          buffer.delete(0, buffer.length());
        } else {
          output.append(ch);
        }
      } else {
        startWhiteSpace = false;
        output.append(ch);
      }
    }
    return new TrimmedInput(output.toString(), noOfSpacesRemoved);
  } else {
    return null;
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:77,代码来源:PreprocessorUtils.java

示例14: trim

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Trims a suffix/prefix from the given string. For example if
 * s is given as "/xy" and toTrim is "/", this method returns "xy"
 */
private static String trim(String s, String toTrim) {
  return StringUtils.removeEnd(StringUtils.removeStart(s, toTrim),
      toTrim);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:AzureNativeFileSystemStore.java

示例15: setSpecificDocletOptions

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Depending upon the command line options provided by the user, set
 * configure the output generation environment.
 * 
 * @param options
 *            The array of option names and values.
 */
public void setSpecificDocletOptions(String[][] options) {
	for (int oi = 0; oi < options.length; ++oi) {
		String[] os = options[oi];
		String opt = os[0].toLowerCase();
		if (opt.equals("-charset")) {
			charset = os[1];
		} else if (opt.equals("-noframe")) {
			noframe = true;
		} else if (opt.equals("-dubboconfigpath")) {
			dubboconfigpath = os[1];
		} else if (opt.equals("-springcontextconfigpath")) {
			springcontextconfigpath = os[1];
		} else if (opt.equals("-excludedurlsxpath")) {
			excludedurlsxpath = os[1];
		} else if (opt.equals("-systemname")) {
			systemname = os[1];
		} else if (opt.equals("-branchname")) {
			branchname = os[1];
		} else if (opt.equals("-searchengine")) {
			searchengine = os[1];
		} else if (opt.equals("-codeurl")) {
			codeurl = os[1];
		} else if (opt.equals("-buildid")) {
			buildid = os[1];
		}
	}
	// if branchname is not specified, try to resolve it from codeurl.
	if (StringUtils.isEmpty(branchname) && StringUtils.isNotEmpty(codeurl)) {
		codeurl = StringUtils.removeEnd(codeurl, "/");
		String[] parts = StringUtils.split(codeurl, '/');
		branchname = parts[parts.length - 1];
	}
	if (root.specifiedClasses().length > 0) {
		Map<String, PackageDoc> map = new HashMap<String, PackageDoc>();
		PackageDoc pd;
		ClassDoc[] classes = root.classes();
		for (int i = 0; i < classes.length; i++) {
			pd = classes[i].containingPackage();
			if (!map.containsKey(pd.name())) {
				map.put(pd.name(), pd);
			}
		}
	}
}
 
开发者ID:WinRoad-NET,项目名称:htmldoclet4jdk8,代码行数:52,代码来源:ConfigurationImpl.java


注:本文中的org.apache.commons.lang.StringUtils.removeEnd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。