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


Java StringUtils.lowerCase方法代码示例

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


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

示例1: getCanonicalizedHeaderString

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
protected String getCanonicalizedHeaderString(SignableRequest<?> request) {
    final List<String> sortedHeaders = new ArrayList<String>(request.getHeaders()
            .keySet());
    Collections.sort(sortedHeaders, String.CASE_INSENSITIVE_ORDER);

    final Map<String, String> requestHeaders = request.getHeaders();
    StringBuilder buffer = new StringBuilder();
    for (String header : sortedHeaders) {
        if (shouldExcludeHeaderFromSigning(header)) {
            continue;
        }
        String key = StringUtils.lowerCase(header);
        String value = requestHeaders.get(header);

        StringUtils.appendCompactedString(buffer, key);
        buffer.append(":");
        if (value != null) {
            StringUtils.appendCompactedString(buffer, value);
        }

        buffer.append("\n");
    }

    return buffer.toString();
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:26,代码来源:AWS4Signer.java

示例2: getMimetype

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
/**
 * Determines the mimetype of a file by looking up the file's extension in
 * an internal listing to find the corresponding mime type. If the file has
 * no extension, or the extension is not available in the listing contained
 * in this class, the default mimetype <code>application/octet-stream</code>
 * is returned.
 * <p>
 * A file extension is one or more characters that occur after the last
 * period (.) in the file's name. If a file has no extension, Guesses the
 * mimetype of file data based on the file's extension.
 *
 * @param fileName
 *            The name of the file whose extension may match a known
 *            mimetype.
 *
 * @return The file's mimetype based on its extension, or a default value of
 *         <code>application/octet-stream</code> if a mime type value cannot
 *         be found.
 */
public String getMimetype(String fileName) {
    int lastPeriodIndex = fileName.lastIndexOf(".");
    if (lastPeriodIndex > 0 && lastPeriodIndex + 1 < fileName.length()) {
        String ext = StringUtils.lowerCase(fileName.substring(lastPeriodIndex + 1));
        if (extensionToMimetypeMap.keySet().contains(ext)) {
            String mimetype = (String) extensionToMimetypeMap.get(ext);
            if (log.isDebugEnabled()) {
                log.debug("Recognised extension '" + ext + "', mimetype is: '" + mimetype + "'");
            }
            return mimetype;
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Extension '" + ext + "' is unrecognized in mime type listing"
                + ", using default mime type: '" + MIMETYPE_OCTET_STREAM + "'");
            }
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("File name has no extension, mime type cannot be recognised for: " + fileName);
        }
    }
    return MIMETYPE_OCTET_STREAM;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:43,代码来源:Mimetypes.java

示例3: computeServiceName

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
/**
 * Returns the service name of this AWS http client by first looking it up from the SDK internal
 * configuration, and if not found, derive it from the class name of the immediate subclass of
 * {@link AmazonWebServiceClient}. No configuration is necessary if the simple class name of the
 * http client follows the convention of <code>(Amazon|AWS).*(JavaClient|Client)</code>.
 */
private String computeServiceName() {
    final String httpClientName = getHttpClientName();
    String service = ServiceNameFactory.getServiceName(httpClientName);
    if (service != null) {
        return service; // only if it is so explicitly configured
    }
    // Otherwise, make use of convention over configuration
    int j = httpClientName.indexOf("JavaClient");
    if (j == -1) {
        j = httpClientName.indexOf("Client");
        if (j == -1) {
            throw new IllegalStateException(
                    "Unrecognized suffix for the AWS http client class name " + httpClientName);
        }
    }
    int i = httpClientName.indexOf(AMAZON);
    int len;
    if (i == -1) {
        i = httpClientName.indexOf(AWS);
        if (i == -1) {
            throw new IllegalStateException(
                    "Unrecognized prefix for the AWS http client class name " + httpClientName);
        }
        len = AWS.length();
    } else {
        len = AMAZON.length();
    }
    if (i >= j) {
        throw new IllegalStateException(
                "Unrecognized AWS http client class name " + httpClientName);
    }
    String serviceName = httpClientName.substring(i + len, j);
    return StringUtils.lowerCase(serviceName);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:41,代码来源:AmazonWebServiceClient.java

示例4: getHeadersForStringToSign

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
protected List<String> getHeadersForStringToSign(SignableRequest<?> request) {
    List<String> headersToSign = new ArrayList<String>();
    for (Map.Entry<String, String> entry : request.getHeaders().entrySet()) {
        String key = entry.getKey();
        String lowerCaseKey = StringUtils.lowerCase(key);
        if (lowerCaseKey.startsWith("x-amz")
                || lowerCaseKey.equals("host")) {
            headersToSign.add(key);
        }
    }

    Collections.sort(headersToSign);
    return headersToSign;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:15,代码来源:AWS3Signer.java

示例5: shouldUseHttpsScheme

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
protected boolean shouldUseHttpsScheme(SignableRequest<?> request) throws SdkClientException {
    try {
        String protocol = StringUtils.lowerCase(request.getEndpoint().toURL().getProtocol());
        if (protocol.equals("http")) {
            return false;
        } else if (protocol.equals("https")) {
            return true;
        } else {
            throw new SdkClientException("Unknown request endpoint protocol " +
                    "encountered while signing request: " + protocol);
        }
    } catch (MalformedURLException e) {
        throw new SdkClientException("Unable to parse request endpoint during signing", e);
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:16,代码来源:AWS3Signer.java

示例6: getCanonicalizedEndpoint

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
protected String getCanonicalizedEndpoint(URI endpoint) {
    String endpointForStringToSign = StringUtils.lowerCase(endpoint.getHost());
    /*
     * Apache HttpClient will omit the port in the Host header for default
     * port values (i.e. 80 for HTTP and 443 for HTTPS) even if we
     * explicitly specify it, so we need to be careful that we use the same
     * value here when we calculate the string to sign and in the Host
     * header we send in the HTTP request.
     */
    if (SdkHttpUtils.isUsingNonDefaultPort(endpoint)) {
        endpointForStringToSign += ":" + endpoint.getPort();
    }

    return endpointForStringToSign;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:16,代码来源:AbstractAWSSigner.java


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