1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.parse; |
16 |
| |
17 |
| import org.apache.hivemind.ApplicationRuntimeException; |
18 |
| import org.apache.hivemind.Location; |
19 |
| import org.apache.hivemind.util.ToStringBuilder; |
20 |
| import org.apache.tapestry.IMarkupWriter; |
21 |
| import org.apache.tapestry.IRender; |
22 |
| import org.apache.tapestry.IRequestCycle; |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| public class TextToken extends TemplateToken implements IRender |
34 |
| { |
35 |
| private char[] _templateData; |
36 |
| |
37 |
| private int _offset; |
38 |
| |
39 |
| private int _length; |
40 |
| |
41 |
1277
| public TextToken(char[] templateData, int startIndex, int endIndex, Location location)
|
42 |
| { |
43 |
1277
| super(TokenType.TEXT, location);
|
44 |
| |
45 |
1277
| if (startIndex < 0 || endIndex < 0 || startIndex > templateData.length
|
46 |
| || endIndex > templateData.length) |
47 |
0
| throw new ApplicationRuntimeException(ParseMessages.rangeError(
|
48 |
| this, |
49 |
| templateData.length), this, getLocation(), null); |
50 |
| |
51 |
1277
| _templateData = templateData;
|
52 |
| |
53 |
1277
| _offset = startIndex;
|
54 |
1277
| _length = endIndex - startIndex + 1;
|
55 |
| } |
56 |
| |
57 |
3361
| public void render(IMarkupWriter writer, IRequestCycle cycle)
|
58 |
| { |
59 |
3361
| if (_length == 0)
|
60 |
0
| return;
|
61 |
| |
62 |
| |
63 |
| |
64 |
| |
65 |
| |
66 |
| |
67 |
| |
68 |
3361
| writer.printRaw(_templateData, _offset, _length);
|
69 |
| } |
70 |
| |
71 |
0
| protected void extendDescription(ToStringBuilder builder)
|
72 |
| { |
73 |
0
| builder.append("offset", _offset);
|
74 |
0
| builder.append("length", _length);
|
75 |
| } |
76 |
| |
77 |
0
| public String getTemplateDataAsString()
|
78 |
| { |
79 |
0
| return new String(_templateData, _offset, _length);
|
80 |
| } |
81 |
| |
82 |
16
| public int getLength()
|
83 |
| { |
84 |
16
| return _length;
|
85 |
| } |
86 |
| |
87 |
16
| public int getOffset()
|
88 |
| { |
89 |
16
| return _offset;
|
90 |
| } |
91 |
| } |