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


Java StringUtils.stripEnd方法代码示例

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


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

示例1: valStr

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@Override
public String valStr() {
    String toTrim = args.get(0).valStr();
    if (nullValue = args.get(0).isNullValue())
        return null;
    String remove = null;
    if (getArgCount() == 2) {
        remove = args.get(1).valStr();
        if (nullValue = args.get(1).isNullValue())
            return null;
    }
    String ret = null;
    if (mTrimLeading)
        ret = StringUtils.stripStart(toTrim, remove);
    if (mTrimTrailing)
        ret = StringUtils.stripEnd(toTrim, remove);
    return ret;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:19,代码来源:ItemFuncTrim.java

示例2: convertToLocalResource

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private static LocalResource convertToLocalResource(String hdfsPath, LocalResourceVisibility visibility) throws Exception {
  // Directory resource path must not end with /, otherwise localization will hang.
  hdfsPath = StringUtils.stripEnd(hdfsPath, HDFS_PATH_SEPARATOR);
  String extension = FilenameUtils.getExtension(hdfsPath).toLowerCase();
  LocalResourceType type;
  if (extension.equals(".zip") ||
      extension.equals(".tgz") ||
      extension.equals(".tar") ||
      extension.equals(".tar.gz")) {
    type = LocalResourceType.ARCHIVE;
  } else {
    type = LocalResourceType.FILE;
  }

  // Currently only HDFS URI is supported
  // Note Non APPLICATION LocalResourceVisibility may introduce conflicts if multiple
  // Applications' Containers on the same node write the same data in the resource directory.
  try {
    FileStatus fileStatus = getFileStatusInHdfs(hdfsPath);
    FileContext fileContext = FileContext.getFileContext(conf);
    return LocalResource.newInstance(
        ConverterUtils.getYarnUrlFromPath(fileContext
            .getDefaultFileSystem().resolvePath(fileStatus.getPath())),
        type, visibility, fileStatus.getLen(), fileStatus.getModificationTime());
  } catch (IllegalArgumentException e) {
    // hdfsPath may be from user, so it may be illegal.
    throw new NonTransientException("Path is illegal.", e);
  }
}
 
开发者ID:Microsoft,项目名称:pai,代码行数:30,代码来源:HadoopUtils.java

示例3: simpleTrim

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public static TrimmedInput simpleTrim(String input) {
  if (input != null) {
    // First remove the trailing white spaces, we do not need those
    if (!containsOnlyWhiteSpaces(input)) {
      input = StringUtils.stripEnd(input, null);
    }
    String output = input.trim();
    return new TrimmedInput(output, input.length() - output.length());
  } else {
    return null;
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:13,代码来源:PreprocessorUtils.java

示例4: getHdfsNodePath

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public static String getHdfsNodePath(String parentNodePath, String nodeName) {
  return (StringUtils.stripEnd(parentNodePath, HDFS_PATH_SEPARATOR) +
      HDFS_PATH_SEPARATOR +
      StringUtils.stripStart(nodeName, HDFS_PATH_SEPARATOR));
}
 
开发者ID:Microsoft,项目名称:pai,代码行数:6,代码来源:HadoopUtils.java

示例5: getNodePath

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public static String getNodePath(String parentNodePath, String nodeName) {
  return (StringUtils.stripEnd(parentNodePath, PATH_SEPARATOR) +
      PATH_SEPARATOR +
      StringUtils.stripStart(nodeName, PATH_SEPARATOR));
}
 
开发者ID:Microsoft,项目名称:pai,代码行数:6,代码来源:ZookeeperStoreStructure.java

示例6: 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


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