KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > parse > ComponentTemplate


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.parse;
16
17 /**
18  * Enapsulates a parsed component template, allowing access to the
19  * tokens parsed.
20  *
21  * <p>TBD: Record the name of the resource (or other location) from which
22  * the template was parsed (useful during debugging).
23  *
24  * @author Howard Lewis Ship
25  *
26  **/

27
28 public class ComponentTemplate
29 {
30     /**
31      * The HTML template from which the tokens were generated. This is a string
32      * read from a resource. The tokens represents offsets and lengths into
33      * this string.
34      *
35      **/

36
37     private char[] _templateData;
38
39     private TemplateToken[] _tokens;
40
41     /**
42      * Creates a new ComponentTemplate.
43      *
44      * @param templateData The template data. This is <em>not</em> copied, so
45      * the array passed in should not be modified further.
46      *
47      * @param tokens The tokens making up the template. This is also
48      * retained (<em>not</em> copied), and so should not
49      * be modified once passed to the constructor.
50      *
51      **/

52
53     public ComponentTemplate(char[] templateData, TemplateToken[] tokens)
54     {
55         _templateData = templateData;
56         _tokens = tokens;
57     }
58
59     public char[] getTemplateData()
60     {
61         return _templateData;
62     }
63
64     public TemplateToken getToken(int index)
65     {
66         return _tokens[index];
67     }
68
69     public int getTokenCount()
70     {
71         return _tokens.length;
72     }
73 }
Popular Tags