%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.om.folder.psml.MenuMetadataImpl |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
16 | */ |
|
17 | package org.apache.jetspeed.om.folder.psml; |
|
18 | ||
19 | import java.util.Collection; |
|
20 | import java.util.Locale; |
|
21 | ||
22 | import org.apache.jetspeed.om.common.GenericMetadata; |
|
23 | import org.apache.jetspeed.om.page.PageMetadataImpl; |
|
24 | ||
25 | /** |
|
26 | * This class implements metadata protocols for menu |
|
27 | * definition implementations. |
|
28 | * |
|
29 | * @author <a href="mailto:rwatler@apache.org">Randy Watler</a> |
|
30 | * @version $Id: MenuMetadataImpl.java 516448 2007-03-09 16:25:47Z ate $ |
|
31 | */ |
|
32 | public abstract class MenuMetadataImpl |
|
33 | { |
|
34 | /** |
|
35 | * metadata - page metadata to hold title information |
|
36 | */ |
|
37 | private PageMetadataImpl metadata; |
|
38 | ||
39 | /** |
|
40 | * MenuDefinitionImpl - constructor |
|
41 | */ |
|
42 | public MenuMetadataImpl() |
|
43 | 0 | { |
44 | 0 | } |
45 | ||
46 | /** |
|
47 | * getTitle - get default title protocol stub |
|
48 | * |
|
49 | * @return null |
|
50 | */ |
|
51 | public String getTitle() |
|
52 | { |
|
53 | 0 | return null; |
54 | } |
|
55 | ||
56 | /** |
|
57 | * getShortTitle - get default short title protocol stub |
|
58 | * |
|
59 | * @return short title text |
|
60 | */ |
|
61 | public String getShortTitle() |
|
62 | { |
|
63 | 0 | return null; |
64 | } |
|
65 | ||
66 | /** |
|
67 | * getText - get default text protocol stub |
|
68 | * |
|
69 | * @return text |
|
70 | */ |
|
71 | public String getText() |
|
72 | { |
|
73 | 0 | return null; |
74 | } |
|
75 | ||
76 | /** |
|
77 | * getTitle - get locale specific title from metadata |
|
78 | * |
|
79 | * @param locale preferred locale |
|
80 | * @return title text |
|
81 | */ |
|
82 | public String getTitle(Locale locale) |
|
83 | { |
|
84 | // get title from metadata or use default title |
|
85 | 0 | String title = getPageMetadata().getText("title", locale); |
86 | 0 | if (title == null) |
87 | { |
|
88 | 0 | title = getTitle(); |
89 | } |
|
90 | 0 | return title; |
91 | } |
|
92 | ||
93 | /** |
|
94 | * getShortTitle - get locale specific short title from metadata |
|
95 | * |
|
96 | * @param locale preferred locale |
|
97 | * @return short title text |
|
98 | */ |
|
99 | public String getShortTitle(Locale locale) |
|
100 | { |
|
101 | // get short title from metadata or use title from metadata, |
|
102 | // default short title, or default title |
|
103 | 0 | String shortTitle = getPageMetadata().getText("short-title", locale); |
104 | 0 | if (shortTitle == null) |
105 | { |
|
106 | 0 | shortTitle = getPageMetadata().getText("title", locale); |
107 | 0 | if (shortTitle == null) |
108 | { |
|
109 | 0 | shortTitle = getShortTitle(); |
110 | 0 | if (shortTitle == null) |
111 | { |
|
112 | 0 | shortTitle = getTitle(); |
113 | } |
|
114 | } |
|
115 | } |
|
116 | 0 | return shortTitle; |
117 | } |
|
118 | ||
119 | /** |
|
120 | * getText - get locale specific text from metadata |
|
121 | * |
|
122 | * @param locale preferred locale |
|
123 | * @return text |
|
124 | */ |
|
125 | public String getText(Locale locale) |
|
126 | { |
|
127 | // get title from metadata or use default title |
|
128 | 0 | String text = getPageMetadata().getText("text", locale); |
129 | 0 | if (text == null) |
130 | { |
|
131 | 0 | text = getText(); |
132 | } |
|
133 | 0 | return text; |
134 | } |
|
135 | ||
136 | /** |
|
137 | * getMetadata - get generic metadata instance |
|
138 | * |
|
139 | * @return metadata instance |
|
140 | */ |
|
141 | public GenericMetadata getMetadata() |
|
142 | { |
|
143 | 0 | return getPageMetadata(); |
144 | } |
|
145 | ||
146 | /** |
|
147 | * getMetadataFields - get metadata fields collection |
|
148 | * |
|
149 | * @return metadata fields collection |
|
150 | */ |
|
151 | public Collection getMetadataFields() |
|
152 | { |
|
153 | // return metadata fields collection that |
|
154 | // may in fact be side effected on unmarshall |
|
155 | 0 | return getPageMetadata().getFields(); |
156 | } |
|
157 | ||
158 | /** |
|
159 | * setMetadataFields - set metadata fields collection |
|
160 | * |
|
161 | * @param metadataFields metadata fields collection |
|
162 | */ |
|
163 | public void setMetadataFields(Collection metadataFields) |
|
164 | { |
|
165 | // set metadata fields collection that |
|
166 | // may in fact be side effected after |
|
167 | // invocation on unmarshall |
|
168 | 0 | getPageMetadata().setFields(metadataFields); |
169 | 0 | } |
170 | ||
171 | /** |
|
172 | * getPageMetadata - get/construct page metadata instance |
|
173 | * |
|
174 | * @return metadata instance |
|
175 | */ |
|
176 | private PageMetadataImpl getPageMetadata() |
|
177 | { |
|
178 | 0 | if (metadata == null) |
179 | { |
|
180 | 0 | metadata = new PageMetadataImpl(); |
181 | } |
|
182 | 0 | return metadata; |
183 | } |
|
184 | ||
185 | /** |
|
186 | * unmarshalled - notification that this instance has been |
|
187 | * loaded from the persistent store |
|
188 | */ |
|
189 | public void unmarshalled() |
|
190 | { |
|
191 | // force metadata update after unmarshalled since |
|
192 | // metadata collection can be side effected by |
|
193 | // unmarshalling colection accessors |
|
194 | 0 | Collection metadataFields = getMetadataFields(); |
195 | 0 | if (metadataFields != null) |
196 | { |
|
197 | 0 | setMetadataFields(metadataFields); |
198 | } |
|
199 | 0 | } |
200 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |