Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2013 Google Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 
 package com.google.cloud.hadoop.gcsio;
 
 
 import java.util.Date;
 import java.util.Map;
Contains information about an item in Google Cloud Storage.
 
 public class GoogleCloudStorageItemInfo {
   // Info about the root of GCS namespace.
   public static final GoogleCloudStorageItemInfo ROOT_INFO =
       new GoogleCloudStorageItemInfo(., 0, 0, nullnull);
 
   // Instead of returning null metadata, we'll return this map.
   private static final Map<Stringbyte[]> EMPTY_METADATA = ImmutableMap.of();
 
   // The Bucket and maybe StorageObject names of the GCS "item" referenced by this object. Not null.
   private final StorageResourceId resourceId;
 
   // Creation time of this item.
   // Time is expressed as milliseconds since January 1, 1970 UTC.
   private final long creationTime;
 
   // Size of an object (number of bytes).
   // Size is -1 for items that do not exist.
   private final long size;
 
   // Location of this item.
   private final String location;
 
   // Storage class of this item.
   private final String storageClass;
 
   // Content-Type of this item
   private final String contentType;
 
   // User-supplied metadata.
   private final Map<Stringbyte[]> metadata;
   private final long contentGeneration;
   private final long metaGeneration;

  
Constructs an instance of GoogleCloudStorageItemInfo.

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.
 
       long creationTimelong sizeString locationString storageClass) {
     this(
         resourceId,
         creationTime,
         size,
         location,
         storageClass,
         null,
         ImmutableMap.<Stringbyte[]>of(),
         0 /* content generation */,
         0 /* meta generation */);
   }

  
Constructs an instance of GoogleCloudStorageItemInfo.

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.
 
       StorageResourceId resourceId,
       long creationTime,
       long size,
       String location,
       String storageClass,
       String contentType,
       Map<Stringbyte[]> metadata,
       long contentGeneration,
      long metaGeneration) {
    Preconditions.checkArgument(resourceId != null,
        "resourceId must not be null! Use StorageResourceId.ROOT to represent GCS root.");
    this. = resourceId;
    this. = creationTime;
    this. = size;
    this. = location;
    this. = storageClass;
    this. = contentType;
    if (metadata == null) {
      this. = ;
    } else {
      this. = metadata;
    }
    this. = contentGeneration;
    this. = metaGeneration;
  }

  
Gets bucket name of this item.
  public String getBucketName() {
    return .getBucketName();
  }

  
Gets object name of this item.
  public String getObjectName() {
    return .getObjectName();
  }

  
Gets the resourceId that holds the (possibly null) bucketName and objectName of this object.
    return ;
  }

  
Gets creation time of this item. Time is expressed as milliseconds since January 1, 1970 UTC.
  public long getCreationTime() {
    return ;
  }

  
Gets size of this item (number of bytes). Returns -1 if the object does not exist.
  public long getSize() {
    return ;
  }

  
Gets location of this item. Note: Location is only supported for buckets. The value is always null for objects.
  public String getLocation() {
    return ;
  }

  
Gets storage class of this item. Note: Storage-class is only supported for buckets. The value is always null for objects.
  public String getStorageClass() {
    return ;
  }

  
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.
  public String getContentType() {
    return ;
  }

  
Gets user-supplied metadata for this item. Note: metadata is only supported for objects. This value is always an empty map for buckets.
  public Map<Stringbyte[]> getMetadata() {
    return ;
  }

  
Indicates whether this item is a bucket. Root is not considered to be a bucket.
  public boolean isBucket() {
    return .isBucket();
  }

  
Indicates whether this item refers to the GCS root (gs://).
  public boolean isRoot() {
    return .isRoot();
  }

  
Indicates whether this item exists.
  public boolean exists() {
    return  >= 0;
  }

  
Get the content generation of the object.
  public long getContentGeneration() {
    return ;
  }

  
Get the meta generation of the object.
  public long getMetaGeneration() {
    return ;
  }

  
Gets string representation of this instance.
  public String toString() {
    if (exists()) {
      return String.format("%s: created on: %s",
          , (new Date()).toString());
    } else {
      return String.format("%s: exists: no".toString());
    }
  }
  public boolean equals(Object obj) {
    if (obj instanceof GoogleCloudStorageItemInfo) {
      return .equals(other.resourceId
          &&  == other.creationTime 
          &&  == other.size 
          && Objects.equals(other.location
          && Objects.equals(other.storageClass)
          &&  == other.metaGeneration
          &&  == other.contentGeneration;
    }
    return false;
  }
New to GrepCode? Check out our FAQ X