public class StorageResourceId extends Object
| Modifier and Type | Field and Description |
|---|---|
static StorageResourceId |
ROOT |
static long |
UNKNOWN_GENERATION_ID |
| Constructor and Description |
|---|
StorageResourceId(String bucketName)
Constructor for a StorageResourceId representing a Bucket;
getObjectName() will return
null for a StorageResourceId that represents a Bucket. |
StorageResourceId(String bucketName,
long generationId)
Constructor for a StorageResourceId representing a full StorageObject, including bucketName and
objectName.
|
StorageResourceId(String bucketName,
String objectName)
Constructor for a StorageResourceId representing a full StorageObject, including bucketName and
objectName.
|
StorageResourceId(String bucketName,
String objectName,
long generationId)
Constructor for a StorageResourceId representing a full StorageObject, including bucketName and
objectName.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
static StorageResourceId |
fromStringPath(String path)
Parses
StorageResourceId from specified string. |
static StorageResourceId |
fromStringPath(String path,
long generationId)
Parses
StorageResourceId from specified string and generationId. |
static StorageResourceId |
fromUriPath(URI path,
boolean allowEmptyObjectName)
Validates the given URI and if valid, returns the associated StorageResourceId.
|
static StorageResourceId |
fromUriPath(URI path,
boolean allowEmptyObjectName,
long generationId)
Validates the given URI and if valid, returns the associated StorageResourceId.
|
String |
getBucketName()
Gets the bucket name component of this resource identifier.
|
long |
getGenerationId()
The generationId to be used with precondition checks when using this StorageResourceId as an
identifier for mutation requests.
|
String |
getObjectName()
Gets the object name component of this resource identifier.
|
boolean |
hasGenerationId()
Returns true if generationId is not UNKNOWN_GENERATION_ID.
|
int |
hashCode() |
boolean |
isBucket()
Returns true if this StorageResourceId represents a GCS Bucket; if true, then
getObjectName will return null. |
boolean |
isDirectory()
Indicates if this StorageResourceId corresponds to a 'directory'; similar to
FileInfo.isDirectory() except deals entirely with pathnames instead of also checking for
exists() to be true on a corresponding GoogleCloudStorageItemInfo. |
boolean |
isRoot()
Returns true if this StorageResourceId represents the GCS root (gs://); if true, then both
getBucketName and getObjectName will be null. |
boolean |
isStorageObject()
Returns true if this StorageResourceId represents a GCS StorageObject; if true, both
getBucketName and getObjectName will be non-empty and non-null. |
StorageResourceId |
toDirectoryId()
Converts StorageResourceId instance to look like a directory path.
|
String |
toString()
Returns a string of the form
gs://<bucketName>/<objectName>. |
public static final long UNKNOWN_GENERATION_ID
public static final StorageResourceId ROOT
public StorageResourceId(String bucketName)
getObjectName() will return
null for a StorageResourceId that represents a Bucket.bucketName - The bucket name of the resource. Must be non-empty and non-null.public StorageResourceId(String bucketName, String objectName)
bucketName - The bucket name of the resource. Must be non-empty and non-null.objectName - The object name of the resource. Must be non-empty and non-null.public StorageResourceId(String bucketName, String objectName, long generationId)
bucketName - The bucket name of the resource. Must be non-empty and non-null.objectName - The object name of the resource. Must be non-empty and non-null.generationId - The generationId to be used with precondition checks when using this
StorageResourceId as an identifier for mutation requests.public StorageResourceId(String bucketName, long generationId)
bucketName - The bucket name of the resource. Must be non-empty and non-null.generationId - The generationId to be used with precondition checks when using this
StorageResourceId as an identifier for mutation requests.public boolean isStorageObject()
getBucketName and getObjectName will be non-empty and non-null.public boolean isBucket()
getObjectName will return null.public boolean isRoot()
getBucketName and getObjectName will be null.public boolean isDirectory()
FileInfo.isDirectory() except deals entirely with pathnames instead of also checking for
exists() to be true on a corresponding GoogleCloudStorageItemInfo.public String getBucketName()
public String getObjectName()
public long getGenerationId()
public boolean hasGenerationId()
public String toString()
gs://<bucketName>/<objectName>.public StorageResourceId toDirectoryId()
public static StorageResourceId fromStringPath(String path)
StorageResourceId from specified string.public static StorageResourceId fromStringPath(String path, long generationId)
StorageResourceId from specified string and generationId.public static StorageResourceId fromUriPath(URI path, boolean allowEmptyObjectName)
path - The GCS URI to validate.allowEmptyObjectName - If true, a missing object name is not considered invalid.public static StorageResourceId fromUriPath(URI path, boolean allowEmptyObjectName, long generationId)
path - The GCS URI to validate.allowEmptyObjectName - If true, a missing object name is not considered invalid.generationId - The generationId to be used with precondition checks when using thisCopyright © 2022. All rights reserved.