001/**
002 *
003 * Copyright 2003-2007 Jive Software.
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.jivesoftware.smackx.bookmarks;
019
020/**
021 * Respresents one instance of a URL defined using XEP-0048 Bookmark Storage XEP.
022 *
023 * @author Derek DeMoro
024 */
025public class BookmarkedURL implements SharedBookmark {
026
027    private String name;
028    private final String URL;
029    private boolean isRss;
030    private boolean isShared;
031
032    protected BookmarkedURL(String URL) {
033        this.URL = URL;
034    }
035
036    protected BookmarkedURL(String URL, String name, boolean isRss) {
037        this.URL = URL;
038        this.name = name;
039        this.isRss = isRss;
040    }
041
042    /**
043     * Returns the name representing the URL (eg. Jive Software). This can be used in as a label, or
044     * identifer in applications.
045     *
046     * @return the name reprenting the URL.
047     */
048    public String getName() {
049        return name;
050    }
051
052    /**
053     * Sets the name representing the URL.
054     *
055     * @param name the name.
056     */
057    protected void setName(String name) {
058        this.name = name;
059    }
060
061    /**
062     * Returns the URL.
063     *
064     * @return the url.
065     */
066    public String getURL() {
067        return URL;
068    }
069    /**
070     * Set to true if this URL is an RSS or news feed.
071     *
072     * @param isRss True if the URL is a news feed and false if it is not.
073     */
074    protected void setRss(boolean isRss) {
075        this.isRss = isRss;
076    }
077
078    /**
079     * Returns true if this URL is a news feed.
080     *
081     * @return Returns true if this URL is a news feed.
082     */
083    public boolean isRss() {
084        return isRss;
085    }
086
087    public boolean equals(Object obj) {
088        if(!(obj instanceof BookmarkedURL)) {
089            return false;
090        }
091        BookmarkedURL url = (BookmarkedURL)obj;
092        return url.getURL().equalsIgnoreCase(URL);
093    }
094
095    protected void setShared(boolean shared) {
096        this.isShared = shared;
097    }
098
099    public boolean isShared() {
100        return isShared;
101    }
102}