Here you can find the source of toUri(String endpoint, Protocol protocol)
Parameter | Description |
---|---|
endpoint | the endpoint. |
protocol | the protocol. |
Parameter | Description |
---|---|
IllegalArgumentException | if the inputs are null. |
public static URI toUri(String endpoint, Protocol protocol)
//package com.java2s; /*/*from w w w . j av a2s . c o m*/ * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ import com.amazonaws.ClientConfiguration; import com.amazonaws.Protocol; import java.net.URI; import java.net.URISyntaxException; public class Main { /** * @param endpoint the endpoint. * @param config the client configuration. * @return an URI for the given endpoint. Prefixes the protocol if the * endpoint given does not have it. * * @throws IllegalArgumentException if the inputs are null. */ public static URI toUri(String endpoint, ClientConfiguration config) { if (config == null) { throw new IllegalArgumentException("ClientConfiguration cannot be null"); } return toUri(endpoint, config.getProtocol()); } /** * @param endpoint the endpoint. * @param protocol the protocol. * @return an URI for the given endpoint. Prefixes the protocol if the * endpoint given does not have it. * * @throws IllegalArgumentException if the inputs are null. */ public static URI toUri(String endpoint, Protocol protocol) { if (endpoint == null) { throw new IllegalArgumentException("endpoint cannot be null"); } /* * If the endpoint doesn't explicitly specify a protocol to use, then * we'll defer to the default protocol specified in the client * configuration. */ if (!endpoint.contains("://")) { endpoint = protocol.toString() + "://" + endpoint; } try { return new URI(endpoint); } catch (final URISyntaxException e) { throw new IllegalArgumentException(e); } } }