KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
8  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
9  * @since Dec 19, 2004
10  * @version $Id$
11  */

12 public class ItalicTokenHandler extends TokenHandler {
13   private Token startToken_ = new Token(0,0);
14   
15   public Token handleToken(Token parent, Token token, ParsingContext context) {
16     startToken_.clone(token) ;
17     startToken_.parent = parent ;
18     token = context.nextToken(token) ;
19     if(token.type == Token.DEFAULT_TOKEN) {
20       context.out("<span class='italic'>") ;
21       while(token != null) {
22         if(token.type == Token.DEFAULT_TOKEN) {
23           token = context.getTokenHandlerManager().handleToken(startToken_, token, context) ;
24         } else if(token.type == Token.ITALIC_TOKEN) {
25           token = context.nextToken(token) ;
26           break ;
27         } else if(token.group == Token.SINGLE_TOKEN_GROUP || token.group == Token.INLINE_TOKEN_GROUP) {
28           if(startToken_.hasAncestor(token.type)) {
29             break ;
30           }
31           token = context.getTokenHandlerManager().handleToken(startToken_, token, context) ;
32         } else {
33           break ;
34         }
35       }
36       context.out("</span>") ;
37       return token ;
38     }
39     context.out(startToken_) ;
40     return token ;
41   }
42   
43   public String JavaDoc[] getHandleableTokenType() { return new String JavaDoc[]{Token.ITALIC_TOKEN} ;}
44 }
Popular Tags