001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.bean.atom; 018 019import static org.apache.juneau.bean.atom.Utils.*; 020import static org.apache.juneau.xml.annotation.XmlFormat.*; 021 022import java.util.*; 023 024import org.apache.juneau.internal.*; 025import org.apache.juneau.xml.annotation.*; 026 027/** 028 * Base class for feed-level and entry-level Atom elements. 029 * 030 * <p> 031 * This abstract class contains properties common to {@link Feed}, {@link Entry}, and {@link Source} 032 * elements. These elements share a common set of metadata properties including authors, contributors, 033 * categories, links, and timestamps. 034 * 035 * <p> 036 * Common properties include: 037 * <ul class='spaced-list'> 038 * <li><b>id</b> (required) - Permanent, unique identifier 039 * <li><b>title</b> (required) - Human-readable title 040 * <li><b>updated</b> (required) - Last modification timestamp 041 * <li><b>authors</b> - Author information 042 * <li><b>categories</b> - Classification/tagging information 043 * <li><b>contributors</b> - Contributor information 044 * <li><b>links</b> - Related resources 045 * <li><b>rights</b> - Copyright/rights information 046 * </ul> 047 * 048 * <p> 049 * This class extends {@link Common}, inheriting the <c>xml:base</c> and <c>xml:lang</c> attributes. 050 * 051 * <h5 class='section'>See Also:</h5><ul> 052 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanAtom">juneau-bean-atom</a> 053 * <li class='extlink'><a class="doclink" href="https://tools.ietf.org/html/rfc4287">RFC 4287 - The Atom Syndication Format</a> 054 * </ul> 055 */ 056public class CommonEntry extends Common { 057 058 private Person[] authors; 059 private Category[] categories; 060 private Person[] contributors; 061 private Id id; 062 private Link[] links; 063 private Text rights; 064 private Text title; 065 private Calendar updated; 066 067 068 /** 069 * Normal constructor. 070 * 071 * @param id The ID of this object. 072 * @param title The title of this object. 073 * @param updated The updated timestamp of this object. 074 */ 075 public CommonEntry(Id id, Text title, Calendar updated) { 076 setId(id).setTitle(title).setUpdated(updated); 077 } 078 079 /** 080 * Normal constructor. 081 * 082 * @param id The ID of this object. 083 * @param title The title of this object. 084 * @param updated The updated timestamp of this object. 085 */ 086 public CommonEntry(String id, String title, String updated) { 087 setId(id).setTitle(title).setUpdated(updated); 088 } 089 090 /** Bean constructor. */ 091 public CommonEntry() {} 092 093 094 //----------------------------------------------------------------------------------------------------------------- 095 // Bean properties 096 //----------------------------------------------------------------------------------------------------------------- 097 098 /** 099 * Bean property getter: <property>authors</property>. 100 * 101 * <p> 102 * The list of authors for this object. 103 * 104 * @return The property value, or <jk>null</jk> if it is not set. 105 */ 106 @Xml(format=COLLAPSED, childName="author") 107 public Person[] getAuthors() { 108 return authors; 109 } 110 111 /** 112 * Bean property setter: <property>authors</property>. 113 * 114 * <p> 115 * The list of authors for this object. 116 * 117 * @param value 118 * The new value for this property. 119 * <br>Can be <jk>null</jk> to unset the property. 120 * @return This object 121 */ 122 public CommonEntry setAuthors(Person...value) { 123 this.authors = value; 124 return this; 125 } 126 127 /** 128 * Bean property getter: <property>categories</property>. 129 * 130 * <p> 131 * The list of categories of this object. 132 * 133 * @return The property value, or <jk>null</jk> if it is not set. 134 */ 135 @Xml(format=COLLAPSED, childName="category") 136 public Category[] getCategories() { 137 return categories; 138 } 139 140 /** 141 * Bean property setter: <property>categories</property>. 142 * 143 * <p> 144 * The list of categories of this object. 145 * 146 * @param value 147 * The new value for this property. 148 * <br>Can be <jk>null</jk> to unset the property. 149 * @return This object 150 */ 151 public CommonEntry setCategories(Category...value) { 152 this.categories = value; 153 return this; 154 } 155 156 /** 157 * Bean property getter: <property>contributors</property>. 158 * 159 * <p> 160 * The list of contributors of this object. 161 * 162 * @return The property value, or <jk>null</jk> if it is not set. 163 */ 164 @Xml(format=COLLAPSED, childName="contributor") 165 public Person[] getContributors() { 166 return contributors; 167 } 168 169 /** 170 * Bean property setter: <property>contributors</property>. 171 * 172 * <p> 173 * The list of contributors of this object. 174 * 175 * @param value 176 * The new value for this property. 177 * <br>Can be <jk>null</jk> to unset the property. 178 * @return This object 179 */ 180 public CommonEntry setContributors(Person...value) { 181 this.contributors = value; 182 return this; 183 } 184 185 /** 186 * Bean property getter: <property>id</property>. 187 * 188 * <p> 189 * The ID of this object. 190 * 191 * @return The property value, or <jk>null</jk> if it is not set. 192 */ 193 public Id getId() { 194 return id; 195 } 196 197 /** 198 * Bean property setter: <property>id</property>. 199 * 200 * <p> 201 * The ID of this object. 202 * 203 * @param value 204 * The new value for this property. 205 * <br>Can be <jk>null</jk> to unset the property. 206 * @return This object 207 */ 208 public CommonEntry setId(Id value) { 209 this.id = value; 210 return this; 211 } 212 213 /** 214 * Bean property fluent setter: <property>id</property>. 215 * 216 * <p> 217 * The ID of this object. 218 * 219 * @param value 220 * The new value for this property. 221 * <br>Can be <jk>null</jk> to unset the property. 222 * @return This object. 223 */ 224 public CommonEntry setId(String value) { 225 setId(new Id(value)); 226 return this; 227 } 228 229 /** 230 * Bean property getter: <property>links</property>. 231 * 232 * <p> 233 * The list of links of this object. 234 * 235 * @return The property value, or <jk>null</jk> if it is not set. 236 */ 237 @Xml(format=COLLAPSED) 238 public Link[] getLinks() { 239 return links; 240 } 241 242 /** 243 * Bean property setter: <property>links</property>. 244 * 245 * <p> 246 * The list of links of this object. 247 * 248 * @param value 249 * The new value for this property. 250 * <br>Can be <jk>null</jk> to unset the property. 251 * @return This object 252 */ 253 public CommonEntry setLinks(Link...value) { 254 this.links = value; 255 return this; 256 } 257 258 /** 259 * Bean property getter: <property>rights</property>. 260 * 261 * <p> 262 * The rights statement of this object. 263 * 264 * @return The property value, or <jk>null</jk> if it is not set. 265 */ 266 public Text getRights() { 267 return rights; 268 } 269 270 /** 271 * Bean property setter: <property>rights</property>. 272 * 273 * <p> 274 * The rights statement of this object. 275 * 276 * @param value 277 * The new value for this property. 278 * <br>Can be <jk>null</jk> to unset the property. 279 * @return This object 280 */ 281 public CommonEntry setRights(Text value) { 282 this.rights = value; 283 return this; 284 } 285 286 /** 287 * Bean property fluent setter: <property>rights</property>. 288 * 289 * <p> 290 * The rights statement of this object. 291 * 292 * @param value 293 * The new value for this property. 294 * <br>Can be <jk>null</jk> to unset the property. 295 * @return This object. 296 */ 297 public CommonEntry setRights(String value) { 298 setRights(new Text().setText(value)); 299 return this; 300 } 301 302 /** 303 * Bean property getter: <property>title</property>. 304 * 305 * <p> 306 * The title of this object. 307 * 308 * @return The property value, or <jk>null</jk> if it is not set. 309 */ 310 public Text getTitle() { 311 return title; 312 } 313 314 /** 315 * Bean property setter: <property>title</property>. 316 * 317 * <p> 318 * The title of this object. 319 * 320 * @param value 321 * The new value for this property. 322 * <br>Can be <jk>null</jk> to unset the property. 323 * @return This object 324 */ 325 public CommonEntry setTitle(Text value) { 326 this.title = value; 327 return this; 328 } 329 330 /** 331 * Bean property fluent setter: <property>title</property>. 332 * 333 * <p> 334 * The title of this object. 335 * 336 * @param value 337 * The new value for this property. 338 * <br>Can be <jk>null</jk> to unset the property. 339 * @return This object. 340 */ 341 public CommonEntry setTitle(String value) { 342 setTitle(new Text().setText(value)); 343 return this; 344 } 345 346 /** 347 * Bean property getter: <property>updated</property>. 348 * 349 * <p> 350 * The update timestamp of this object. 351 * 352 * @return The property value, or <jk>null</jk> if it is not set. 353 */ 354 public Calendar getUpdated() { 355 return updated; 356 } 357 358 /** 359 * Bean property setter: <property>updated</property>. 360 * 361 * <p> 362 * The update timestamp of this object. 363 * 364 * @param value 365 * The new value for this property. 366 * <br>Can be <jk>null</jk> to unset the property. 367 * @return This object 368 */ 369 public CommonEntry setUpdated(Calendar value) { 370 this.updated = value; 371 return this; 372 } 373 374 /** 375 * Bean property fluent setter: <property>updated</property>. 376 * 377 * <p> 378 * The update timestamp of this object. 379 * 380 * @param value 381 * The new value for this property. 382 * <br>Can be <jk>null</jk> to unset the property. 383 * @return This object. 384 */ 385 public CommonEntry setUpdated(String value) { 386 setUpdated(parseDateTime(value)); 387 return this; 388 } 389 390 @Override /* Overridden from Common */ 391 public CommonEntry setBase(Object value) { 392 super.setBase(value); 393 return this; 394 } 395 396 @Override /* Overridden from Common */ 397 public CommonEntry setLang(String value) { 398 super.setLang(value); 399 return this; 400 } 401}