Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ViewMetadata |
|
| 0.0;0 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, | |
13 | * software distributed under the License is distributed on an | |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
15 | * KIND, either express or implied. See the License for the | |
16 | * specific language governing permissions and limitations | |
17 | * under the License. | |
18 | */ | |
19 | package javax.faces.view; | |
20 | ||
21 | import java.util.Collection; | |
22 | import java.util.Collections; | |
23 | import java.util.Iterator; | |
24 | import java.util.LinkedList; | |
25 | ||
26 | import javax.faces.component.UIComponent; | |
27 | import javax.faces.component.UIViewParameter; | |
28 | import javax.faces.component.UIViewRoot; | |
29 | import javax.faces.context.FacesContext; | |
30 | ||
31 | /** | |
32 | * @author Simon Lessard (latest modification by $Author: slessard $) | |
33 | * @version $Revision: 696523 $ $Date: 2009-03-14 20:10:08 -0400 (mer., 17 sept. 2008) $ | |
34 | * | |
35 | * @since 2.0 | |
36 | */ | |
37 | 0 | public abstract class ViewMetadata |
38 | { | |
39 | public abstract UIViewRoot createMetadataView(FacesContext context); | |
40 | ||
41 | public abstract String getViewId(); | |
42 | ||
43 | public static Collection<UIViewParameter> getViewParameters(UIViewRoot root) | |
44 | { | |
45 | 0 | LinkedList<UIViewParameter> result = new LinkedList<UIViewParameter>(); |
46 | 0 | UIComponent metadataFacet = root.getFacet (UIViewRoot.METADATA_FACET_NAME); |
47 | Iterator<UIComponent> children; | |
48 | ||
49 | 0 | if (metadataFacet == null) { |
50 | // No metadata, so return an empty collection. | |
51 | ||
52 | 0 | return Collections.emptyList(); |
53 | } | |
54 | ||
55 | // Iterate over all the children, keep only the view parameters. | |
56 | ||
57 | 0 | children = metadataFacet.getChildren().iterator(); |
58 | ||
59 | 0 | while (children.hasNext()) { |
60 | 0 | UIComponent component = children.next(); |
61 | ||
62 | 0 | if (component instanceof UIViewParameter) { |
63 | 0 | result.add ((UIViewParameter) component); |
64 | } | |
65 | 0 | } |
66 | ||
67 | // TODO: does this need to be immutable? Spec does not indicate either | |
68 | // way. | |
69 | ||
70 | 0 | return Collections.unmodifiableCollection (result); |
71 | } | |
72 | } |