DependencyResolver.java
1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xmp.schema.rng.parser.sax;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class DependencyResolver
implements EntityResolver {
private String baseDir;
private List<String> otherDir;
public DependencyResolver(String baseDir, List<String> otherDir) {
this.baseDir = baseDir;
this.otherDir = otherDir;
}
@Override
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
InputSource s;
if (this.baseDir != null && (s = this.getInputSource(this.baseDir, systemId)) != null) {
return s;
}
if (this.otherDir != null) {
for (String dir : this.otherDir) {
InputSource s2 = this.getInputSource(dir, systemId);
if (s2 == null) continue;
return s2;
}
}
return new InputSource(systemId);
}
private InputSource getInputSource(String dir, String systemId) {
String path = dir + systemId;
try {
URL url = new URL(path);
InputSource is = new InputSource(url.openStream());
return is;
}
catch (IOException e) {
return null;
}
}
}