Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||||
InsertToken |
|
| 1.3333333333333333;1.333 |
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.script; |
|
16 | ||
17 | import java.io.Writer; |
|
18 | import java.util.Map; |
|
19 | ||
20 | import org.apache.hivemind.Location; |
|
21 | ||
22 | /** |
|
23 | * A token that writes the value of a property using a property path routed in |
|
24 | * the symbols.. |
|
25 | * |
|
26 | * @author Howard Lewis Ship |
|
27 | */ |
|
28 | ||
29 | class InsertToken extends AbstractToken |
|
30 | { |
|
31 | ||
32 | private String _expression; |
|
33 | ||
34 | InsertToken(String expression, Location location) |
|
35 | { |
|
36 | 5 | super(location); |
37 | ||
38 | 5 | _expression = expression; |
39 | 5 | } |
40 | ||
41 | /** |
|
42 | * Gets the named symbol from the symbols {@link Map}, verifies that it is |
|
43 | * a String, and writes it to the {@link Writer}. |
|
44 | */ |
|
45 | ||
46 | public void write(StringBuffer buffer, ScriptSession session) |
|
47 | { |
|
48 | 5 | Object value = evaluate(_expression, session); |
49 | ||
50 | 5 | if (value != null) buffer.append(value); |
51 | 5 | } |
52 | ||
53 | public void addToken(IScriptToken token) |
|
54 | { |
|
55 | // Should never be invoked. |
|
56 | 0 | } |
57 | ||
58 | } |