Class InMemoryObjectEntry


  • public class InMemoryObjectEntry
    extends Object
    InMemoryObjectEntry represents a GCS StorageObject in-memory by maintaining byte[] contents alongside channels and metadata allowing interaction with the data in a similar way to the equivalent GCS API calls. Intended to be used only internally by the InMemoryGoogleCloudStorage class.
    • Constructor Detail

      • InMemoryObjectEntry

        public InMemoryObjectEntry​(String bucketName,
                                   String objectName,
                                   long createTimeMillis,
                                   long modificationTimeMillis,
                                   String contentType,
                                   String contentEncoding,
                                   Map<String,​byte[]> metadata)
      • InMemoryObjectEntry

        public InMemoryObjectEntry​(GoogleCloudStorageItemInfo itemInfo)
        Constructor for creating an InMemoryObjectEntry from a pre-existing, read-only GoogleCloudStorageItemInfo. This is used to simulate metadata-only entities like Native Folders.
        Parameters:
        itemInfo - The item info to represent. Must be for a folder or a zero-byte object.
    • Method Detail

      • getObjectName

        public String getObjectName()
        Returns the objectName initially provided at construction-time of this InMemoryObjectEntry; it will never change over the lifetime of this InMemoryObjectEntry.
      • getBucketName

        public String getBucketName()
        Returns the bucketName initially provided at construction-time of this InMemoryObjectEntry; it will never change over the lifetime of this InMemoryObjectEntry.
      • getShallowCopy

        public InMemoryObjectEntry getShallowCopy​(String bucketName,
                                                  String objectName)
                                           throws IOException
        Returns a copy of this InMemoryObjectEntry which shares the underlying completedContents data; it is illegal to call this method if the write channel has not yet been closed.
        Throws:
        IOException
      • getWriteChannel

        public WritableByteChannel getWriteChannel()
                                            throws IOException
        Returns a WritableByteChannel for this InMemoryObjectEntry's byte contents; the same channel is returned on each call, and it is illegal to call this method if the channel has ever been closed already.
        Throws:
        IOException
      • getReadChannel

        public SeekableByteChannel getReadChannel​(String bucketName,
                                                  String objectName,
                                                  GoogleCloudStorageReadOptions readOptions)
                                           throws IOException
        Returns a SeekableByteChannel pointing at this InMemoryObjectEntry's byte contents; a previous writer must have already closed the associated WritableByteChannel to commit the byte contents and make them available for reading.
        Throws:
        IOException
      • getInfo

        public GoogleCloudStorageItemInfo getInfo()
        Gets the GoogleCloudStorageItemInfo associated with this InMemoryObjectEntry, whose 'size' is only updated when the initial writer has finished closing the channel.
      • patchMetadata

        public void patchMetadata​(Map<String,​byte[]> newMetadata)
                           throws IOException
        Updates the metadata associated with this InMemoryObjectEntry. Any key in newMetadata which has a corresponding null value will be removed from the object's metadata. All other values will be added.
        Throws:
        IOException