XMPMetadataFactory.java
1.64 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xmp.core;
import com.adobe.xmp.core.XMPMetadata;
import com.adobe.xmp.core.impl.XMPMetadataImpl;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class XMPMetadataFactory {
private static String versionString = null;
public static XMPMetadata create() {
return new XMPMetadataImpl();
}
public static String getVersionString() {
if (versionString == null) {
try {
Enumeration<URL> resources = XMPMetadataFactory.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
while (resources.hasMoreElements()) {
Manifest manifest = new Manifest(resources.nextElement().openStream());
Attributes attrs = manifest.getMainAttributes();
if (!"com.adobe.xmp.core".equals(attrs.getValue("Bundle-SymbolicName")) || attrs.getValue("Bundle-Version") == null) continue;
String bundleVersion = attrs.getValue("Bundle-Version");
Pattern pattern = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+).*");
Matcher matcher = pattern.matcher(bundleVersion);
if (!matcher.find()) continue;
versionString = bundleVersion;
break;
}
}
catch (IOException E) {
// empty catch block
}
}
return versionString;
}
}