1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jdo.impl.enhancer.util;
18
19 import java.util.List;
20 import java.util.Iterator;
21
22 import java.io.PrintWriter;
23 import java.io.InputStream;
24
25
26
27 /***
28 * Searches resources among a set of files.
29 */
30 public class CombinedResourceLocator
31 extends ResourceLocatorBase
32 implements ResourceLocator
33 {
34 /***
35 * List of resource locators.
36 */
37 final List locators;
38
39 /***
40 * Creates an intsance.
41 */
42 public CombinedResourceLocator(PrintWriter out,
43 boolean verbose,
44 List locators)
45 {
46 super(out, verbose);
47 affirm(locators != null);
48 this.locators = locators;
49 }
50
51 /***
52 * Finds a resource with a given name.
53 */
54 public InputStream getInputStreamForResource(String resourceName)
55 {
56 affirm(resourceName != null);
57
58 for (Iterator i = locators.iterator(); i.hasNext();) {
59 final ResourceLocator locator = (ResourceLocator)i.next();
60 affirm(locator != null);
61 final InputStream stream
62 = locator.getInputStreamForResource(resourceName);
63 if (stream != null) {
64 return stream;
65 }
66 }
67 return null;
68 }
69 }