View Javadoc

1   /**
2    * This file Copyright (c) 2008-2010 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
32   *
33   */
34  package info.magnolia.module.rssaggregator.generator;
35  
36  import info.magnolia.module.rssaggregator.util.Assert;
37  import static info.magnolia.module.rssaggregator.RSSAggregator.*;
38  
39  /**
40   * A Feed.
41   *
42   * @author Rob van der Linden Vooren
43   */
44  public class Feed {
45  
46      private final String contentType;
47      private final String xml;
48      private final String characterEncoding;
49  
50      /**
51       * Construct a new Feed with the given content and characterEncoding.
52       *
53       * @param content               the content of this feed (must not be null)
54       * @param contentType           the content type (i.e. 'text/xml') for this feed.
55       * @param characterEncoding the character encoding of this feed (must not be null)
56       */
57      public Feed(String content, String contentType, String characterEncoding) {
58          Assert.notNull(content, "'content' must not be null");
59          Assert.notNull(contentType, "'contentType' must not be null");
60          Assert.notNull(characterEncoding, "'characterEncoding' must not be null");
61          this.xml = content;
62          this.contentType = contentType;
63          this.characterEncoding = characterEncoding;
64      }
65  
66      /**
67       * Construct a new Feed with the given content, characterEncoding and default content type (text/xml).
68       *
69       * @param xml               the content of this feed (must not be null)
70       * @param characterEncoding the character encoding of this feed (must not be null)
71       */
72      public Feed(String xml, String characterEncoding) {
73          Assert.notNull(xml, "'content' must not be null");
74          Assert.notNull(characterEncoding, "'characterEncoding' must not be null");
75          this.xml = xml;
76          this.contentType = DEFAULT_CONTENT_TYPE;
77          this.characterEncoding = characterEncoding;
78      }
79  
80      /**
81       * Return the content of this feed.
82       *
83       * @return the content of this feed
84       * @deprecated since 1.1 use {link #getContent()} instead
85       */
86      public String getXml() {
87          return xml;
88      }
89  
90      /**
91       * Return the content of this feed.
92       *
93       * @return the content of this feed
94       */
95      public String getContent() {
96          return xml;
97      }
98  
99      /**
100      * Return the character encoding of this feed.
101      *
102      * @return the character encoding of this feed
103      */
104     public String getCharacterEncoding() {
105         return characterEncoding;
106     }
107 
108     /**
109      * Return the contentType of this feed.
110      *
111      * @return the contentType of this feed.
112      */
113     public String getContentType() {
114         return contentType;
115     }
116 }