public final class RestUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
closeStream(Object stream)
|
static org.mule.runtime.api.metadata.TypedValue<String> |
consumeStringAndClose(Object stream,
org.mule.runtime.api.metadata.MediaType targetMediaType,
Charset targetCharset)
Consumes the contents of the given
stream as a String and closes it. |
static String |
stringValue(Object o)
Transforms a value into a tailored String representation for HTTP requests.
|
static List<org.mule.runtime.api.metadata.TypedValue<String>> |
toList(Iterator<org.mule.runtime.api.metadata.TypedValue<?>> iterator,
org.mule.runtime.api.metadata.MediaType mediaType,
org.mule.runtime.api.metadata.MediaType defaultMediaType)
Transform an iterator of TypedValue> into a list of TypedValue
|
static org.mule.runtime.api.metadata.TypedValue<String> |
toTypedValue(String value,
org.mule.runtime.api.metadata.MediaType mediaType,
Charset encoding) |
public static void closeStream(Object stream)
stream which can be either a CursorProvider or an InputStream.
Null values or instances of other classes will be ignored.stream - a streampublic static org.mule.runtime.api.metadata.TypedValue<String> consumeStringAndClose(Object stream, org.mule.runtime.api.metadata.MediaType targetMediaType, Charset targetCharset)
stream as a String and closes it.
The stream can be either a CursorStreamProvider or an InputStream. IllegalArgumentException
will be thrown if the stream is an instance of any other class.
Notice that in the case of CursorStreamProvider, this method will close the provider meaning that it will no longer
be able to yield new cursors.
stream - a CursorStreamProvider or an InputStreamtargetCharset - the encoding to use when reading the String and that will be set to the TypedValuetargetMediaType - the media type that will be set to the TypedValueIllegalArgumentException - if stream is not of the expected types.public static List<org.mule.runtime.api.metadata.TypedValue<String>> toList(Iterator<org.mule.runtime.api.metadata.TypedValue<?>> iterator, org.mule.runtime.api.metadata.MediaType mediaType, org.mule.runtime.api.metadata.MediaType defaultMediaType)
iterator - The iterator to consumemediaType - The primary source of the media type and charset. This is the media type for this specific iterator.defaultMediaType - Tee default source for the charset. The charset of this media type will be used if the primary one
does not contain one.public static String stringValue(Object o)
Copyright © 2022. All rights reserved.