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


Java StringUtils.strip方法代码示例

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


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

示例1: parse

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
protected List<String> parse(final int response, final String[] reply) {
    final List<String> result = new ArrayList<String>(reply.length);
    for(final String line : reply) {
        // Some servers include the status code for every line.
        if(line.startsWith(String.valueOf(response))) {
            try {
                String stripped = line;
                stripped = StringUtils.strip(StringUtils.removeStart(stripped, String.valueOf(String.format("%d-", response))));
                stripped = StringUtils.strip(StringUtils.removeStart(stripped, String.valueOf(response)));
                result.add(stripped);
            }
            catch(IndexOutOfBoundsException e) {
                log.error(String.format("Failed parsing line %s", line), e);
            }
        }
        else {
            result.add(StringUtils.strip(line));
        }
    }
    return result;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:22,代码来源:FTPStatListService.java

示例2: generateMapType

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static Object generateMapType(ServiceDefinition def, TypeDefinition td, MetadataType metadataType,
                                      Set<String> resolvedTypes) {
    String keyType = StringUtils.substringAfter(td.getType(), "<");
    keyType = StringUtils.substringBefore(keyType, ",");
    keyType = StringUtils.strip(keyType);
    keyType = StringUtils.isNotEmpty(keyType) ? keyType : "java.lang.Object";
    Object key = generateType(def, keyType, metadataType, resolvedTypes);

    String valueType = StringUtils.substringAfter(td.getType(), ",");
    valueType = StringUtils.substringBefore(valueType, ">");
    valueType = StringUtils.strip(valueType);
    valueType = StringUtils.isNotEmpty(valueType) ? valueType : "java.lang.Object";
    Object value = generateType(def, valueType, metadataType, resolvedTypes);

    Map<Object, Object> map = new HashMap<>();
    map.put(key, value);
    return map;
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:19,代码来源:GenericInvokeUtils.java

示例3: Math

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static MIMEContainer Math(String code) {
  code = StringUtils.strip(code, "$");
  return addMimeType(MIME.TEXT_LATEX, "$$" + code + "$$");
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:5,代码来源:MIMEContainer.java

示例4: normalizeString

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static String normalizeString(String input) {
	// Contain only ASCII letters, digits, or underscore characters (_).
	// Begin with an alphabetic character or underscore character.
	// Subsequent characters may include letters, digits, underscores.
	// Be between 1 and 127 characters in length, not including quotes for
	// delimited identifiers.
	// Contain no quotation marks and no spaces.
	StringBuffer sb = new StringBuffer();
	// To lowercase and remove all extra whitespaces.
	input = StringUtils.normalizeSpace(input.toLowerCase());
	for (char c : input.toCharArray()) {
		if (VALID_CHARS.contains(String.valueOf(c))) {
			if (sb.length() == 0 && INVALID_FIRST_CHARS.contains(String.valueOf(c))) {
				sb.append(REPLACEMENT_CHAR);
			}
			else {
				sb.append(c);
			}
		}
		else {
			sb.append(REPLACEMENT_CHAR);
		}
	}

	String normalizedName = sb.toString();
	// Remove leading and trailing underscore and multiple underscores
	normalizedName = StringUtils.replacePattern(normalizedName, "_{2,}", REPLACEMENT_CHAR);
	normalizedName = StringUtils.strip(normalizedName, REPLACEMENT_CHAR);

	return normalizedName.length() > 127 ? normalizedName.substring(0, 127) : normalizedName;
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:32,代码来源:CommonUtils.java

示例5: convert

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * @return IDN normalized hostname
 */
public String convert(final String hostname) {
    if(!PreferencesFactory.get().getBoolean("connection.hostname.idn")) {
        return StringUtils.strip(hostname);
    }
    if(StringUtils.isNotEmpty(hostname)) {
        try {
            // Convenience function that implements the IDNToASCII operation as defined in
            // the IDNA RFC. This operation is done on complete domain names, e.g: "www.example.com".
            // It is important to note that this operation can fail. If it fails, then the input
            // domain name cannot be used as an Internationalized Domain Name and the application
            // should have methods defined to deal with the failure.
            // IDNA.DEFAULT Use default options, i.e., do not process unassigned code points
            // and do not use STD3 ASCII rules If unassigned code points are found
            // the operation fails with ParseException
            final String idn = IDN.toASCII(StringUtils.strip(hostname));
            if(log.isDebugEnabled()) {
                if(!StringUtils.equals(StringUtils.strip(hostname), idn)) {
                    log.debug(String.format("IDN hostname for %s is %s", hostname, idn));
                }
            }
            if(StringUtils.isNotEmpty(idn)) {
                return idn;
            }
        }
        catch(IllegalArgumentException e) {
            log.warn(String.format("Failed to convert hostname %s to IDNA", hostname), e);
        }
    }
    return StringUtils.strip(hostname);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:34,代码来源:PunycodeConverter.java

示例6: extractVariableName

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String extractVariableName(String path, int start, int end, Set<String> variables) {
    String substring = StringUtils.substring(path, start, end);
    String stripped = StringUtils.strip(substring, "{}");
    String variable = StringUtils.substringBefore(stripped, ":");
    variables.add(variable);
    return String.format("${%s}", variable);
}
 
开发者ID:sdadas,项目名称:spring2ts,代码行数:8,代码来源:ServicePath.java

示例7: strip

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static String strip(Object val) {
  return StringUtils.strip(String.valueOf(val));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:4,代码来源:Strings.java


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