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 <rating> 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 * The <a href="http://www.w3.org/PICS/">PICS</a> rating for the channel. 030 * </p> 031 * 032 * @author Bill Brown 033 * 034 */ 035public class Rating implements Serializable { 036 037 /** 038 * 039 */ 040 private static final long serialVersionUID = 1511199969383702784L; 041 042 private final String rating; 043 044 Rating(String rating) throws RSSpectException { 045 if (rating == null || rating.equals("")) { 046 throw new RSSpectException("rating SHOULD NOT be blank."); 047 } 048 this.rating = rating; 049 } 050 051 Rating(Rating rating) { 052 this.rating = rating.rating; 053 } 054 055 /** 056 * @return the rating. 057 */ 058 public String getRating() { 059 return rating; 060 } 061 062 /** 063 * Shows the contents of the <rating> element. 064 */ 065 @Override 066 public String toString() { 067 return "<rating>" + rating + "</rating>"; 068 } 069 070 @Override 071 public boolean equals(Object obj) { 072 if (obj == this) { 073 return true; 074 } 075 if (!(obj instanceof Rating)) { 076 return false; 077 } 078 return this.toString().equals(obj.toString()); 079 } 080 081 @Override public int hashCode() { 082 return toString().hashCode(); 083 } 084}