Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
LocalizationToken |
|
| 1.0;1 |
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 | import java.util.Map; | |
18 | ||
19 | import org.apache.hivemind.Location; | |
20 | import org.apache.hivemind.util.ToStringBuilder; | |
21 | ||
22 | /** | |
23 | * Represents localized text from the template. | |
24 | * | |
25 | * @see TokenType#LOCALIZATION | |
26 | * | |
27 | * @author Howard Lewis Ship | |
28 | * @since 3.0 | |
29 | * | |
30 | **/ | |
31 | ||
32 | public class LocalizationToken extends TemplateToken | |
33 | { | |
34 | private String _tag; | |
35 | private String _key; | |
36 | private boolean _raw; | |
37 | private Map _attributes; | |
38 | ||
39 | /** | |
40 | * Creates a new token. | |
41 | * | |
42 | * | |
43 | * @param tag the tag of the element from the template | |
44 | * @param key the localization key specified | |
45 | * @param raw if true, then the localized value contains markup that should not be escaped | |
46 | * @param attributes any additional attributes (beyond those used to define key and raw) | |
47 | * that were specified. This value is retained, not copied. | |
48 | * @param location location of the tag which defines this token | |
49 | * | |
50 | **/ | |
51 | ||
52 | public LocalizationToken(String tag, String key, boolean raw, Map attributes, Location location) | |
53 | { | |
54 | 0 | super(TokenType.LOCALIZATION, location); |
55 | ||
56 | 0 | _tag = tag; |
57 | 0 | _key = key; |
58 | 0 | _raw = raw; |
59 | 0 | _attributes = attributes; |
60 | 0 | } |
61 | ||
62 | /** | |
63 | * Returns any attributes for the token, which may be null. Do not modify | |
64 | * the return value. | |
65 | * | |
66 | **/ | |
67 | ||
68 | public Map getAttributes() | |
69 | { | |
70 | 0 | return _attributes; |
71 | } | |
72 | ||
73 | public boolean isRaw() | |
74 | { | |
75 | 0 | return _raw; |
76 | } | |
77 | ||
78 | public String getTag() | |
79 | { | |
80 | 0 | return _tag; |
81 | } | |
82 | ||
83 | public String getKey() | |
84 | { | |
85 | 0 | return _key; |
86 | } | |
87 | ||
88 | protected void extendDescription(ToStringBuilder builder) | |
89 | { | |
90 | 0 | builder.append("tag", _tag); |
91 | 0 | builder.append("key", _key); |
92 | 0 | builder.append("raw", _raw); |
93 | 0 | } |
94 | } |