KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > examples > UserFilter


1 /*
2  * This file is part of "SnipSnap Radeox Rendering Engine".
3  *
4  * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel
5  * All Rights Reserved.
6  *
7  * Please visit http://radeox.org/ for updates and contact.
8  *
9  * --LICENSE NOTICE--
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library 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 GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  * --LICENSE NOTICE--
24  */

25
26 package examples;
27
28 import org.radeox.filter.FilterSupport;
29 import org.radeox.filter.context.FilterContext;
30 import org.snipsnap.render.filter.context.SnipFilterContext;
31 import org.snipsnap.render.context.SnipRenderContext;
32 import org.snipsnap.snip.Snip;
33
34 /**
35  * Example which shows howto get the Snip from the filter context.
36  *
37  * @author Stephan J. Schmidt
38  * @version $Id: UserFilter.java 1606 2004-05-17 10:56:18Z leo $
39  */

40
41 // cut:start-1
42
public class UserFilter extends FilterSupport {
43   public String JavaDoc filter(String JavaDoc input, FilterContext context) {
44     //! Refactor to context like SnipRenderContext
45
SnipRenderContext renderContext =
46       ((SnipFilterContext) context).getSnipRenderContext();
47     Snip snip = (Snip)
48         renderContext.getAttribute(SnipRenderContext.SNIP);
49     return snip.getMUser()+" wrote:\n\n";
50   }
51 }
52 // cut:end-1
53
Popular Tags