KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > grammar > wiki > impl > SmileyTokenHandler


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.services.grammar.wiki.impl;
6
7 import java.util.* ;
8 import org.exoplatform.container.PortalContainer ;
9 import org.exoplatform.container.configuration.*;
10 import org.exoplatform.services.grammar.wiki.WikiEngineService;
11 /**
12  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
13  * @since Dec 19, 2004
14  * @version $Id$
15  */

16 public class SmileyTokenHandler extends TokenHandler {
17  
18   private Map smileys_ ;
19   
20   public SmileyTokenHandler() throws Exception JavaDoc {
21     PortalContainer pcontainer = PortalContainer.getInstance() ;
22     ConfigurationManager manager =
23       (ConfigurationManager)pcontainer.getComponentInstanceOfType(ConfigurationManager.class) ;
24     ServiceConfiguration sconf = manager.getServiceConfiguration(WikiEngineService.class) ;
25     smileys_ = sconf.getPropertiesParam("smiley.configuration").getProperties();
26   }
27   
28   public Token handleToken(Token parent, Token token, ParsingContext context) {
29     String JavaDoc timage = token.getTokenImage(context) ;
30     String JavaDoc image = (String JavaDoc) smileys_.get(timage) ;
31     if(image == null) context.getOutputBuffer().append(timage) ;
32     else context.getOutputBuffer().append(image) ;
33     return context.nextToken(token) ;
34   }
35   
36   public String JavaDoc[] getHandleableTokenType() { return new String JavaDoc[] { Token.SMILEY_TOKEN} ;}
37 }
Popular Tags