001: /*
002: JSPWiki - a JSP-based WikiWiki clone.
003:
004: Copyright (C) 2001-2007 Janne Jalkanen (Janne.Jalkanen@iki.fi)
005:
006: This program is free software; you can redistribute it and/or modify
007: it under the terms of the GNU Lesser General Public License as published by
008: the Free Software Foundation; either version 2.1 of the License, or
009: (at your option) any later version.
010:
011: This program is distributed in the hope that it will be useful,
012: but WITHOUT ANY WARRANTY; without even the implied warranty of
013: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: GNU Lesser General Public License for more details.
015:
016: You should have received a copy of the GNU Lesser General Public License
017: along with this program; if not, write to the Free Software
018: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: */
020: package com.ecyrd.jspwiki.rss;
021:
022: import java.util.*;
023:
024: import javax.servlet.ServletContext;
025:
026: import com.ecyrd.jspwiki.TextUtil;
027: import com.ecyrd.jspwiki.WikiContext;
028:
029: /**
030: * @author jalkanen
031: *
032: * @since
033: */
034: public abstract class Feed {
035: protected List m_entries = new ArrayList();
036:
037: protected String m_feedURL;
038: protected String m_channelTitle;
039: protected String m_channelDescription;
040: protected String m_channelLanguage;
041:
042: protected WikiContext m_wikiContext;
043:
044: protected String m_mode = RSSGenerator.MODE_WIKI;
045:
046: public Feed(WikiContext context) {
047: m_wikiContext = context;
048: }
049:
050: public void setMode(String mode) {
051: m_mode = mode;
052: }
053:
054: public void addEntry(Entry e) {
055: m_entries.add(e);
056: }
057:
058: public abstract String getString();
059:
060: /**
061: * @return Returns the m_channelDescription.
062: */
063: public String getChannelDescription() {
064: return m_channelDescription;
065: }
066:
067: /**
068: * @param description The m_channelDescription to set.
069: */
070: public void setChannelDescription(String description) {
071: m_channelDescription = description;
072: }
073:
074: /**
075: * @return Returns the m_channelLanguage.
076: */
077: public String getChannelLanguage() {
078: return m_channelLanguage;
079: }
080:
081: /**
082: * @param language The m_channelLanguage to set.
083: */
084: public void setChannelLanguage(String language) {
085: m_channelLanguage = language;
086: }
087:
088: /**
089: * @return Returns the m_channelTitle.
090: */
091: public String getChannelTitle() {
092: return m_channelTitle;
093: }
094:
095: /**
096: * @param title The m_channelTitle to set.
097: */
098: public void setChannelTitle(String title) {
099: m_channelTitle = title;
100: }
101:
102: /**
103: * @return Returns the m_feedURL.
104: */
105: public String getFeedURL() {
106: return m_feedURL;
107: }
108:
109: /**
110: * @param feedurl The m_feedURL to set.
111: */
112: public void setFeedURL(String feedurl) {
113: m_feedURL = feedurl;
114: }
115:
116: protected String getMimeType(ServletContext c, String name) {
117: String type = c.getMimeType(name);
118:
119: if (type == null)
120: type = "application/octet-stream";
121:
122: return type;
123: }
124:
125: /**
126: * Does the required formatting and entity replacement for XML.
127: */
128: public static String format(String s) {
129: if (s != null) {
130: s = TextUtil.replaceString(s, "&", "&");
131: s = TextUtil.replaceString(s, "<", "<");
132: s = TextUtil.replaceString(s, ">", ">");
133:
134: return s.trim();
135: }
136: return null;
137: }
138: }
|