1 /** 2 * This file Copyright (c) 2008-2016 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 static info.magnolia.module.rssaggregator.RSSAggregator.DEFAULT_CONTENT_TYPE; 37 38 import info.magnolia.module.rssaggregator.util.Assert; 39 40 /** 41 * A Feed. 42 */ 43 public class Feed { 44 45 private final String contentType; 46 private final String xml; 47 private final String characterEncoding; 48 49 /** 50 * Construct a new Feed with the given content and characterEncoding. 51 * 52 * @param content the content of this feed (must not be null) 53 * @param contentType the content type (i.e. 'text/xml') for this feed. 54 * @param characterEncoding the character encoding of this feed (must not be null) 55 */ 56 public Feed(String content, String contentType, String characterEncoding) { 57 Assert.notNull(content, "'content' must not be null"); 58 Assert.notNull(contentType, "'contentType' must not be null"); 59 Assert.notNull(characterEncoding, "'characterEncoding' must not be null"); 60 this.xml = content; 61 this.contentType = contentType; 62 this.characterEncoding = characterEncoding; 63 } 64 65 /** 66 * Construct a new Feed with the given content, characterEncoding and default content type (text/xml). 67 * 68 * @param xml the content of this feed (must not be null) 69 * @param characterEncoding the character encoding of this feed (must not be null) 70 */ 71 public Feed(String xml, String characterEncoding) { 72 Assert.notNull(xml, "'content' must not be null"); 73 Assert.notNull(characterEncoding, "'characterEncoding' must not be null"); 74 this.xml = xml; 75 this.contentType = DEFAULT_CONTENT_TYPE; 76 this.characterEncoding = characterEncoding; 77 } 78 79 /** 80 * Return the content of this feed. 81 * 82 * @return the content of this feed 83 * @deprecated since 1.1 use {@link #getContent()} instead 84 */ 85 public String getXml() { 86 return xml; 87 } 88 89 /** 90 * Return the content of this feed. 91 * 92 * @return the content of this feed 93 */ 94 public String getContent() { 95 return xml; 96 } 97 98 /** 99 * Return the character encoding of this feed. 100 * 101 * @return the character encoding of this feed 102 */ 103 public String getCharacterEncoding() { 104 return characterEncoding; 105 } 106 107 /** 108 * Return the contentType of this feed. 109 * 110 * @return the contentType of this feed. 111 */ 112 public String getContentType() { 113 return contentType; 114 } 115 }