Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
DynamicAttributesTagSupport |
|
| 0.0;0 |
1 | /* | |
2 | * Copyright 2004-2008 the Seasar Foundation and the Others. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
13 | * either express or implied. See the License for the specific language | |
14 | * governing permissions and limitations under the License. | |
15 | */ | |
16 | package org.seasar.cubby.tags; | |
17 | ||
18 | import java.util.HashMap; | |
19 | import java.util.Map; | |
20 | ||
21 | import javax.servlet.http.HttpServletRequest; | |
22 | import javax.servlet.jsp.JspException; | |
23 | import javax.servlet.jsp.PageContext; | |
24 | import javax.servlet.jsp.tagext.DynamicAttributes; | |
25 | import javax.servlet.jsp.tagext.SimpleTagSupport; | |
26 | ||
27 | /** | |
28 | * DynamicAttributesをフィールドに持つタグの基底クラスです。 | |
29 | * | |
30 | * @author agata | |
31 | * @since 1.0.0 | |
32 | */ | |
33 | 37 | abstract class DynamicAttributesTagSupport extends SimpleTagSupport |
34 | implements DynamicAttributes { | |
35 | ||
36 | /** | |
37 | * DynamicAttributes | |
38 | */ | |
39 | 37 | private final Map<String, Object> attrs = new HashMap<String, Object>(); |
40 | ||
41 | /** | |
42 | * {@inheritDoc} DynamicAttributesをセットします。 FIXME | |
43 | * 現在はuriを無視しているので、必要であれば対応したほうがよいかも | |
44 | */ | |
45 | public void setDynamicAttribute(final String uri, final String localName, | |
46 | final Object value) throws JspException { | |
47 | 10 | this.attrs.put(localName, value); |
48 | 10 | } |
49 | ||
50 | /** | |
51 | * DynamicAttributesを取得します。 | |
52 | * | |
53 | * @return DynamicAttributes | |
54 | */ | |
55 | protected Map<String, Object> getDynamicAttribute() { | |
56 | 37 | return this.attrs; |
57 | } | |
58 | ||
59 | /** | |
60 | * PageContextを取得します。 | |
61 | * | |
62 | * @return PageContext | |
63 | */ | |
64 | protected PageContext getPageContext() { | |
65 | 0 | return (PageContext) getJspContext(); |
66 | } | |
67 | ||
68 | /** | |
69 | * HttpServletRequestを取得します。 | |
70 | * | |
71 | * @return HttpServletRequest | |
72 | */ | |
73 | protected HttpServletRequest getRequest() { | |
74 | 0 | return (HttpServletRequest) getPageContext().getRequest(); |
75 | } | |
76 | ||
77 | /** | |
78 | * オブジェクトを文字列に変換します。 オブジェクトが<code>null</code>の場合、空文字を返します。 | |
79 | * | |
80 | * @param object | |
81 | * 対象のオブジェクト | |
82 | * @return オブジェクトのtoString結果。 | |
83 | */ | |
84 | protected static String toString(final Object object) { | |
85 | 87 | return object == null ? "" : object.toString(); |
86 | } | |
87 | ||
88 | } |