Class GoogleCloudStorageItemInfo


  • public class GoogleCloudStorageItemInfo
    extends Object
    Contains information about an item in Google Cloud Storage.
    • Method Detail

      • createBucket

        public static GoogleCloudStorageItemInfo createBucket​(StorageResourceId resourceId,
                                                              long creationTime,
                                                              long modificationTime,
                                                              String location,
                                                              String storageClass)
        Factory method for creating a GoogleCloudStorageItemInfo for a bucket.
        Parameters:
        resourceId - Resource ID that identifies a bucket
        creationTime - Time when a bucket was created (milliseconds since January 1, 1970 UTC).
        modificationTime - Time when a bucket was last modified (milliseconds since January 1, 1970 UTC).
        location - Location of a bucket.
        storageClass - Storage class of a bucket.
      • createObject

        public static GoogleCloudStorageItemInfo createObject​(StorageResourceId resourceId,
                                                              long creationTime,
                                                              long modificationTime,
                                                              long size,
                                                              String contentType,
                                                              String contentEncoding,
                                                              Map<String,​byte[]> metadata,
                                                              long contentGeneration,
                                                              long metaGeneration,
                                                              VerificationAttributes verificationAttributes)
        Factory method for creating a GoogleCloudStorageItemInfo for an object.
        Parameters:
        resourceId - identifies either root, a Bucket, or a StorageObject
        creationTime - Time when object was created (milliseconds since January 1, 1970 UTC).
        size - Size of the given object (number of bytes) or -1 if the object does not exist.
        metadata - User-supplied object metadata for this object.
      • createFolder

        public static GoogleCloudStorageItemInfo createFolder​(StorageResourceId resourceId,
                                                              com.google.storage.control.v2.Folder folder)
        Factory method for creating a GoogleCloudStorageItemInfo from a native HNS Folder.
        Parameters:
        resourceId - The resource ID of the folder.
        folder - The Folder object from the Storage Control API.
      • createInferredDirectory

        public static GoogleCloudStorageItemInfo createInferredDirectory​(StorageResourceId resourceId)
        Factory method for creating a "found" GoogleCloudStorageItemInfo for an inferred directory.
        Parameters:
        resourceId - Resource ID that identifies an inferred directory
      • createNotFound

        public static GoogleCloudStorageItemInfo createNotFound​(StorageResourceId resourceId)
        Factory method for creating a "not found" GoogleCloudStorageItemInfo for a bucket or an object.
        Parameters:
        resourceId - Resource ID that identifies an inferred directory
      • getBucketName

        public String getBucketName()
        Gets bucket name of this item.
      • getObjectName

        public String getObjectName()
        Gets object name of this item.
      • getResourceId

        public StorageResourceId getResourceId()
        Gets the resourceId that holds the (possibly null) bucketName and objectName of this object.
      • getCreationTime

        public long getCreationTime()
        Gets creation time of this item.

        Time is expressed as milliseconds since January 1, 1970 UTC.

      • getModificationTime

        public long getModificationTime()
        Gets modification time of this item.

        Time is expressed as milliseconds since January 1, 1970 UTC.

      • getSize

        public long getSize()
        Gets size of this item (number of bytes). Returns -1 if the object does not exist.
      • getLocation

        public String getLocation()
        Gets location of this item.

        Note: Location is only supported for buckets. The value is always null for objects.

      • getStorageClass

        public String getStorageClass()
        Gets storage class of this item.

        Note: Storage-class is only supported for buckets. The value is always null for objects.

      • getContentType

        public String getContentType()
        Gets the content-type of this item, or null if unknown or inapplicable.

        Note: content-type is only supported for objects, and will always be null for buckets.

      • getContentEncoding

        public String getContentEncoding()
        Gets the content-encoding of this item, or null if unknown or inapplicable.

        Note: content-encoding is only supported for objects, and will always be null for buckets.

      • getMetadata

        public Map<String,​byte[]> getMetadata()
        Gets user-supplied metadata for this item.

        Note: metadata is only supported for objects. This value is always an empty map for buckets.

      • isBucket

        public boolean isBucket()
        Indicates whether this item is a bucket. Root is not considered to be a bucket.
      • isRoot

        public boolean isRoot()
        Indicates whether this item refers to the GCS root (gs://).
      • isGlobalRoot

        public boolean isGlobalRoot()
        Indicates whether this instance has information about the unique, shared root of the underlying storage system.
      • isNativeHNSFolder

        public boolean isNativeHNSFolder()
        Indicates whether itemInfo is a native HNS folder. This is different from a placeholder object or an inferred directory.
      • isDirectory

        public boolean isDirectory()
        Indicates whether itemInfo is a directory.
      • isInferredDirectory

        public boolean isInferredDirectory()
        Indicates whether itemInfo is an inferred directory
      • getContentGeneration

        public long getContentGeneration()
        Get the content generation of the object.
      • getMetaGeneration

        public long getMetaGeneration()
        Get the meta generation of the object.
      • getVerificationAttributes

        public VerificationAttributes getVerificationAttributes()
        Get object validation attributes.
      • exists

        public boolean exists()
        Indicates whether this item exists.
      • metadataEquals

        public boolean metadataEquals​(Map<String,​byte[]> otherMetadata)
        Helper for checking logical equality of metadata maps, checking equality of keySet() between this.metadata and otherMetadata, and then using Arrays.equals to compare contents of corresponding byte arrays.
      • toString

        public String toString()
        Gets string representation of this instance.
        Overrides:
        toString in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object