App Engine Python SDK version 1.7.4 (2)
[gae.git] / java / src / main / com / google / appengine / api / blobstore / BlobKey.java
blob30bdcaf76cd54ef30ba82080fd34d139eeda7a44
1 // Copyright 2009 Google Inc. All rights reserved.
3 package com.google.appengine.api.blobstore;
5 import java.io.Serializable;
7 /**
8 * {@code BlobKey} contains the string identifier of a large (possibly
9 * larger than 1MB) blob of binary data that was uploaded in a
10 * previous request and can be streamed directly to users.
13 public final class BlobKey implements Serializable, Comparable<BlobKey> {
14 private final String blobKey;
16 /**
17 * Construct a new {@code BlobKey} with the specified key string.
19 * @throws IllegalArgumentException If the specified string was null.
21 public BlobKey(String blobKey) {
22 if (blobKey == null) {
23 throw new IllegalArgumentException("Argument must not be null.");
25 this.blobKey = blobKey;
28 /**
29 * Returns the blob key as a String.
31 public String getKeyString() {
32 return blobKey;
35 @Override
36 public int hashCode() {
37 return blobKey.hashCode();
40 /**
41 * Two {@code BlobKey} objects are considered equal if they point
42 * to the same blobs.
44 @Override
45 public boolean equals(Object object) {
46 if (object instanceof BlobKey) {
47 BlobKey key = (BlobKey) object;
48 return key.blobKey.equals(blobKey);
50 return false;
53 @Override
54 public String toString() {
55 return "<BlobKey: " + blobKey + ">";
58 public int compareTo(BlobKey o) {
59 return blobKey.compareTo(o.blobKey);