KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > module > sitemesh > html > tokenizer > TagTokenizer


1 package com.opensymphony.module.sitemesh.html.tokenizer;
2
3 /**
4  * Splits a chunk of HTML into 'text' and 'tag' tokens, for easy processing. Is VERY tolerant to badly formed HTML.
5  * <p/>
6  * <h3>Usage</h3>
7  * <p/>
8  * You need to supply a custom {@link TokenHandler} that will receive callbacks as text and tags are processed.
9  * <p/>
10  * <pre>char[] input = ...;
11  * HTMLTagTokenizer tokenizer = new HTMLTagTokenizer(input);
12  * TokenHandler handler = new MyTokenHandler();
13  * tokenizer.start(handler);</pre>
14  *
15  * @author Joe Walnes
16  * @see TokenHandler
17  * @see com.opensymphony.module.sitemesh.parser.HTMLPageParser
18  */

19 public class TagTokenizer {
20
21     private final char[] input;
22
23     public TagTokenizer(char[] input) {
24         this.input = input;
25     }
26
27     public TagTokenizer(String JavaDoc input) {
28         this(input.toCharArray());
29     }
30
31     public void start(TokenHandler handler) {
32         Parser parser = new Parser(input, handler);
33         parser.start();
34     }
35
36 }
37
Popular Tags