KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snipsnap > semanticweb > rss > RssSnip


1 /*
2  * This file is part of "SnipSnap Wiki/Weblog".
3  *
4  * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel
5  * All Rights Reserved.
6  *
7  * Please visit http://snipsnap.org/ for updates and contact.
8  *
9  * --LICENSE NOTICE--
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  * --LICENSE NOTICE--
24  */

25
26 package org.snipsnap.semanticweb.rss;
27
28 import org.radeox.api.engine.RenderEngine;
29 import org.radeox.api.engine.context.RenderContext;
30 import org.snipsnap.app.Application;
31 import org.snipsnap.container.Components;
32 import org.snipsnap.render.context.SnipRenderContext;
33 import org.snipsnap.snip.*;
34 import org.snipsnap.snip.attachment.Attachments;
35 import org.snipsnap.snip.label.Labels;
36 import org.snipsnap.user.Permissions;
37 import org.snipsnap.user.User;
38
39 import javax.servlet.http.HttpServletRequest JavaDoc;
40 import java.io.IOException JavaDoc;
41 import java.io.Writer JavaDoc;
42 import java.sql.Timestamp JavaDoc;
43 import java.util.List JavaDoc;
44
45 /**
46  * Encapsulates a Snip for RSS as RSS channels are more fine granular
47  * than Snip content.
48  *
49  * @author Stephan J. Schmidt
50  * @version $Id: RssSnip.java 1606 2004-05-17 10:56:18Z leo $
51  */

52
53 public class RssSnip implements Snip {
54   private Snip snip;
55   private String JavaDoc url;
56   private String JavaDoc title;
57   private String JavaDoc content;
58
59   public RssSnip(Snip snip) {
60     this.title = snip.getName();
61     this.content = snip.getContent();
62     this.snip = snip;
63     this.url = "";
64   }
65
66   public RssSnip(Snip snip, String JavaDoc content) {
67     this(snip);
68     this.content = content;
69   }
70
71   public RssSnip(Snip snip, String JavaDoc content, String JavaDoc title) {
72     this(snip, content);
73     this.title = title;
74   }
75
76   public RssSnip(Snip snip, String JavaDoc content, String JavaDoc title, String JavaDoc url) {
77     this(snip, content, title);
78     this.url = "#" + url.replace(' ', '_');
79   }
80
81   public int getVersion() {
82     return snip.getVersion();
83   }
84
85   public void setVersion(int version) {
86   }
87
88   public void setParentName(String JavaDoc name) {
89   }
90
91   public String JavaDoc getParentName() {
92     return snip.getParentName();
93   }
94
95   public String JavaDoc getCommentedName() {
96     return snip.getCommentedName();
97   }
98
99   public void setCommentedName(String JavaDoc name) {
100   }
101
102   public SnipPath getPath() throws IOException JavaDoc {
103     return snip.getPath();
104   }
105
106   public void setApplication(String JavaDoc applicationOid) {
107   }
108
109   public String JavaDoc getApplication() {
110     return snip.getApplication();
111   }
112
113   public String JavaDoc getName() {
114     return title;
115   }
116
117   public String JavaDoc getTitle() {
118     return title;
119   }
120
121   public String JavaDoc getContent() {
122     return content;
123   }
124
125   public String JavaDoc getNameEncoded() {
126     return snip.getNameEncoded() + url;
127   }
128
129   public String JavaDoc toXML() {
130     return getXMLContent();
131   }
132
133   public String JavaDoc getXMLContent() {
134     RenderEngine engine = (RenderEngine) Components.getContainer().getComponentInstance(Components.DEFAULT_ENGINE);
135     RenderContext context = new SnipRenderContext(snip, SnipSpaceFactory.getInstance());
136     context.setParameters(Application.get().getParameters());
137     return engine.render(content, context);
138   }
139
140   // Only pass through the other methods
141
public void handle(HttpServletRequest JavaDoc request) {
142     return;
143   }
144
145   public String JavaDoc getLink() {
146     return null;
147   }
148
149   public String JavaDoc getOwner() {
150     return snip.getOwner();
151   }
152
153   public Writer JavaDoc appendTo(Writer JavaDoc s) throws IOException JavaDoc {
154     return snip.appendTo(s);
155   }
156
157   public Access getAccess() {
158     return snip.getAccess();
159   }
160
161   public boolean isOwner(User user) {
162     return snip.isOwner(user);
163   }
164
165   public Modified getModified() {
166     return snip.getModified();
167   }
168
169   public boolean isWeblog() {
170     return snip.isWeblog();
171   }
172
173   public boolean isNotWeblog() {
174     return snip.isNotWeblog();
175   }
176
177   public void addPermission(String JavaDoc permission, String JavaDoc role) {
178     return;
179   }
180
181   public void setPermissions(Permissions permissions) {
182     return;
183   }
184
185   public Permissions getPermissions() {
186     return snip.getPermissions();
187   }
188
189   public String JavaDoc getOUser() {
190     return snip.getOUser();
191   }
192
193   public void setOUser(User oUser) {
194     return;
195   }
196
197   public void setOUser(String JavaDoc oUser) {
198     return;
199   }
200
201   public Attachments getAttachments() {
202     return snip.getAttachments();
203   }
204
205   public void setAttachments(Attachments attachments) {
206     return;
207   }
208
209   public Labels getLabels() {
210     return snip.getLabels();
211   }
212
213   public void setLabels(Labels labels) {
214     return;
215   }
216
217   public Links getBackLinks() {
218     return snip.getBackLinks();
219   }
220
221   public Links getSnipLinks() {
222     return snip.getSnipLinks();
223   }
224
225   public void setBackLinks(Links backLinks) {
226     return;
227   }
228
229   public void setSnipLinks(Links snipLinks) {
230     return;
231   }
232
233   public int getViewCount() {
234     return snip.getViewCount();
235   }
236
237   public void setViewCount(int count) {
238     return;
239   }
240
241   public int incViewCount() {
242     return snip.getViewCount();
243   }
244
245   public Timestamp JavaDoc getCTime() {
246     return snip.getCTime();
247   }
248
249   public void setCTime(Timestamp JavaDoc cTime) {
250     return;
251   }
252
253   public Timestamp JavaDoc getMTime() {
254     return snip.getMTime();
255   }
256
257   public void setMTime(Timestamp JavaDoc mTime) {
258     return;
259   }
260
261   public String JavaDoc getCUser() {
262     return snip.getCUser();
263   }
264
265   public void setCUser(User cUser) {
266     return;
267   }
268
269   public void setCUser(String JavaDoc cUser) {
270     return;
271   }
272
273   public String JavaDoc getMUser() {
274     return snip.getMUser();
275   }
276
277   public void setMUser(User mUser) {
278     return;
279   }
280
281   public void setMUser(String JavaDoc mUser) {
282     return;
283   }
284
285   public List JavaDoc getChildren() {
286     return snip.getChildren();
287   }
288
289   public void setCommentedSnip(Snip comment) {
290     return;
291   }
292
293   public Snip getCommentedSnip() {
294     return snip.getCommentedSnip();
295   }
296
297   public boolean isComment() {
298     return snip.isComment();
299   }
300
301   public Comments getComments() {
302     return snip.getComments();
303   }
304
305   public List JavaDoc getChildrenDateOrder() {
306     return snip.getChildrenDateOrder();
307   }
308
309   public List JavaDoc getChildrenModifiedOrder() {
310     return snip.getChildrenModifiedOrder();
311   }
312
313   public void addSnip(Snip snip) {
314     return;
315   }
316
317   public void removeSnip(Snip snip) {
318     return;
319   }
320
321   public Snip getParent() {
322     return snip.getParent();
323   }
324
325   public void setDirectParent(Snip parentSnip) {
326     return;
327   }
328
329   public void setParent(Snip parentSnip) {
330     return;
331   }
332
333   public String JavaDoc getShortName() {
334     return title;
335   }
336
337   public void setName(String JavaDoc name) {
338     return;
339   }
340
341   public void setContent(String JavaDoc content) {
342     return;
343   }
344
345   public String JavaDoc getAttachmentString() {
346     return snip.getAttachmentString();
347   }
348
349   public Snip copy(String JavaDoc newName) {
350     return new RssSnip(snip, content, title, url);
351   }
352 }
353
Popular Tags