001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.dto.atom; 014 015import static org.apache.juneau.dto.atom.Utils.*; 016import static org.apache.juneau.xml.annotation.XmlFormat.*; 017 018import java.util.*; 019 020import org.apache.juneau.annotation.*; 021import org.apache.juneau.xml.annotation.*; 022 023/** 024 * Parent class of {@link Entry}, {@link Feed}, and {@link Source}. 025 * 026 * <ul class='seealso'> 027 * <li class='link'>{@doc DtoAtom} 028 * <li class='jp'>{@doc package-summary.html#TOC} 029 * </ul> 030 */ 031public class CommonEntry extends Common { 032 033 private Person[] authors; 034 private Category[] categories; 035 private Person[] contributors; 036 private Id id; 037 private Link[] links; 038 private Text rights; 039 private Text title; 040 private Calendar updated; 041 042 043 /** 044 * Normal constructor. 045 * 046 * @param id The ID of this object. 047 * @param title The title of this object. 048 * @param updated The updated timestamp of this object. 049 */ 050 public CommonEntry(Id id, Text title, Calendar updated) { 051 id(id).title(title).updated(updated); 052 } 053 054 /** 055 * Normal constructor. 056 * 057 * @param id The ID of this object. 058 * @param title The title of this object. 059 * @param updated The updated timestamp of this object. 060 */ 061 public CommonEntry(String id, String title, String updated) { 062 id(id).title(title).updated(updated); 063 } 064 065 /** Bean constructor. */ 066 public CommonEntry() {} 067 068 069 //----------------------------------------------------------------------------------------------------------------- 070 // Bean properties 071 //----------------------------------------------------------------------------------------------------------------- 072 073 /** 074 * Returns the list of authors for this object. 075 * 076 * @return The list of authors for this object. 077 */ 078 @Xml(format=COLLAPSED, childName="author") 079 public Person[] getAuthors() { 080 return authors; 081 } 082 083 /** 084 * Sets the list of authors for this object. 085 * 086 * @param authors The list of authors for this object. 087 * @return This object (for method chaining). 088 */ 089 @Beanp("authors") 090 public CommonEntry authors(Person...authors) { 091 this.authors = authors; 092 return this; 093 } 094 095 /** 096 * Returns the list of categories of this object. 097 * 098 * @return The list of categories of this object. 099 */ 100 @Xml(format=COLLAPSED, childName="category") 101 public Category[] getCategories() { 102 return categories; 103 } 104 105 /** 106 * Sets the list of categories of this object. 107 * 108 * @param categories The list of categories of this object. 109 * @return This object (for method chaining). 110 */ 111 @Beanp("categories") 112 public CommonEntry categories(Category...categories) { 113 this.categories = categories; 114 return this; 115 } 116 117 /** 118 * Returns the list of contributors of this object. 119 * 120 * @return The list of contributors of this object. 121 */ 122 @Xml(format=COLLAPSED, childName="contributor") 123 public Person[] getContributors() { 124 return contributors; 125 } 126 127 /** 128 * Sets the list of contributors of this object. 129 * 130 * @param contributors The list of contributors of this object. 131 * @return This object (for method chaining). 132 */ 133 @Beanp("contributors") 134 public CommonEntry contributors(Person...contributors) { 135 this.contributors = contributors; 136 return this; 137 } 138 139 /** 140 * Returns the ID of this object. 141 * 142 * @return The ID of this object. 143 */ 144 public Id getId() { 145 return id; 146 } 147 148 /** 149 * Sets the ID of this object. 150 * 151 * @param id The ID of this object. 152 * @return This object (for method chaining). 153 */ 154 @Beanp("id") 155 public CommonEntry id(Id id) { 156 this.id = id; 157 return this; 158 } 159 160 /** 161 * Sets the ID of this object. 162 * 163 * @param id The ID of this object. 164 * @return This object (for method chaining). 165 */ 166 public CommonEntry id(String id) { 167 this.id = new Id(id); 168 return this; 169 } 170 171 /** 172 * Returns the list of links of this object. 173 * 174 * @return The list of links of this object. 175 */ 176 @Xml(format=COLLAPSED) 177 public Link[] getLinks() { 178 return links; 179 } 180 181 /** 182 * Sets the list of links of this object. 183 * 184 * @param links The list of links of this object. 185 * @return This object (for method chaining). 186 */ 187 @Beanp("links") 188 public CommonEntry links(Link...links) { 189 this.links = links; 190 return this; 191 } 192 193 /** 194 * Returns the rights statement of this object. 195 * 196 * @return The rights statement of this object. 197 */ 198 public Text getRights() { 199 return rights; 200 } 201 202 /** 203 * Sets the rights statement of this object. 204 * 205 * @param rights The rights statement of this object. 206 * @return This object (for method chaining). 207 */ 208 @Beanp("rights") 209 public CommonEntry rights(Text rights) { 210 this.rights = rights; 211 return this; 212 } 213 214 /** 215 * Sets the rights statement of this object. 216 * 217 * @param rights The rights statement of this object. 218 * @return This object (for method chaining). 219 */ 220 public CommonEntry rights(String rights) { 221 this.rights = new Text().text(rights); 222 return this; 223 } 224 225 /** 226 * Returns the title of this object. 227 * 228 * @return The title of this object. 229 */ 230 public Text getTitle() { 231 return title; 232 } 233 234 /** 235 * Sets the title of this object. 236 * 237 * @param title The title of this object. 238 * @return This object (for method chaining). 239 */ 240 @Beanp("title") 241 public CommonEntry title(Text title) { 242 this.title = title; 243 return this; 244 } 245 246 /** 247 * Sets the title of this object. 248 * 249 * @param title The title of this object. 250 * @return This object (for method chaining). 251 */ 252 public CommonEntry title(String title) { 253 this.title = new Text().text(title); 254 return this; 255 } 256 257 /** 258 * Returns the update timestamp of this object. 259 * 260 * @return The update timestamp of this object. 261 */ 262 public Calendar getUpdated() { 263 return updated; 264 } 265 266 /** 267 * Sets the update timestamp of this object. 268 * 269 * @param updated The update timestamp of this object. 270 * @return This object (for method chaining). 271 */ 272 @Beanp("updated") 273 public CommonEntry updated(Calendar updated) { 274 this.updated = updated; 275 return this; 276 } 277 278 /** 279 * Sets the update timestamp of this object. 280 * 281 * @param updated The update timestamp of this object in ISO8601 format. 282 * @return This object (for method chaining). 283 */ 284 @Beanp("updated") 285 public CommonEntry updated(String updated) { 286 this.updated = parseDateTime(updated); 287 return this; 288 } 289}