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 <language> 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 language the channel is written in. This allows aggregators to group all 030 * Italian language sites, for example, on a single page. A list of allowable 031 * values for this element, as provided by Netscape, is <a 032 * href="http://cyber.law.harvard.edu/rss/languages.html">here</a>. You may also 033 * use <a 034 * href="http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes">values 035 * defined</a> by the W3C. 036 * </p> 037 * 038 * @author Bill Brown 039 * 040 */ 041public class Language implements Serializable { 042 043 private static final long serialVersionUID = -8639326685256827986L; 044 045 private final String language; 046 047 Language(String language) throws RSSpectException { 048 if (language == null || language.equals("")) { 049 throw new RSSpectException("language SHOULD NOT be blank."); 050 } 051 this.language = language; 052 } 053 054 Language(Language language) { 055 this.language = language.language; 056 } 057 058 /** 059 * @return the language. 060 */ 061 public String getLanguage() { 062 return language; 063 } 064 065 /** 066 * Shows the contents of the <language> element. 067 */ 068 @Override 069 public String toString() { 070 return "<language>" + language + "</language>"; 071 } 072 073 @Override 074 public boolean equals(Object obj) { 075 if (obj == this) { 076 return true; 077 } 078 if (!(obj instanceof Language)) { 079 return false; 080 } 081 return this.toString().equals(obj.toString()); 082 } 083 084 @Override public int hashCode() { 085 return toString().hashCode(); 086 } 087}