Shuyi Chen | d7955ce | 2013-05-22 14:51:55 -0700 | [diff] [blame] | 1 | /** |
| 2 | * $Revision$ |
| 3 | * $Date$ |
| 4 | * |
| 5 | * Copyright 2003-2007 Jive Software. |
| 6 | * |
| 7 | * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | */ |
| 19 | |
| 20 | package org.jivesoftware.smackx.bookmark; |
| 21 | |
| 22 | /** |
| 23 | * Respresents one instance of a URL defined using JEP-0048 Bookmark Storage JEP. |
| 24 | * |
| 25 | * @author Derek DeMoro |
| 26 | */ |
| 27 | public class BookmarkedURL implements SharedBookmark { |
| 28 | |
| 29 | private String name; |
| 30 | private final String URL; |
| 31 | private boolean isRss; |
| 32 | private boolean isShared; |
| 33 | |
| 34 | protected BookmarkedURL(String URL) { |
| 35 | this.URL = URL; |
| 36 | } |
| 37 | |
| 38 | protected BookmarkedURL(String URL, String name, boolean isRss) { |
| 39 | this.URL = URL; |
| 40 | this.name = name; |
| 41 | this.isRss = isRss; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Returns the name representing the URL (eg. Jive Software). This can be used in as a label, or |
| 46 | * identifer in applications. |
| 47 | * |
| 48 | * @return the name reprenting the URL. |
| 49 | */ |
| 50 | public String getName() { |
| 51 | return name; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Sets the name representing the URL. |
| 56 | * |
| 57 | * @param name the name. |
| 58 | */ |
| 59 | protected void setName(String name) { |
| 60 | this.name = name; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Returns the URL. |
| 65 | * |
| 66 | * @return the url. |
| 67 | */ |
| 68 | public String getURL() { |
| 69 | return URL; |
| 70 | } |
| 71 | /** |
| 72 | * Set to true if this URL is an RSS or news feed. |
| 73 | * |
| 74 | * @param isRss True if the URL is a news feed and false if it is not. |
| 75 | */ |
| 76 | protected void setRss(boolean isRss) { |
| 77 | this.isRss = isRss; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Returns true if this URL is a news feed. |
| 82 | * |
| 83 | * @return Returns true if this URL is a news feed. |
| 84 | */ |
| 85 | public boolean isRss() { |
| 86 | return isRss; |
| 87 | } |
| 88 | |
| 89 | public boolean equals(Object obj) { |
| 90 | if(!(obj instanceof BookmarkedURL)) { |
| 91 | return false; |
| 92 | } |
| 93 | BookmarkedURL url = (BookmarkedURL)obj; |
| 94 | return url.getURL().equalsIgnoreCase(URL); |
| 95 | } |
| 96 | |
| 97 | protected void setShared(boolean shared) { |
| 98 | this.isShared = shared; |
| 99 | } |
| 100 | |
| 101 | public boolean isShared() { |
| 102 | return isShared; |
| 103 | } |
| 104 | } |