001/** 002 * Copyright 2011 Bill Brown 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.colorfulsoftware.rss; 017 018import java.io.Serializable; 019 020/** 021 * <p> 022 * The <title> element. 023 * </p> 024 * <p> 025 * From the <a href="http://cyber.law.harvard.edu/rss/rss.html">RSS 2.0 026 * specification</a>... 027 * </p> 028 * <p> 029 * For Channel: The name of the channel. It's how people refer to your service. 030 * If you have an HTML website that contains the same information as your RSS 031 * file, the title of your channel should be the same as the title of your 032 * website. 033 * </p> 034 * 035 * <p> 036 * For Item: The title of the item. 037 * </p> 038 * 039 * @author Bill Brown 040 * 041 */ 042public class Title implements Serializable { 043 044 private static final long serialVersionUID = -8102075738201739128L; 045 046 private final String title; 047 048 Title(String title) throws RSSpectException { 049 if (title == null || title.equals("")) { 050 throw new RSSpectException("title SHOULD NOT be blank."); 051 } 052 this.title = title; 053 } 054 055 Title(Title title) { 056 this.title = title.title; 057 } 058 059 /** 060 * @return the title. 061 */ 062 public String getTitle() { 063 return title; 064 } 065 066 /** 067 * Shows the contents of the <title> element. 068 */ 069 @Override 070 public String toString() { 071 return "<title>" + title + "</title>"; 072 } 073 074 @Override 075 public boolean equals(Object obj) { 076 if (obj == this) { 077 return true; 078 } 079 if (!(obj instanceof Title)) { 080 return false; 081 } 082 return this.toString().equals(obj.toString()); 083 } 084 085 @Override public int hashCode() { 086 return toString().hashCode(); 087 } 088}