PathUtility Class

  • java.lang.Object
    • com.microsoft.azure.storage.core.PathUtility

public class PathUtility

RESERVED FOR INTERNAL USE. A class to help modify paths

Method Summary

Modifier and Type Method and Description
StorageUri addToQuery(final StorageUri resourceURI, final String queryString)

Adds a queryString to an URI.

URI addToQuery(final URI resourceURI, final String queryString)

Adds a queryString to an URI.

URI addToSingleUriQuery(final URI resourceURI, final HashMap<String, String[]> fieldCollection)

Adds a queryString to an URI.

URI appendPathToSingleUri(final URI uri, final String relativeOrAbsoluteUri)

Appends a path to a URI correctly using "/" as separator.

URI appendPathToSingleUri(final URI uri, final String relativeUri, final String separator)

Appends a path to a URI correctly using the given separator.

StorageUri appendPathToUri(final StorageUri uriList, final String relativeOrAbsoluteUri)

Appends a path to a list of URIs correctly using "/" as separator.

StorageUri appendPathToUri(final StorageUri uriList, final String relativeOrAbsoluteUri, final String separator)

Appends a path to a list of URIs correctly using "/" as separator.

String getBlobNameFromURI(final URI inURI, final boolean usePathStyleUris)

Gets the blob name from the URI.

String getCanonicalPathFromCredentials(final StorageCredentials credentials, final String absolutePath)

Gets the canonical path for an object from the credentials.

String getContainerNameFromUri(final URI resourceAddress, final boolean usePathStyleUris)

Get the container name from address from the URI.

StorageUri getContainerURI(final StorageUri blobAddress, final boolean usePathStyleUris)

Gets the container URI from a blob address

String getDirectoryNameFromURI(final URI resourceAddress, final boolean usePathStyleUris)

Get the name of the lowest level directory from the given directory address.

String getFileNameFromURI(final URI resourceAddress, final boolean usePathStyleUris)

Gets the file name from the URI.

StorageUri getServiceClientBaseAddress(final StorageUri addressUri, final boolean usePathStyleUris)

Get the service client address from a complete Uri.

String getServiceClientBaseAddress(final URI address, final boolean usePathStyleUris)

Get the service client address from a complete Uri.

String getShareNameFromUri(final URI resourceAddress, final boolean usePathStyleUris)

Get the share name from address from the URI.

StorageUri getShareURI(final StorageUri fileAddress, final boolean usePathStyleUris)

Gets the share URI from a file address

String getTableNameFromUri(final URI resourceAddress, final boolean usePathStyleUris)

Get the table name from address from the URI.

HashMap<String, String[]> parseQueryString(String parseString)

Parses a query string into a one to many hashmap.

URI stripSingleURIQueryAndFragment(final URI inUri)

Strips the Query and Fragment from the uri.

StorageUri stripURIQueryAndFragment(final StorageUri inUri)

Strips the Query and Fragment from the uri.

Method Details

addToQuery

public static StorageUri addToQuery(final StorageUri resourceURI, final String queryString)

Adds a queryString to an URI.

Parameters:

resourceURI - the URI of the resource
queryString - the query string to add

Returns:

an appended URI.

Throws:

URISyntaxException - if the resulting URI is invalid.
StorageException

addToQuery

public static URI addToQuery(final URI resourceURI, final String queryString)

Adds a queryString to an URI.

Parameters:

resourceURI - the URI of the resource
queryString - the query string to add

Returns:

an appended URI.

Throws:

URISyntaxException - if the resulting URI is invalid.
StorageException

addToSingleUriQuery

public static URI addToSingleUriQuery(final URI resourceURI, final HashMap fieldCollection)

Adds a queryString to an URI.

Parameters:

resourceURI - the URI of the resource
fieldCollection - the key/ values collection to append.

Returns:

an appended URI.

Throws:

URISyntaxException - if the resulting URI is invalid.
StorageException

appendPathToSingleUri

public static URI appendPathToSingleUri(final URI uri, final String relativeOrAbsoluteUri)

Appends a path to a URI correctly using "/" as separator.

Parameters:

uri - The base Uri.
relativeOrAbsoluteUri - The relative or absloute URI.

Returns:

The appended Uri.

Throws:

URISyntaxException

appendPathToSingleUri

public static URI appendPathToSingleUri(final URI uri, final String relativeUri, final String separator)

Appends a path to a URI correctly using the given separator.

Parameters:

uri - The base Uri.
relativeUri - The relative URI.
separator - the separator to use.

Returns:

The appended Uri.

Throws:

URISyntaxException - a valid Uri cannot be constructed

appendPathToUri

public static StorageUri appendPathToUri(final StorageUri uriList, final String relativeOrAbsoluteUri)

Appends a path to a list of URIs correctly using "/" as separator.

Parameters:

uriList - The base Uri.
relativeOrAbsoluteUri - The relative or absolute URI.

Returns:

The appended Uri.

Throws:

URISyntaxException

appendPathToUri

public static StorageUri appendPathToUri(final StorageUri uriList, final String relativeOrAbsoluteUri, final String separator)

Appends a path to a list of URIs correctly using "/" as separator.

Parameters:

uriList - The base Uri.
relativeOrAbsoluteUri - The relative or absolute URI.
separator

Returns:

The appended Uri.

Throws:

URISyntaxException

getBlobNameFromURI

public static String getBlobNameFromURI(final URI inURI, final boolean usePathStyleUris)

Gets the blob name from the URI.

Parameters:

inURI - the resource address
usePathStyleUris - a value indicating if the address is a path style uri.

Returns:

the blobs name

Throws:

URISyntaxException

getCanonicalPathFromCredentials

public static String getCanonicalPathFromCredentials(final StorageCredentials credentials, final String absolutePath)

Gets the canonical path for an object from the credentials.

Parameters:

credentials - the credentials to use.
absolutePath - the Absolute path of the object.

Returns:

the canonical path for an object from the credentials

getContainerNameFromUri

public static String getContainerNameFromUri(final URI resourceAddress, final boolean usePathStyleUris)

Get the container name from address from the URI.

Parameters:

resourceAddress - The container Uri.
usePathStyleUris - a value indicating if the address is a path style uri.

Returns:

container name from address from the URI.

Throws:

IllegalArgumentException

getContainerURI

public static StorageUri getContainerURI(final StorageUri blobAddress, final boolean usePathStyleUris)

Gets the container URI from a blob address

Parameters:

blobAddress - the blob address
usePathStyleUris - a value indicating if the address is a path style uri.

Returns:

the container URI from a blob address

Throws:

URISyntaxException

getDirectoryNameFromURI

public static String getDirectoryNameFromURI(final URI resourceAddress, final boolean usePathStyleUris)

Get the name of the lowest level directory from the given directory address.

Parameters:

resourceAddress - the directory URI
usePathStyleUris - a value indicating if the address is a path style URI

Returns:

directory name from address from the URI

getFileNameFromURI

public static String getFileNameFromURI(final URI resourceAddress, final boolean usePathStyleUris)

Gets the file name from the URI.

Parameters:

resourceAddress - the file URI
usePathStyleUris - a value indicating if the address is a path style URI

Returns:

the file's name

getServiceClientBaseAddress

public static StorageUri getServiceClientBaseAddress(final StorageUri addressUri, final boolean usePathStyleUris)

Get the service client address from a complete Uri.

Parameters:

addressUri - Complete address of the resource.
usePathStyleUris - a value indicating if the address is a path style uri.

Returns:

the service client address from a complete Uri.

Throws:

URISyntaxException

getServiceClientBaseAddress

public static String getServiceClientBaseAddress(final URI address, final boolean usePathStyleUris)

Get the service client address from a complete Uri.

Parameters:

address - Complete address of the resource.
usePathStyleUris - a value indicating if the address is a path style uri.

Returns:

the service client address from a complete Uri.

Throws:

URISyntaxException

getShareNameFromUri

public static String getShareNameFromUri(final URI resourceAddress, final boolean usePathStyleUris)

Get the share name from address from the URI.

Parameters:

resourceAddress - The share Uri.
usePathStyleUris - a value indicating if the address is a path style uri.

Returns:

share name from address from the URI.

Throws:

IllegalArgumentException

getShareURI

public static StorageUri getShareURI(final StorageUri fileAddress, final boolean usePathStyleUris)

Gets the share URI from a file address

Parameters:

fileAddress - the file address
usePathStyleUris - a value indicating if the address is a path style uri.

Returns:

the share URI from a file address

Throws:

URISyntaxException

getTableNameFromUri

public static String getTableNameFromUri(final URI resourceAddress, final boolean usePathStyleUris)

Get the table name from address from the URI.

Parameters:

resourceAddress - The table Uri.
usePathStyleUris - a value indicating if the address is a path style uri.

Returns:

table name from address from the URI.

Throws:

IllegalArgumentException

parseQueryString

public static HashMap parseQueryString(String parseString)

Parses a query string into a one to many hashmap.

Parameters:

parseString - the string to parse

Returns:

a HashMap<String, String[]> of the key values.

Throws:

StorageException

stripSingleURIQueryAndFragment

public static URI stripSingleURIQueryAndFragment(final URI inUri)

Strips the Query and Fragment from the uri.

Parameters:

inUri - the uri to alter

Returns:

the stripped uri.

Throws:

StorageException

stripURIQueryAndFragment

public static StorageUri stripURIQueryAndFragment(final StorageUri inUri)

Strips the Query and Fragment from the uri.

Parameters:

inUri - the uri to alter

Returns:

the stripped uri.

Throws:

StorageException

Applies to