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