Class BlobUrlParts
- java.lang.Object
-
- com.azure.storage.blob.BlobUrlParts
-
public final class BlobUrlParts extends Object
This class represents the components that make up an Azure Storage Container/Blob URL. You may parse an existing URL into its parts with theparse(URL)class. You may construct a URL from parts by callingtoUrl().
-
-
Constructor Summary
Constructors Constructor Description BlobUrlParts()Initializes a BlobUrlParts object which helps aid in the construction of a Blob Storage URL.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description StringgetAccountName()Gets the accountname, ex.StringgetBlobContainerName()Gets the container name that will be used as part of the URL path.StringgetBlobName()Decodes and gets the blob name that will be used as part of the URL path.CommonSasQueryParametersgetCommonSasQueryParameters()Gets theCommonSasQueryParametersrepresenting the SAS query parameters that will be used to generate the SAS token for this URL.StringgetHost()Gets the URL host, ex.BlobServiceSasQueryParametersgetSasQueryParameters()Deprecated.Please usegetCommonSasQueryParameters()StringgetScheme()Gets the URL scheme, ex.StringgetSnapshot()Gets the snapshot identifier that will be used as part of the query string if set.Map<String,String[]>getUnparsedParameters()Gets the query string parameters that aren't part of the SAS token that will be used by this URL.StringgetVersionId()Gets the version identifier that will be used as part of the query string if set.static BlobUrlPartsparse(String url)Parses a string into a BlobUrlParts.static BlobUrlPartsparse(URL url)Parses an existing URL into a BlobUrlParts.BlobUrlPartsparseSasQueryParameters(String queryParams)Sets theCommonSasQueryParametersrepresenting the SAS query parameters that will be used to generate the SAS token for this URL.BlobUrlPartssetAccountName(String accountName)Sets the account name.BlobUrlPartssetBlobName(String blobName)Sets the blob name that will be used as part of the URL path.BlobUrlPartssetCommonSasQueryParameters(CommonSasQueryParameters commonSasQueryParameters)Sets theCommonSasQueryParametersrepresenting the SAS query parameters that will be used to generate the SAS token for this URL.BlobUrlPartssetContainerName(String containerName)Sets the container name that will be used as part of the URL path.BlobUrlPartssetHost(String host)Sets the URL host, ex.BlobUrlPartssetSasQueryParameters(BlobServiceSasQueryParameters blobServiceSasQueryParameters)Deprecated.BlobUrlPartssetScheme(String scheme)Sets the URL scheme, ex.BlobUrlPartssetSnapshot(String snapshot)Sets the snapshot identifier that will be used as part of the query string if set.BlobUrlPartssetUnparsedParameters(Map<String,String[]> unparsedParameters)Sets the query string parameters that aren't part of the SAS token that will be used by this URL.BlobUrlPartssetVersionId(String versionId)Sets the version identifier that will be used as part of the query string if set.URLtoUrl()Converts the blob URL parts to aURL.
-
-
-
Method Detail
-
getAccountName
public String getAccountName()
Gets the accountname, ex. "myaccountname".- Returns:
- the account name.
-
setAccountName
public BlobUrlParts setAccountName(String accountName)
Sets the account name.- Parameters:
accountName- The account name.- Returns:
- the updated BlobURLParts object.
-
getScheme
public String getScheme()
Gets the URL scheme, ex. "https".- Returns:
- the URL scheme.
-
setScheme
public BlobUrlParts setScheme(String scheme)
Sets the URL scheme, ex. "https".- Parameters:
scheme- The URL scheme.- Returns:
- the updated BlobUrlParts object.
-
getHost
public String getHost()
Gets the URL host, ex. "account.blob.core.windows.net" or "127.0.0.1:10000".- Returns:
- the URL host.
-
setHost
public BlobUrlParts setHost(String host)
Sets the URL host, ex. "account.blob.core.windows.net" or "127.0.0.1:10000".- Parameters:
host- The URL host.- Returns:
- the updated BlobUrlParts object.
-
getBlobContainerName
public String getBlobContainerName()
Gets the container name that will be used as part of the URL path.- Returns:
- the container name.
-
setContainerName
public BlobUrlParts setContainerName(String containerName)
Sets the container name that will be used as part of the URL path.- Parameters:
containerName- The container nme.- Returns:
- the updated BlobUrlParts object.
-
getBlobName
public String getBlobName()
Decodes and gets the blob name that will be used as part of the URL path.- Returns:
- the decoded blob name.
-
setBlobName
public BlobUrlParts setBlobName(String blobName)
Sets the blob name that will be used as part of the URL path.- Parameters:
blobName- The blob name. If the blob name contains special characters, pass in the url encoded version of the blob name.- Returns:
- the updated BlobUrlParts object.
-
getSnapshot
public String getSnapshot()
Gets the snapshot identifier that will be used as part of the query string if set.- Returns:
- the snapshot identifier.
-
setSnapshot
public BlobUrlParts setSnapshot(String snapshot)
Sets the snapshot identifier that will be used as part of the query string if set.- Parameters:
snapshot- The snapshot identifier.- Returns:
- the updated BlobUrlParts object.
-
getVersionId
public String getVersionId()
Gets the version identifier that will be used as part of the query string if set.- Returns:
- the version identifier.
-
setVersionId
public BlobUrlParts setVersionId(String versionId)
Sets the version identifier that will be used as part of the query string if set.- Parameters:
versionId- The version identifier.- Returns:
- the updated BlobUrlParts object.
-
getSasQueryParameters
@Deprecated public BlobServiceSasQueryParameters getSasQueryParameters()
Deprecated.Please usegetCommonSasQueryParameters()Gets theBlobServiceSasQueryParametersrepresenting the SAS query parameters- Returns:
- the
BlobServiceSasQueryParametersof the URL
-
setSasQueryParameters
@Deprecated public BlobUrlParts setSasQueryParameters(BlobServiceSasQueryParameters blobServiceSasQueryParameters)
Deprecated.Sets theBlobServiceSasQueryParametersrepresenting the SAS query parameters.- Parameters:
blobServiceSasQueryParameters- The SAS query parameters.- Returns:
- the updated BlobUrlParts object.
-
getCommonSasQueryParameters
public CommonSasQueryParameters getCommonSasQueryParameters()
Gets theCommonSasQueryParametersrepresenting the SAS query parameters that will be used to generate the SAS token for this URL.- Returns:
- the
CommonSasQueryParametersof the URL
-
setCommonSasQueryParameters
public BlobUrlParts setCommonSasQueryParameters(CommonSasQueryParameters commonSasQueryParameters)
Sets theCommonSasQueryParametersrepresenting the SAS query parameters that will be used to generate the SAS token for this URL.- Parameters:
commonSasQueryParameters- The SAS query parameters.- Returns:
- the updated BlobUrlParts object.
-
parseSasQueryParameters
public BlobUrlParts parseSasQueryParameters(String queryParams)
Sets theCommonSasQueryParametersrepresenting the SAS query parameters that will be used to generate the SAS token for this URL.- Parameters:
queryParams- The SAS query parameter string.- Returns:
- the updated BlobUrlParts object.
-
getUnparsedParameters
public Map<String,String[]> getUnparsedParameters()
Gets the query string parameters that aren't part of the SAS token that will be used by this URL.- Returns:
- the non-SAS token query string values.
-
setUnparsedParameters
public BlobUrlParts setUnparsedParameters(Map<String,String[]> unparsedParameters)
Sets the query string parameters that aren't part of the SAS token that will be used by this URL.- Parameters:
unparsedParameters- The non-SAS token query string values.- Returns:
- the updated BlobUrlParts object.
-
toUrl
public URL toUrl()
Converts the blob URL parts to aURL.- Returns:
- A
URLto the blob resource composed of all the elements in this object. - Throws:
IllegalStateException- The fields present on the BlobUrlParts object were insufficient to construct a valid URL or were ill-formatted.
-
parse
public static BlobUrlParts parse(String url)
Parses a string into a BlobUrlParts.Query parameters will be parsed into two properties,
BlobServiceSasQueryParameterswhich contains all SAS token related values andunparsedParameterswhich is all other query parameters.If a URL points to a blob in the root container, and the root container is referenced implicitly, i.e. there is no path element for the container, the name of this blob in the root container will be set as the containerName field in the resulting
BlobURLParts.- Parameters:
url- TheURLto be parsed.- Returns:
- A
BlobUrlPartsobject containing all the components of a BlobURL. - Throws:
IllegalArgumentException- Ifurlis a malformedURL.
-
parse
public static BlobUrlParts parse(URL url)
Parses an existing URL into a BlobUrlParts.Query parameters will be parsed into two properties,
BlobServiceSasQueryParameterswhich contains all SAS token related values andunparsedParameterswhich is all other query parameters.If a URL points to a blob in the root container, and the root container is referenced implicitly, i.e. there is no path element for the container, the name of this blob in the root container will be set as the containerName field in the resulting
BlobURLParts.- Parameters:
url- TheURLto be parsed.- Returns:
- A
BlobUrlPartsobject containing all the components of a BlobURL.
-
-