github.com/olivere/camlistore@v0.0.0-20140121221811-1b7ac2da0199/clients/android/src/org/camlistore/QueuedFile.java (about) 1 /* 2 Copyright 2011 Google Inc. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package org.camlistore; 18 19 import android.net.Uri; 20 21 /** 22 * Immutable struct for tuple (sha1 blobRef, URI to upload, size of blob). 23 */ 24 public class QueuedFile { 25 26 private final Uri mUri; 27 private final long mSize; 28 private final String mDiskPath; // or null if it can't be resolved. 29 30 public QueuedFile(Uri uri, long size, String diskPath) { 31 if (uri == null) { 32 throw new NullPointerException("uri == null"); 33 } 34 mUri = uri; 35 mSize = size; 36 mDiskPath = diskPath; 37 } 38 39 public Uri getUri() { 40 return mUri; 41 } 42 43 public long getSize() { 44 return mSize; 45 } 46 47 // getDiskPath may return null, if the URI couldn't be resolved to a path on disk. 48 public String getDiskPath() { 49 return mDiskPath; 50 } 51 52 @Override 53 public String toString() { 54 return "QueuedFile [mSize=" + mSize + ", mUri=" + mUri + "]"; 55 } 56 57 @Override 58 public int hashCode() { 59 final int prime = 31; 60 int result = 1; 61 result = prime * result + (int) (mSize ^ (mSize >>> 32)); 62 result = prime * result + ((mUri == null) ? 0 : mUri.hashCode()); 63 return result; 64 } 65 66 @Override 67 public boolean equals(Object obj) { 68 if (this == obj) 69 return true; 70 if (obj == null) 71 return false; 72 if (getClass() != obj.getClass()) 73 return false; 74 QueuedFile other = (QueuedFile) obj; 75 if (mSize != other.mSize) 76 return false; 77 if (mUri == null) { 78 if (other.mUri != null) 79 return false; 80 } else if (!mUri.equals(other.mUri)) 81 return false; 82 return true; 83 } 84 }