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 the parse(URL) class. You may construct a URL from parts by calling toUrl().
  • Constructor Details

    • BlobUrlParts

      public BlobUrlParts()
      Initializes a BlobUrlParts object which helps aid in the construction of a Blob Storage URL.
  • Method Details

    • 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.
      Gets the BlobServiceSasQueryParameters representing the SAS query parameters
      Returns:
      the BlobServiceSasQueryParameters of the URL
    • setSasQueryParameters

      @Deprecated public BlobUrlParts setSasQueryParameters(BlobServiceSasQueryParameters blobServiceSasQueryParameters)
      Sets the BlobServiceSasQueryParameters representing the SAS query parameters.
      Parameters:
      blobServiceSasQueryParameters - The SAS query parameters.
      Returns:
      the updated BlobUrlParts object.
    • getCommonSasQueryParameters

      public CommonSasQueryParameters getCommonSasQueryParameters()
      Gets the CommonSasQueryParameters representing the SAS query parameters that will be used to generate the SAS token for this URL.
      Returns:
      the CommonSasQueryParameters of the URL
    • setCommonSasQueryParameters

      public BlobUrlParts setCommonSasQueryParameters(CommonSasQueryParameters commonSasQueryParameters)
      Sets the CommonSasQueryParameters representing 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 the CommonSasQueryParameters representing 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 a URL.
      Returns:
      A URL to 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, BlobServiceSasQueryParameters which contains all SAS token related values and unparsedParameters which 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 - The URL to be parsed.
      Returns:
      A BlobUrlParts object containing all the components of a BlobURL.
      Throws:
      IllegalArgumentException - If url is a malformed URL.
    • parse

      public static BlobUrlParts parse(URL url)
      Parses an existing URL into a BlobUrlParts.

      Query parameters will be parsed into two properties, BlobServiceSasQueryParameters which contains all SAS token related values and unparsedParameters which 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 - The URL to be parsed.
      Returns:
      A BlobUrlParts object containing all the components of a BlobURL.