001/* $Id: Channel.java 1102402 2011-05-12 18:03:26Z simonetripodi $ 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one or more 004 * contributor license agreements. See the NOTICE file distributed with 005 * this work for additional information regarding copyright ownership. 006 * The ASF licenses this file to You under the Apache License, Version 2.0 007 * (the "License"); you may not use this file except in compliance with 008 * the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.commons.digester3.annotations.rss; 019 020import java.util.ArrayList; 021import java.util.List; 022 023import org.apache.commons.digester3.annotations.rules.BeanPropertySetter; 024import org.apache.commons.digester3.annotations.rules.ObjectCreate; 025import org.apache.commons.digester3.annotations.rules.SetNext; 026 027/** 028 * @since 2.1 029 */ 030@ObjectCreate( pattern = "rss/channel" ) 031public final class Channel 032{ 033 034 private final List<Item> items = new ArrayList<Item>(); 035 036 @BeanPropertySetter( pattern = "rss/channel/title" ) 037 private String title; 038 039 @BeanPropertySetter( pattern = "rss/channel/link" ) 040 private String link; 041 042 @BeanPropertySetter( pattern = "rss/channel/description" ) 043 private String description; 044 045 @BeanPropertySetter( pattern = "rss/channel/language" ) 046 private String language; 047 048 private Image image; 049 050 public String getTitle() 051 { 052 return title; 053 } 054 055 public void setTitle( String title ) 056 { 057 this.title = title; 058 } 059 060 public String getLink() 061 { 062 return link; 063 } 064 065 public void setLink( String link ) 066 { 067 this.link = link; 068 } 069 070 public String getDescription() 071 { 072 return description; 073 } 074 075 public void setDescription( String description ) 076 { 077 this.description = description; 078 } 079 080 public String getLanguage() 081 { 082 return language; 083 } 084 085 public void setLanguage( String language ) 086 { 087 this.language = language; 088 } 089 090 public List<Item> getItems() 091 { 092 return items; 093 } 094 095 public Image getImage() 096 { 097 return image; 098 } 099 100 @SetNext 101 public void setImage( Image image ) 102 { 103 this.image = image; 104 } 105 106 @SetNext 107 public void addItem( Item item ) 108 { 109 this.items.add( item ); 110 } 111 112 @Override 113 public boolean equals( Object obj ) 114 { 115 if ( this == obj ) 116 return true; 117 if ( obj == null ) 118 return false; 119 if ( getClass() != obj.getClass() ) 120 return false; 121 Channel other = (Channel) obj; 122 if ( description == null ) 123 { 124 if ( other.description != null ) 125 return false; 126 } 127 else if ( !description.equals( other.description ) ) 128 return false; 129 if ( image == null ) 130 { 131 if ( other.image != null ) 132 return false; 133 } 134 else if ( !image.equals( other.image ) ) 135 return false; 136 if ( items == null ) 137 { 138 if ( other.items != null ) 139 return false; 140 } 141 else if ( !items.equals( other.items ) ) 142 return false; 143 if ( language == null ) 144 { 145 if ( other.language != null ) 146 return false; 147 } 148 else if ( !language.equals( other.language ) ) 149 return false; 150 if ( link == null ) 151 { 152 if ( other.link != null ) 153 return false; 154 } 155 else if ( !link.equals( other.link ) ) 156 return false; 157 if ( title == null ) 158 { 159 if ( other.title != null ) 160 return false; 161 } 162 else if ( !title.equals( other.title ) ) 163 return false; 164 return true; 165 } 166 167 @Override 168 public String toString() 169 { 170 return "Channel [description=" + description + ", image=" + image + ", items=" + items + ", language=" 171 + language + ", link=" + link + ", title=" + title + "]"; 172 } 173 174}