Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CompoundLSResourceResolver |
|
| 2.0;2 |
1 | /* | |
2 | * Copyright 2007-2008 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php | |
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, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | package org.kuali.rice.ken.util; | |
17 | ||
18 | import java.util.ArrayList; | |
19 | import java.util.List; | |
20 | ||
21 | import org.w3c.dom.ls.LSInput; | |
22 | import org.w3c.dom.ls.LSResourceResolver; | |
23 | ||
24 | /** | |
25 | * LSResourceResolver implementation that delegates in sequence to a list of LSResourceResolvers, | |
26 | * returning the first match. | |
27 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
28 | */ | |
29 | public class CompoundLSResourceResolver implements LSResourceResolver { | |
30 | private final List<LSResourceResolver> resolvers; | |
31 | ||
32 | /** | |
33 | * Constructs a CompoundLSResourceResolver.java. | |
34 | * @param first | |
35 | * @param second | |
36 | */ | |
37 | 0 | public CompoundLSResourceResolver(LSResourceResolver first, LSResourceResolver second) { |
38 | 0 | this.resolvers = new ArrayList<LSResourceResolver>(2); |
39 | 0 | this.resolvers.add(first); |
40 | 0 | this.resolvers.add(second); |
41 | 0 | } |
42 | ||
43 | /** | |
44 | * Constructs a CompoundLSResourceResolver.java. | |
45 | * @param resolvers | |
46 | */ | |
47 | 0 | public CompoundLSResourceResolver(List<LSResourceResolver> resolvers) { |
48 | 0 | this.resolvers = resolvers; |
49 | 0 | } |
50 | ||
51 | /** | |
52 | * @see org.w3c.dom.ls.LSResourceResolver#resolveResource(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) | |
53 | */ | |
54 | public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { | |
55 | 0 | for (LSResourceResolver resolver: resolvers) { |
56 | 0 | LSInput input = resolver.resolveResource(type, namespaceURI, publicId, systemId, baseURI); |
57 | 0 | if (input != null) { |
58 | 0 | return input; |
59 | } | |
60 | 0 | } |
61 | 0 | return null; |
62 | } | |
63 | } |