Utility Class

  • java.lang.Object
    • com.azure.storage.common.Utility

public final class Utility

Utility methods for storage client libraries.

Field Summary

Modifier and Type Field and Description
static final String STORAGE_TRACING_NAMESPACE_VALUE

Please see here for more information on Azure resource provider namespaces.

Constructor Summary

Constructor Description
Utility()

Creates a new instance of Utility.

Method Summary

Modifier and Type Method and Description
static String appendQueryParameter(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 String encodeUrlPath(String url)

Performs a safe encoding of a url string, only encoding the path.

static OffsetDateTime parseDate(String dateString)

Deprecated

Use StorageImplUtils#parseDateAndFormat(String)

Given a String representing a date in a form of the ISO8601 pattern, generates a Date representing it with up to millisecond precision.

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.

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.

Methods inherited from java.lang.Object

Field Details

STORAGE_TRACING_NAMESPACE_VALUE

public static final String STORAGE_TRACING_NAMESPACE_VALUE

Please see here for more information on Azure resource provider namespaces.

Constructor Details

Utility

public Utility()

Creates a new instance of Utility.

Method Details

appendQueryParameter

public static String appendQueryParameter(String url, String key, String value)

Appends a query parameter to a url.

Parameters:

url - The url.
key - The query key.
value - The query value.

Returns:

The updated url.

convertStreamToByteBuffer

public static Flux 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:

ByteBuffer which contains the input data.

convertStreamToByteBuffer

public static Flux 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 using com.azure.core.util.FluxUtil#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:

ByteBuffer which contains the input data.

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

@Deprecated
public static OffsetDateTime parseDate(String dateString)

Deprecated

Use StorageImplUtils#parseDateAndFormat(String)

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 - the String to be interpreted as a Date

Returns:

the corresponding Date object

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

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

Applies to