android-ibc-forum

Unnamed repository; edit this file 'description' to name the repository.
git clone http://git.code.weiherhei.de/android-ibc-forum.git
Log | Files | Refs

RSSBase.java (2922B)


      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 import java.io.Serializable;
     20 import java.util.ArrayList;
     21 
     22 import de.mtbnews.android.tapatalk.wrapper.ListEntry;
     23 
     24 /**
     25  * Common data about RSS feeds and items.
     26  * 
     27  * @author Mr Horn
     28  */
     29 abstract class RSSBase implements Serializable, ListEntry
     30 {
     31 
     32 	private String title;
     33 	private android.net.Uri link;
     34 	private String description;
     35 	private java.util.List<String> categories;
     36 	private java.util.Date pubdate;
     37 
     38 	/**
     39 	 * Specify initial capacity for the List which contains the category names.
     40 	 */
     41 	RSSBase(byte categoryCapacity)
     42 	{
     43 		categories = categoryCapacity == 0 ? null : new ArrayList<String>(
     44 				categoryCapacity);
     45 	}
     46 
     47 	public String getTitle()
     48 	{
     49 		return title;
     50 	}
     51 
     52 	public String getDescription()
     53 	{
     54 		return description;
     55 	}
     56 
     57 	public android.net.Uri getLink()
     58 	{
     59 		return link;
     60 	}
     61 
     62 	public java.util.List<String> getCategories()
     63 	{
     64 		if (categories == null)
     65 		{
     66 			return java.util.Collections.emptyList();
     67 		}
     68 
     69 		return java.util.Collections.unmodifiableList(categories);
     70 	}
     71 
     72 	public java.util.Date getPubDate()
     73 	{
     74 		return pubdate;
     75 	}
     76 	
     77 	public java.util.Date getDate()
     78 	{
     79 		return this.getPubDate();
     80 	}
     81 
     82 	void setTitle(String title)
     83 	{
     84 		this.title = title;
     85 	}
     86 
     87 	void setLink(android.net.Uri link)
     88 	{
     89 		this.link = link;
     90 	}
     91 
     92 	void setDescription(String description)
     93 	{
     94 		this.description = description;
     95 	}
     96 
     97 	void addCategory(String category)
     98 	{
     99 		if (categories == null)
    100 		{
    101 			categories = new ArrayList<String>(3);
    102 		}
    103 
    104 		this.categories.add(category);
    105 	}
    106 
    107 	void setPubDate(java.util.Date pubdate)
    108 	{
    109 		this.pubdate = pubdate;
    110 	}
    111 
    112 	/**
    113 	 * Returns the title.
    114 	 */
    115 	public String toString()
    116 	{
    117 		return title;
    118 	}
    119 
    120 	/**
    121 	 * Returns the hash code of the link.
    122 	 */
    123 	@Override
    124 	public int hashCode()
    125 	{
    126 		if (link == null)
    127 		{
    128 			return 0;
    129 		}
    130 
    131 		return link.hashCode();
    132 	}
    133 
    134 	/**
    135 	 * Compares the links for equality.
    136 	 */
    137 	@Override
    138 	public boolean equals(Object object)
    139 	{
    140 		if (this == object)
    141 		{
    142 			return true;
    143 		}
    144 		else if (object instanceof RSSBase)
    145 		{
    146 			/* other is never null */
    147 			final RSSBase other = (RSSBase) (object);
    148 
    149 			if (link == null)
    150 			{
    151 				return other.link == null;
    152 			}
    153 
    154 			return link.equals(other.link);
    155 		}
    156 		else
    157 		{
    158 			return false;
    159 		}
    160 	}
    161 
    162 	
    163 	public String getName() {
    164 		return null;
    165 	}
    166 	
    167 	public String getContent() {
    168 		return getDescription();
    169 	}
    170 }