Java Code Examples for software.amazon.awssdk.utils.StringUtils#lowerCase()

The following examples show how to use software.amazon.awssdk.utils.StringUtils#lowerCase() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShapeModel.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * Tries to find the member model associated with the given c2j member name from this shape
 * model. Returns the member model if present else returns null.
 */
private MemberModel tryFindMemberModelByC2jName(String memberC2jName, boolean ignoreCase) {

    List<MemberModel> memberModels = getMembers();
    String expectedName = ignoreCase ? StringUtils.lowerCase(memberC2jName)
                                           : memberC2jName;

    if (memberModels != null) {
        for (MemberModel member : memberModels) {
            String actualName = ignoreCase ? StringUtils.lowerCase(member.getC2jName())
                                           : member.getC2jName();

            if (expectedName.equals(actualName)) {
                return member;
            }
        }
    }
    return null;
}
 
Example 2
Source File: DefaultSdkHttpFullRequest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
private String standardizeProtocol(String protocol) {
    Validate.paramNotNull(protocol, "protocol");

    String standardizedProtocol = StringUtils.lowerCase(protocol);
    Validate.isTrue(standardizedProtocol.equals("http") || standardizedProtocol.equals("https"),
                    "Protocol must be 'http' or 'https', but was %s", protocol);

    return standardizedProtocol;
}
 
Example 3
Source File: SdkHttpUtils.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
/**
 * Returns true if the specified port is the standard port for the given protocol. (i.e. 80 for HTTP or 443 for HTTPS).
 *
 * Null or -1 ports (to simplify interaction with {@link URI}'s default value) are treated as standard ports.
 *
 * @return True if the specified port is standard for the specified protocol, otherwise false.
 */
public static boolean isUsingStandardPort(String protocol, Integer port) {
    Validate.paramNotNull(protocol, "protocol");
    Validate.isTrue(protocol.equals("http") || protocol.equals("https"),
                    "Protocol must be 'http' or 'https', but was '%s'.", protocol);

    String scheme = StringUtils.lowerCase(protocol);

    return port == null || port == -1 ||
           (scheme.equals("http") && port == 80) ||
           (scheme.equals("https") && port == 443);
}
 
Example 4
Source File: AbstractAwsSigner.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
protected String getCanonicalizedEndpoint(SdkHttpFullRequest request) {
    String endpointForStringToSign = StringUtils.lowerCase(request.host());

    // Omit the port from the endpoint if we're using the default port for the protocol. Some HTTP clients (ie. Apache) don't
    // allow you to specify it in the request, so we're standardizing around not including it. See SdkHttpRequest#port().
    if (!SdkHttpUtils.isUsingStandardPort(request.protocol(), request.port())) {
        endpointForStringToSign += ":" + request.port();
    }

    return endpointForStringToSign;
}
 
Example 5
Source File: RetryMode.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
private static Optional<RetryMode> fromString(String string) {
    if (string == null || string.isEmpty()) {
        return Optional.empty();
    }

    switch (StringUtils.lowerCase(string)) {
        case "legacy":
            return Optional.of(LEGACY);
        case "standard":
            return Optional.of(STANDARD);
        default:
            throw new IllegalStateException("Unsupported retry policy mode configured: " + string);
    }
}
 
Example 6
Source File: Mimetype.java    From aws-sdk-java-v2 with Apache License 2.0 3 votes vote down vote up
/**
 * 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.
 *
 * @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
 * {@link #MIMETYPE_OCTET_STREAM} if a mime type value cannot
 * be found.
 */
String getMimetype(String fileName) {
    int lastPeriodIndex = fileName.lastIndexOf('.');
    if (lastPeriodIndex > 0 && lastPeriodIndex + 1 < fileName.length()) {
        String ext = StringUtils.lowerCase(fileName.substring(lastPeriodIndex + 1));
        if (extensionToMimetype.containsKey(ext)) {
            return extensionToMimetype.get(ext);
        }
    }
    return MIMETYPE_OCTET_STREAM;
}