Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
SimpleMenuItem |
|
| 1.4;1.4 |
1 | /* | |
2 | * $Id: SimpleMenuItem.java 836180 2009-11-14 14:00:02Z apetrelli $ | |
3 | * | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | package org.apache.tiles.beans; | |
22 | ||
23 | import java.io.Serializable; | |
24 | ||
25 | /** | |
26 | * A MenuItem implementation. | |
27 | * Used to read menu items in definitions. | |
28 | * | |
29 | * @version $Rev: 836180 $ $Date: 2009-11-15 01:00:02 +1100 (Sun, 15 Nov 2009) $ | |
30 | */ | |
31 | public class SimpleMenuItem implements MenuItem, Serializable { | |
32 | ||
33 | /** | |
34 | * The value of the item, i.e. what is really visible to the user. | |
35 | */ | |
36 | 35 | private String value = null; |
37 | ||
38 | /** | |
39 | * The link where the menu item points to. | |
40 | */ | |
41 | 35 | private String link = null; |
42 | ||
43 | /** | |
44 | * The (optional) icon image URL. | |
45 | */ | |
46 | 35 | private String icon = null; |
47 | ||
48 | /** | |
49 | * The (optional) tooltip text. | |
50 | */ | |
51 | 35 | private String tooltip = null; |
52 | ||
53 | /** | |
54 | * Constructor. | |
55 | */ | |
56 | public SimpleMenuItem() { | |
57 | 35 | super(); |
58 | 35 | } |
59 | ||
60 | /** | |
61 | * Sets the value of the item, i.e. what is really visible to the user. | |
62 | * | |
63 | * @param value The value of the item. | |
64 | */ | |
65 | public void setValue(String value) { | |
66 | 32 | this.value = value; |
67 | 32 | } |
68 | ||
69 | /** | |
70 | * Returns the value of the item, i.e. what is really visible to the user. | |
71 | * | |
72 | * @return The value of the item. | |
73 | */ | |
74 | public String getValue() { | |
75 | 3 | return value; |
76 | } | |
77 | ||
78 | /** | |
79 | * Sets the link where the menu item points to. | |
80 | * | |
81 | * @param link The link. | |
82 | */ | |
83 | public void setLink(String link) { | |
84 | 32 | this.link = link; |
85 | 32 | } |
86 | ||
87 | /** | |
88 | * Returns the link where the menu item points to. | |
89 | * | |
90 | * @return The link. | |
91 | */ | |
92 | public String getLink() { | |
93 | 3 | return link; |
94 | } | |
95 | ||
96 | /** | |
97 | * Sets the (optional) icon image URL. | |
98 | * | |
99 | * @param icon The icon URL. | |
100 | */ | |
101 | public void setIcon(String icon) { | |
102 | 4 | this.icon = icon; |
103 | 4 | } |
104 | ||
105 | /** | |
106 | * Returns the (optional) icon image URL. | |
107 | * | |
108 | * @return The icon URL. | |
109 | */ | |
110 | public String getIcon() { | |
111 | 3 | return icon; |
112 | } | |
113 | ||
114 | /** | |
115 | * Sets the (optional) tooltip text. | |
116 | * | |
117 | * @param tooltip The tooltip text. | |
118 | */ | |
119 | public void setTooltip(String tooltip) { | |
120 | 2 | this.tooltip = tooltip; |
121 | 2 | } |
122 | ||
123 | /** | |
124 | * Returns the (optional) tooltip text. | |
125 | * | |
126 | * @return The tooltip text. | |
127 | */ | |
128 | public String getTooltip() { | |
129 | 3 | return tooltip; |
130 | } | |
131 | ||
132 | /** {@inheritDoc} */ | |
133 | @Override | |
134 | public String toString() { | |
135 | 1 | StringBuffer buff = new StringBuffer("SimpleMenuItem["); |
136 | ||
137 | 1 | if (getValue() != null) { |
138 | 1 | buff.append("value=").append(getValue()).append(", "); |
139 | } | |
140 | ||
141 | 1 | if (getLink() != null) { |
142 | 1 | buff.append("link=").append(getLink()).append(", "); |
143 | } | |
144 | ||
145 | 1 | if (getTooltip() != null) { |
146 | 1 | buff.append("tooltip=").append(getTooltip()).append(", "); |
147 | } | |
148 | ||
149 | 1 | if (getIcon() != null) { |
150 | 1 | buff.append("icon=").append(getIcon()).append(", "); |
151 | } | |
152 | ||
153 | 1 | buff.append("]"); |
154 | 1 | return buff.toString(); |
155 | } | |
156 | ||
157 | } |