當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。