home *** CD-ROM | disk | FTP | other *** search
- package sun.misc;
-
- import java.util.StringTokenizer;
- import java.util.jar.Attributes;
- import java.util.jar.Attributes.Name;
-
- public class ExtensionInfo {
- public static final int COMPATIBLE = 0;
- public static final int REQUIRE_SPECIFICATION_UPGRADE = 1;
- public static final int REQUIRE_IMPLEMENTATION_UPGRADE = 2;
- public static final int REQUIRE_VENDOR_SWITCH = 3;
- public static final int INCOMPATIBLE = 4;
- public String title;
- public String name;
- public String specVersion;
- public String specVendor;
- public String implementationVersion;
- public String vendor;
- public String vendorId;
- public String url;
-
- public ExtensionInfo() {
- }
-
- public ExtensionInfo(String var1, Attributes var2) throws NullPointerException {
- String var3;
- if (var1 != null) {
- var3 = var1 + "-";
- } else {
- var3 = "";
- }
-
- String var4 = var3 + Name.EXTENSION_NAME.toString();
- this.name = var2.getValue(var4);
- var4 = var3 + Name.SPECIFICATION_TITLE.toString();
- this.title = var2.getValue(var4);
- var4 = var3 + Name.SPECIFICATION_VERSION.toString();
- this.specVersion = var2.getValue(var4);
- var4 = var3 + Name.SPECIFICATION_VERSION.toString();
- this.specVersion = var2.getValue(var4);
- var4 = var3 + Name.IMPLEMENTATION_VERSION.toString();
- this.implementationVersion = var2.getValue(var4);
- var4 = var3 + Name.IMPLEMENTATION_VENDOR.toString();
- this.vendor = var2.getValue(var4);
- var4 = var3 + Name.IMPLEMENTATION_VENDOR_ID.toString();
- this.vendorId = var2.getValue(var4);
- var4 = var3 + Name.IMPLEMENTATION_URL.toString();
- this.url = var2.getValue(var4);
- }
-
- public int isCompatibleWith(ExtensionInfo var1) {
- if (this.name != null && var1.name != null) {
- if (this.name.compareTo(var1.name) == 0) {
- System.out.println("Potential match");
- if (this.specVersion != null && var1.specVersion != null) {
- int var2 = this.compareExtensionVersion(this.specVersion, var1.specVersion);
- if (var2 < 0) {
- return this.vendorId != null && var1.vendorId != null && this.vendorId.compareTo(var1.vendorId) != 0 ? 3 : 1;
- } else {
- if (this.vendorId != null && var1.vendorId != null) {
- if (this.vendorId.compareTo(var1.vendorId) != 0) {
- return 3;
- }
-
- if (this.implementationVersion != null && var1.implementationVersion != null) {
- var2 = this.compareExtensionVersion(this.implementationVersion, var1.implementationVersion);
- if (var2 < 0) {
- return 2;
- }
- }
- }
-
- return 0;
- }
- } else {
- return 0;
- }
- } else {
- return 4;
- }
- } else {
- return 4;
- }
- }
-
- public String toString() {
- return "Extension : " + this.title + "(" + this.name + "), spec version(" + this.specVersion + "), impl version(" + this.implementationVersion + ") from " + this.vendor + "(" + this.vendorId + ")";
- }
-
- private int compareExtensionVersion(String var1, String var2) throws NumberFormatException {
- StringTokenizer var3 = new StringTokenizer(var1, ".,");
- StringTokenizer var4 = new StringTokenizer(var2, ".,");
-
- while(var3.hasMoreTokens() || var4.hasMoreTokens()) {
- int var5;
- if (var3.hasMoreTokens()) {
- var5 = Integer.parseInt(var3.nextToken());
- } else {
- var5 = 0;
- }
-
- int var6;
- if (var4.hasMoreTokens()) {
- var6 = Integer.parseInt(var4.nextToken());
- } else {
- var6 = 0;
- }
-
- if (var5 < var6) {
- return -1;
- }
-
- if (var5 > var6) {
- return 1;
- }
- }
-
- return 0;
- }
- }
-