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.*;
016
017import java.util.*;
018
019import org.apache.juneau.annotation.*;
020
021/**
022 * Represents an <c>atomEntry</c> construct in the RFC4287 specification.
023 *
024 * <h5 class='figure'>Schema</h5>
025 * <p class='bcode w800'>
026 *    atomEntry =
027 *       element atom:entry {
028 *          atomCommonAttributes,
029 *          (atomAuthor*
030 *          &amp; atomCategory*
031 *          &amp; atomContent?
032 *          &amp; atomContributor*
033 *          &amp; atomId
034 *          &amp; atomLink*
035 *          &amp; atomPublished?
036 *          &amp; atomRights?
037 *          &amp; atomSource?
038 *          &amp; atomSummary?
039 *          &amp; atomTitle
040 *          &amp; atomUpdated
041 *          &amp; extensionElement*)
042 *       }
043 * </p>
044 *
045 * <ul class='seealso'>
046 *    <li class='link'>{@doc juneau-dto.Atom}
047 *    <li class='jp'>{@doc package-summary.html#TOC}
048 * </ul>
049 */
050@Bean(typeName="entry")
051public class Entry extends CommonEntry {
052
053   private Content content;
054   private Calendar published;
055   private Source source;
056   private Text summary;
057
058   /**
059    * Normal constructor.
060    *
061    * @param id The ID of this entry.
062    * @param title The title of this entry.
063    * @param updated The updated timestamp of this entry.
064    */
065   public Entry(Id id, Text title, Calendar updated) {
066      super(id, title, updated);
067   }
068
069   /**
070    * Normal constructor.
071    *
072    * @param id The ID of this entry.
073    * @param title The title of this entry.
074    * @param updated The updated timestamp of this entry.
075    */
076   public Entry(String id, String title, String updated) {
077      super(id, title, updated);
078   }
079
080   /** Bean constructor. */
081   public Entry() {}
082
083
084   //-----------------------------------------------------------------------------------------------------------------
085   // Bean properties
086   //-----------------------------------------------------------------------------------------------------------------
087
088   /**
089    * Returns the content of this entry.
090    *
091    * @return The content of this entry.
092    */
093   public Content getContent() {
094      return content;
095   }
096
097   /**
098    * Sets the content of this entry.
099    *
100    * @param content The content of this entry.
101    * @return This object (for method chaining).
102    */
103   @BeanProperty("content")
104   public Entry content(Content content) {
105      this.content = content;
106      return this;
107   }
108
109   /**
110    * Returns the publish timestamp of this entry.
111    *
112    * @return The publish timestamp of this entry.
113    */
114   public Calendar getPublished() {
115      return published;
116   }
117
118   /**
119    * Sets the publish timestamp of this entry.
120    *
121    * @param published The publish timestamp of this entry.
122    * @return This object (for method chaining).
123    */
124   @BeanProperty("published")
125   public Entry published(Calendar published) {
126      this.published = published;
127      return this;
128   }
129
130   /**
131    * Sets the publish timestamp of this entry.
132    *
133    * @param published The publish timestamp of this entry in ISO8601 format.
134    * @return This object (for method chaining).
135    */
136   @BeanProperty("published")
137   public Entry published(String published) {
138      this.published = parseDateTime(published);
139      return this;
140   }
141
142   /**
143    * Returns the source of this entry.
144    *
145    * @return The source of this entry.
146    */
147   public Source getSource() {
148      return source;
149   }
150
151   /**
152    * Sets the source of this entry.
153    *
154    * @param source The source of this entry.
155    * @return This object (for method chaining).
156    */
157   @BeanProperty("source")
158   public Entry source(Source source) {
159      this.source = source;
160      return this;
161   }
162
163   /**
164    * Returns the summary of this entry.
165    *
166    * @return The summary of this entry.
167    */
168   public Text getSummary() {
169      return summary;
170   }
171
172   /**
173    * Sets the summary of this entry.
174    *
175    * @param summary The summary of this entry.
176    * @return This object (for method chaining).
177    */
178   @BeanProperty("summary")
179   public Entry summary(Text summary) {
180      this.summary = summary;
181      return this;
182   }
183
184   /**
185    * Sets the summary of this entry.
186    *
187    * @param summary The summary of this entry.
188    * @return This object (for method chaining).
189    */
190   @BeanProperty("summary")
191   public Entry summary(String summary) {
192      this.summary = new Text(summary);
193      return this;
194   }
195
196
197   //-----------------------------------------------------------------------------------------------------------------
198   // Overridden setters (to simplify method chaining)
199   //-----------------------------------------------------------------------------------------------------------------
200
201   @Override /* CommonEntry */
202   public Entry authors(Person...authors) {
203      super.authors(authors);
204      return this;
205   }
206
207   @Override /* CommonEntry */
208   public Entry categories(Category...categories) {
209      super.categories(categories);
210      return this;
211   }
212
213   @Override /* CommonEntry */
214   public Entry contributors(Person...contributors) {
215      super.contributors(contributors);
216      return this;
217   }
218
219   @Override /* CommonEntry */
220   public Entry id(Id id) {
221      super.id(id);
222      return this;
223   }
224
225   @Override /* CommonEntry */
226   public Entry links(Link...links) {
227      super.links(links);
228      return this;
229   }
230
231   @Override /* CommonEntry */
232   public Entry rights(Text rights) {
233      super.rights(rights);
234      return this;
235   }
236
237   @Override /* CommonEntry */
238   public Entry rights(String rights) {
239      super.rights(rights);
240      return this;
241   }
242
243   @Override /* CommonEntry */
244   public Entry title(Text title) {
245      super.title(title);
246      return this;
247   }
248
249   @Override /* CommonEntry */
250   public Entry title(String title) {
251      super.title(title);
252      return this;
253   }
254
255   @Override /* CommonEntry */
256   public Entry updated(Calendar updated) {
257      super.updated(updated);
258      return this;
259   }
260
261   @Override /* CommonEntry */
262   public Entry updated(String updated) {
263      super.updated(updated);
264      return this;
265   }
266
267   @Override /* Common */
268   public Entry base(Object base) {
269      super.base(base);
270      return this;
271   }
272
273   @Override /* Common */
274   public Entry lang(String lang) {
275      super.lang(lang);
276      return this;
277   }
278}