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 <comments> 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 * URL of a page for comments relating to the item. <a href= 030 * "http://cyber.law.harvard.edu/rss/rss.html#ltcommentsgtSubelementOfLtitemgt" 031 * >More</a>. 032 * </p> 033 * 034 * <p> 035 * <comments> is an optional sub-element of <item>. 036 * </p> 037 * 038 * <p> 039 * If present, it is the url of the comments page for the item. 040 * </p> 041 * 042 * <p> 043 * <comments>http://ekzemplo.com/entry/4403/comments</comments> 044 * </p> 045 * 046 * <p> 047 * More about comments <a 048 * href="http://cyber.law.harvard.edu/rss/weblogComments.html">here</a>. 049 * </p> 050 * 051 * @author Bill Brown 052 * 053 */ 054public class Comments implements Serializable { 055 056 /** 057 * 058 */ 059 private static final long serialVersionUID = -2013605887767981438L; 060 061 private final String comments; 062 063 Comments(String comments) throws RSSpectException { 064 if (comments == null || comments.equals("")) { 065 throw new RSSpectException("comments SHOULD NOT be blank."); 066 } 067 this.comments = comments; 068 } 069 070 Comments(Comments comments) { 071 this.comments = comments.comments; 072 } 073 074 /** 075 * @return the comments url. 076 */ 077 public String getComments() { 078 return comments; 079 } 080 081 /** 082 * Shows the contents of the <comments> element. 083 */ 084 @Override 085 public String toString() { 086 return "<comments>" + comments + "</comments>"; 087 } 088 089 @Override 090 public boolean equals(Object obj) { 091 if (obj == this) { 092 return true; 093 } 094 if (!(obj instanceof Comments)) { 095 return false; 096 } 097 return this.toString().equals(obj.toString()); 098 } 099 100 @Override public int hashCode() { 101 return toString().hashCode(); 102 } 103}