MediaThumbnail.java (2111B)
1 /* 2 * Copyright (C) 2010 A. Horn 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.mcsoxford.rss; 18 19 /** 20 * Immutable class for media thumbnail RSS 2.0 data. 21 * 22 * @author Mr Horn 23 * @see http://search.yahoo.com/mrss/ 24 */ 25 public final class MediaThumbnail { 26 27 private final android.net.Uri url; 28 private final int height; 29 private final int width; 30 31 /** 32 * Returns the URL of the thumbnail. 33 * The return value is never {@code null}. 34 */ 35 public android.net.Uri getUrl() { 36 return url; 37 } 38 39 /** 40 * Returns the thumbnail's height or {@code -1} if unspecified. 41 */ 42 public int getHeight() { 43 return height; 44 } 45 46 /** 47 * Returns the thumbnail's width or {@code -1} if unspecified. 48 */ 49 public int getWidth() { 50 return width; 51 } 52 53 /* Internal constructor for RSSHandler */ 54 MediaThumbnail(android.net.Uri url, int height, int width) { 55 this.url = url; 56 this.height = height; 57 this.width = width; 58 } 59 60 /** 61 * Returns the thumbnail's URL as a string. 62 */ 63 public String toString() { 64 return url.toString(); 65 } 66 67 /** 68 * Returns the hash code of the thumbnail's URL. 69 */ 70 @Override 71 public int hashCode() { 72 return url.hashCode(); 73 } 74 75 /** 76 * Compares the URLs of two thumbnails for equality. 77 */ 78 @Override 79 public boolean equals(Object object) { 80 if (this == object) { 81 return true; 82 } else if (object instanceof MediaThumbnail) { 83 final MediaThumbnail other = (MediaThumbnail) (object); 84 85 /* other is not null */ 86 return url.equals(other.url); 87 } else { 88 return false; 89 } 90 } 91 92 } 93