1 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 16 public class SmileyTokenHandler extends TokenHandler { 17 18 private Map smileys_ ; 19 20 public SmileyTokenHandler() throws Exception { 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 timage = token.getTokenImage(context) ; 30 String image = (String ) 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 [] getHandleableTokenType() { return new String [] { Token.SMILEY_TOKEN} ;} 37 } | Popular Tags |