KickJava   Java API By Example, From Geeks To Geeks.

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


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 RomanEnumeratedTokenHandler extends TokenHandler {
13   
14   public Token handleToken(Token parent, Token token, ParsingContext context) {
15     StringBuffer JavaDoc b = context.getOutputBuffer() ;
16     TokenHandlerManager manager = context.getTokenHandlerManager() ;
17     b.append("<ul class='roman-enumerated'>") ;
18     boolean closeLI = false ;
19     while(token != null) {
20       if(token.type == Token.ROMAN_ENUMERATED_TOKEN) {
21         if(closeLI) b.append("</li>") ;
22         closeLI = true ;
23         b.append("<li>") ;
24         token = context.nextToken(token) ;
25       } else if(token.type == Token.MULTIPLE_NEW_LINE_TOKEN) {
26         break ;
27       } else {
28         token = manager.handleToken(null ,token, context) ;
29       }
30     }
31     b.append("</li>") ;
32     b.append("</ul>") ;
33     return token ;
34   }
35   
36   public String JavaDoc[] getHandleableTokenType() {
37     String JavaDoc[] s = { Token.ROMAN_ENUMERATED_TOKEN } ;
38     return s;
39   }
40 }
Popular Tags