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 <description> 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: Phrase or sentence describing the channel. 030 * </p> 031 * 032 * <p> 033 * For Item: The item synopsis. 034 * </p> 035 * 036 * @author Bill Brown 037 * 038 */ 039public class Description implements Serializable { 040 041 private static final long serialVersionUID = -3376088317656959708L; 042 043 private final String description; 044 045 Description(String description) { 046 // not sure why, but descriptions can be blank. 047 this.description = (description == null) ? "" : description; 048 } 049 050 Description(Description description){ 051 this.description = description.description; 052 } 053 054 /** 055 * @return the description (can be the empty string). 056 */ 057 public String getDescription() { 058 return description; 059 } 060 061 /** 062 * Shows the contents of the <description> element. 063 */ 064 @Override 065 public String toString() { 066 return "<description>" + description + "</description>"; 067 } 068 069 @Override 070 public boolean equals(Object obj) { 071 if (obj == this) { 072 return true; 073 } 074 if (!(obj instanceof Description)) { 075 return false; 076 } 077 return this.toString().equals(obj.toString()); 078 } 079 080 @Override public int hashCode() { 081 return toString().hashCode(); 082 } 083}