|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ObjectArrayRenderStrategy.java | 100% | 100% | 100% | 100% |
|
1 | // Copyright 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.describe; | |
16 | ||
17 | import org.apache.tapestry.IMarkupWriter; | |
18 | import org.apache.tapestry.IRequestCycle; | |
19 | ||
20 | /** | |
21 | * Renders an object array as an unordered list; each element is recursively rendered. | |
22 | * | |
23 | * @author Howard M. Lewis Ship | |
24 | * @since 4.0 | |
25 | */ | |
26 | public class ObjectArrayRenderStrategy implements RenderStrategy | |
27 | { | |
28 | private RenderStrategy _renderStrategy; | |
29 | ||
30 | 2 | public void renderObject(Object object, IMarkupWriter writer, IRequestCycle cycle) |
31 | { | |
32 | 2 | Object[] array = (Object[]) object; |
33 | ||
34 | 2 | if (array.length == 0) |
35 | { | |
36 | 1 | writer.begin("em"); |
37 | 1 | writer.print("empty list"); |
38 | 1 | writer.end(); |
39 | 1 | return; |
40 | } | |
41 | ||
42 | 1 | writer.begin("ul"); |
43 | ||
44 | 1 | for (int i = 0; i < array.length; i++) |
45 | { | |
46 | 2 | writer.begin("li"); |
47 | 2 | _renderStrategy.renderObject(array[i], writer, cycle); |
48 | 2 | writer.end(); |
49 | ||
50 | } | |
51 | ||
52 | 1 | writer.end(); |
53 | } | |
54 | ||
55 | 1 | public void setRenderStrategy(RenderStrategy renderStrategy) |
56 | { | |
57 | 1 | _renderStrategy = renderStrategy; |
58 | } | |
59 | ||
60 | } |
|