Enum HttpUtils
- java.lang.Object
-
- java.lang.Enum<HttpUtils>
-
- com.oracle.bmc.util.internal.HttpUtils
-
- All Implemented Interfaces:
Serializable,Comparable<HttpUtils>
public enum HttpUtils extends Enum<HttpUtils>
Utility functions related to HTTP calls.Note, the overloading performed in this class is to allow for compile time validation of the args passed in (vs. taking a generic Object and throwing an exception if the class isn't supported at runtime).
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectattemptEncodeQueryParam(Object queryParam)Attempts to encode a query param if it is a String.static <T> StringencodeCollectionFormatHeaderParam(String paramName, List<T> values, CollectionFormatType collectionFormatType)Attempts to encode a header parameter which is described by a list of values for that parameter and aCollectionFormatTypewhich describes how the values should appear in the headerstatic <T> WrappedWebTargetencodeCollectionFormatQueryParam(WrappedWebTarget target, String queryParamName, List<T> values, CollectionFormatType collectionFormatType)Attempts to encode a query parameter which is described by a list of values for that parameter and aCollectionFormatTypewhich describes how the values should appear in the query string (e.g. as multiple parameters, as a single parameter with a given delimiter).static WrappedWebTargetencodeMapQueryParam(WrappedWebTarget target, String prefix, Map<String,?> queryParam)Attempts to encode a query param if it is aMap.static StringencodePathSegment(Boolean pathSegment)Encodes a path segment.static StringencodePathSegment(Character pathSegment)Encodes a path segment.static StringencodePathSegment(Number pathSegment)Encodes a path segment.static StringencodePathSegment(String pathSegment)Encodes a path segment.static StringencodePathSegment(UUID pathSegment)Encodes a path segment.static StringurlPathSegmentEscape(String pathSegment)Escape a URL path segment string.static HttpUtilsvalueOf(String name)Returns the enum constant of this type with the specified name.static HttpUtils[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Method Detail
-
values
public static HttpUtils[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (HttpUtils c : HttpUtils.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static HttpUtils valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
urlPathSegmentEscape
public static String urlPathSegmentEscape(String pathSegment)
Escape a URL path segment string.- Parameters:
pathSegment- path segment to escape- Returns:
- escaped path segment
-
encodePathSegment
public static String encodePathSegment(@Nonnull String pathSegment)
Encodes a path segment.- Parameters:
pathSegment- The path segment to encode.- Returns:
- The encoded path segment.
-
encodePathSegment
public static String encodePathSegment(@Nonnull Number pathSegment)
Encodes a path segment.- Parameters:
pathSegment- The path segment to encode.- Returns:
- The encoded path segment.
-
encodePathSegment
public static String encodePathSegment(@Nonnull Boolean pathSegment)
Encodes a path segment.- Parameters:
pathSegment- The path segment to encode.- Returns:
- The encoded path segment.
-
encodePathSegment
public static String encodePathSegment(@Nonnull Character pathSegment)
Encodes a path segment.- Parameters:
pathSegment- The path segment to encode.- Returns:
- The encoded path segment.
-
encodePathSegment
public static String encodePathSegment(@Nonnull UUID pathSegment)
Encodes a path segment.- Parameters:
pathSegment- The path segment to encode.- Returns:
- The encoded path segment.
-
attemptEncodeQueryParam
public static Object attemptEncodeQueryParam(Object queryParam)
Attempts to encode a query param if it is a String.This does not try to encode non-String values as Jersey uses different serializers for non-String values, so we can’t assume what the string value would be.
Note: this should be called much lower in the HTTP stack (currently being called through the generated code), so it can encode the serialized values.
- Parameters:
queryParam- The query parameter to encode.- Returns:
- The encoded param, or the same value if it was not a String.
-
encodeMapQueryParam
public static WrappedWebTarget encodeMapQueryParam(WrappedWebTarget target, String prefix, Map<String,?> queryParam)
Attempts to encode a query param if it is aMap.Each key is prefixed with the value passed as prefix. If a value is a
Collection, then the “{prefix}{key}={item}” output is repeated for each item in the collection, where “{item}” is encoded usingattemptEncodeQueryParam(Object). If the value is not a collection, then the output is simply “{prefix}{key}={value}”, where the value is again encoded.Note: this should be called much lower in the HTTP stack (currently being called through the generated code), so it can encode the serialized values.
- Parameters:
target- target instanceprefix- prefix for each keyqueryParam- The map query parameter to encode.- Returns:
- a new target instance
-
encodeCollectionFormatQueryParam
public static <T> WrappedWebTarget encodeCollectionFormatQueryParam(WrappedWebTarget target, String queryParamName, List<T> values, CollectionFormatType collectionFormatType)
Attempts to encode a query parameter which is described by a list of values for that parameter and aCollectionFormatTypewhich describes how the values should appear in the query string (e.g. as multiple parameters, as a single parameter with a given delimiter).- Parameters:
target- target instancequeryParamName- the name of the query parameter as it should appear in the query stringvalues- the values for the query parameter. An empty or null list will result in no action being taken on the target instance. Additionally, any null values inside the list will be ignoredcollectionFormatType- describes how entries should appear in the query string, for example as multiple parameters with the name query string parameter name/key, or as a single parameter with its values separated by a delimiter character (comma, space, tab or pipe)- Returns:
- a new target instance
-
encodeCollectionFormatHeaderParam
public static <T> String encodeCollectionFormatHeaderParam(String paramName, List<T> values, CollectionFormatType collectionFormatType)
Attempts to encode a header parameter which is described by a list of values for that parameter and aCollectionFormatTypewhich describes how the values should appear in the header- Parameters:
paramName- the name of the query parameter as it should appear in the query stringvalues- the values for the query parameter. An empty or null list will result in no action being taken on the target instance. Additionally, any null values inside the list will be ignoredcollectionFormatType- describes how entries should appear in the query string, for example as a single parameter with its values separated by a delimiter character (comma, space, tab or pipe)- Returns:
- a String
-
-