Package com.azure.storage.common
Class Utility
- java.lang.Object
-
- com.azure.storage.common.Utility
-
public final class Utility extends Object
Utility methods for storage client libraries.
-
-
Field Summary
Fields Modifier and Type Field Description static StringSTORAGE_TRACING_NAMESPACE_VALUE
-
Constructor Summary
Constructors Constructor Description Utility()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringappendQueryParameter(String url, String key, String value)Appends a query parameter to a url.static Flux<ByteBuffer>convertStreamToByteBuffer(InputStream data, long length, int blockSize)A utility method for converting the input stream to Flux of ByteBuffer.static Flux<ByteBuffer>convertStreamToByteBuffer(InputStream data, long length, int blockSize, boolean markAndReset)A utility method for converting the input stream to Flux of ByteBuffer.static StringencodeUrlPath(String url)Performs a safe encoding of a url string, only encoding the path.static OffsetDateTimeparseDate(String dateString)Given a String representing a date in a form of the ISO8601 pattern, generates a Date representing it with up to millisecond precision.static StringurlDecode(String stringToDecode)Performs a safe decoding of the passed string, taking care to preserve each+character rather than replacing it with a space character.static StringurlEncode(String stringToEncode)Performs a safe encoding of the specified string, taking care to insert %20 for each space character instead of inserting the+character.
-
-
-
Field Detail
-
STORAGE_TRACING_NAMESPACE_VALUE
public static final String STORAGE_TRACING_NAMESPACE_VALUE
- See Also:
- Constant Field Values
-
-
Method Detail
-
urlDecode
public static String urlDecode(String stringToDecode)
Performs a safe decoding of the passed string, taking care to preserve each+character rather than replacing it with a space character.- Parameters:
stringToDecode- String value to decode- Returns:
- the decoded string value
- Throws:
RuntimeException- If the UTF-8 charset isn't supported
-
urlEncode
public static String urlEncode(String stringToEncode)
Performs a safe encoding of the specified string, taking care to insert %20 for each space character instead of inserting the+character.- Parameters:
stringToEncode- String value to encode- Returns:
- the encoded string value
- Throws:
RuntimeException- If the UTF-8 charset ins't supported
-
encodeUrlPath
public static String encodeUrlPath(String url)
Performs a safe encoding of a url string, only encoding the path.- Parameters:
url- The url to encode.- Returns:
- The encoded url.
-
parseDate
public static OffsetDateTime parseDate(String dateString)
Given a String representing a date in a form of the ISO8601 pattern, generates a Date representing it with up to millisecond precision.- Parameters:
dateString- theStringto be interpreted as aDate- Returns:
- the corresponding
Dateobject - Throws:
IllegalArgumentException- IfdateStringdoesn't match an ISO8601 pattern
-
convertStreamToByteBuffer
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize)
A utility method for converting the input stream to Flux of ByteBuffer. Will check the equality of entity length and the input length.- Parameters:
data- The input data which needs to convert to ByteBuffer.length- The expected input data length.blockSize- The size of each ByteBuffer.- Returns:
ByteBufferwhich contains the input data.- Throws:
com.azure.core.exception.UnexpectedLengthException- when input data length mismatch input length.RuntimeException- When I/O error occurs.
-
convertStreamToByteBuffer
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize, boolean markAndReset)
A utility method for converting the input stream to Flux of ByteBuffer. Will check the equality of entity length and the input length. Using markAndReset=true to force a seekable stream implies a buffering strategy is not being used, in which case length is still needed for whatever underlying REST call is being streamed to. If markAndReset=false and data is being buffered, consider usingFluxUtil.toFluxByteBuffer(InputStream, int)which does not require a data length.- Parameters:
data- The input data which needs to convert to ByteBuffer.length- The expected input data length.blockSize- The size of each ByteBuffer.markAndReset- Whether the stream needs to be marked and reset. This should generally always be true to support retries. It is false in the case of buffered upload to support non markable streams because buffered upload uses its own mechanisms to support retries.- Returns:
ByteBufferwhich contains the input data.- Throws:
com.azure.core.exception.UnexpectedLengthException- when input data length mismatch input length.RuntimeException- When I/O error occurs.
-
-