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.transforms.*; 022import org.apache.juneau.xml.annotation.*; 023 024/** 025 * Parent class of {@link Entry}, {@link Feed}, and {@link Source}. 026 * 027 * <h5 class='section'>See Also:</h5> 028 * <ul class='doctree'> 029 * <li class='link'>{@doc juneau-dto.Atom} 030 * <li class='jp'>{@doc package-summary.html#TOC} 031 * </ul> 032 */ 033public class CommonEntry extends Common { 034 035 private Person[] authors; 036 private Category[] categories; 037 private Person[] contributors; 038 private Id id; 039 private Link[] links; 040 private Text rights; 041 private Text title; 042 private Calendar updated; 043 044 045 /** 046 * Normal constructor. 047 * 048 * @param id The ID of this object. 049 * @param title The title of this object. 050 * @param updated The updated timestamp of this object. 051 */ 052 public CommonEntry(Id id, Text title, Calendar updated) { 053 id(id).title(title).updated(updated); 054 } 055 056 /** 057 * Normal constructor. 058 * 059 * @param id The ID of this object. 060 * @param title The title of this object. 061 * @param updated The updated timestamp of this object. 062 */ 063 public CommonEntry(String id, String title, String updated) { 064 id(id).title(title).updated(updated); 065 } 066 067 /** Bean constructor. */ 068 public CommonEntry() {} 069 070 071 //----------------------------------------------------------------------------------------------------------------- 072 // Bean properties 073 //----------------------------------------------------------------------------------------------------------------- 074 075 /** 076 * Returns the list of authors for this object. 077 * 078 * @return The list of authors for this object. 079 */ 080 @Xml(format=COLLAPSED, childName="author") 081 public Person[] getAuthors() { 082 return authors; 083 } 084 085 /** 086 * Sets the list of authors for this object. 087 * 088 * @param authors The list of authors for this object. 089 * @return This object (for method chaining). 090 */ 091 @BeanProperty("authors") 092 public CommonEntry authors(Person...authors) { 093 this.authors = authors; 094 return this; 095 } 096 097 /** 098 * Returns the list of categories of this object. 099 * 100 * @return The list of categories of this object. 101 */ 102 @Xml(format=COLLAPSED, childName="category") 103 public Category[] getCategories() { 104 return categories; 105 } 106 107 /** 108 * Sets the list of categories of this object. 109 * 110 * @param categories The list of categories of this object. 111 * @return This object (for method chaining). 112 */ 113 @BeanProperty("categories") 114 public CommonEntry categories(Category...categories) { 115 this.categories = categories; 116 return this; 117 } 118 119 /** 120 * Returns the list of contributors of this object. 121 * 122 * @return The list of contributors of this object. 123 */ 124 @Xml(format=COLLAPSED, childName="contributor") 125 public Person[] getContributors() { 126 return contributors; 127 } 128 129 /** 130 * Sets the list of contributors of this object. 131 * 132 * @param contributors The list of contributors of this object. 133 * @return This object (for method chaining). 134 */ 135 @BeanProperty("contributors") 136 public CommonEntry contributors(Person...contributors) { 137 this.contributors = contributors; 138 return this; 139 } 140 141 /** 142 * Returns the ID of this object. 143 * 144 * @return The ID of this object. 145 */ 146 public Id getId() { 147 return id; 148 } 149 150 /** 151 * Sets the ID of this object. 152 * 153 * @param id The ID of this object. 154 * @return This object (for method chaining). 155 */ 156 @BeanProperty("id") 157 public CommonEntry id(Id id) { 158 this.id = id; 159 return this; 160 } 161 162 /** 163 * Sets the ID of this object. 164 * 165 * @param id The ID of this object. 166 * @return This object (for method chaining). 167 */ 168 public CommonEntry id(String id) { 169 this.id = new Id(id); 170 return this; 171 } 172 173 /** 174 * Returns the list of links of this object. 175 * 176 * @return The list of links of this object. 177 */ 178 @Xml(format=COLLAPSED) 179 public Link[] getLinks() { 180 return links; 181 } 182 183 /** 184 * Sets the list of links of this object. 185 * 186 * @param links The list of links of this object. 187 * @return This object (for method chaining). 188 */ 189 @BeanProperty("links") 190 public CommonEntry links(Link...links) { 191 this.links = links; 192 return this; 193 } 194 195 /** 196 * Returns the rights statement of this object. 197 * 198 * @return The rights statement of this object. 199 */ 200 public Text getRights() { 201 return rights; 202 } 203 204 /** 205 * Sets the rights statement of this object. 206 * 207 * @param rights The rights statement of this object. 208 * @return This object (for method chaining). 209 */ 210 @BeanProperty("rights") 211 public CommonEntry rights(Text rights) { 212 this.rights = rights; 213 return this; 214 } 215 216 /** 217 * Sets the rights statement of this object. 218 * 219 * @param rights The rights statement of this object. 220 * @return This object (for method chaining). 221 */ 222 public CommonEntry rights(String rights) { 223 this.rights = new Text().text(rights); 224 return this; 225 } 226 227 /** 228 * Returns the title of this object. 229 * 230 * @return The title of this object. 231 */ 232 public Text getTitle() { 233 return title; 234 } 235 236 /** 237 * Sets the title of this object. 238 * 239 * @param title The title of this object. 240 * @return This object (for method chaining). 241 */ 242 @BeanProperty("title") 243 public CommonEntry title(Text title) { 244 this.title = title; 245 return this; 246 } 247 248 /** 249 * Sets the title of this object. 250 * 251 * @param title The title of this object. 252 * @return This object (for method chaining). 253 */ 254 public CommonEntry title(String title) { 255 this.title = new Text().text(title); 256 return this; 257 } 258 259 /** 260 * Returns the update timestamp of this object. 261 * 262 * @return The update timestamp of this object. 263 */ 264 @Swap(CalendarSwap.ISO8601DT.class) 265 public Calendar getUpdated() { 266 return updated; 267 } 268 269 /** 270 * Sets the update timestamp of this object. 271 * 272 * @param updated The update timestamp of this object. 273 * @return This object (for method chaining). 274 */ 275 @BeanProperty("updated") 276 public CommonEntry updated(Calendar updated) { 277 this.updated = updated; 278 return this; 279 } 280 281 /** 282 * Sets the update timestamp of this object. 283 * 284 * @param updated The update timestamp of this object in ISO8601 format. 285 * @return This object (for method chaining). 286 */ 287 @BeanProperty("updated") 288 public CommonEntry updated(String updated) { 289 this.updated = parseDateTime(updated); 290 return this; 291 } 292}