UriPath.java
1.66 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
56
57
58
59
60
61
62
63
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa;
import com.adobe.xfa.protocol.Protocol;
import com.adobe.xfa.ut.Resolver;
import com.adobe.xfa.ut.StringUtils;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
public class UriPath {
private URL msRefFileLocation;
public URL getFile(String sFileName) {
if (StringUtils.isEmpty(sFileName)) {
return null;
}
File file = new File(sFileName);
if (file.isAbsolute()) {
if (file.exists()) {
try {
return file.toURL();
}
catch (MalformedURLException e) {
// empty catch block
}
}
return null;
}
if (this.msRefFileLocation != null) {
Protocol protocol = Resolver.getProtocol(this.msRefFileLocation.getProtocol());
try {
return new URL(this.msRefFileLocation, sFileName, protocol != null ? protocol.getURLStreamHandler() : null);
}
catch (MalformedURLException e) {
return null;
}
}
File cwd = new File(System.getProperty("user.dir"));
file = new File(cwd, sFileName);
if (file.exists()) {
try {
return file.toURL();
}
catch (MalformedURLException e) {
// empty catch block
}
}
return null;
}
public URL getRefFileLocation() {
return this.msRefFileLocation;
}
public void setRefFileLocation(URL location) {
this.msRefFileLocation = location;
}
}