ExtensionRefpublic class ExtensionRef extends Object This class holds the information for each installed optional package
reference. It is used to select the optional package actually referenced.
Refer to http://java.sun.com/j2se/1.4.2/docs/guide/extensions/versioning.html#packages
for more info. |
Fields Summary |
---|
private static String | resourceBundleName | public static Logger | logger | private static final String | myClassName | private String | name | private String | implVendorId | private String | implVer | private DeweyDecimal | specVer |
Constructors Summary |
---|
public ExtensionRef(Manifest manifest, String extName)
Attributes attrs = manifest.getMainAttributes();
name = attrs.getValue(extName + "-" + Attributes.Name.EXTENSION_NAME); // NOI18N
String s = attrs.getValue(
extName + "-" + Attributes.Name.SPECIFICATION_VERSION); // NOI18N
if (s != null) {
try {
specVer = new DeweyDecimal(s);
} catch (NumberFormatException e) {
logger.log(Level.SEVERE, getClass().getName() + ".exception1", new Object[]{e.getMessage()});
logger.log(Level.SEVERE, "", e);
throw e;
}
}
implVendorId =
attrs.getValue(
extName + "-" + Attributes.Name.IMPLEMENTATION_VENDOR_ID); // NOI18N
implVer =
attrs.getValue(
extName + "-" + Attributes.Name.IMPLEMENTATION_VERSION); // NOI18N
validate();
|
Methods Summary |
---|
public boolean | isSatisfiedBy(Archive another)
logger.entering(myClassName, "isSatisfiedBy", another); // NOI18N
Attributes attrs = another.getManifest().getMainAttributes();
String name = attrs.getValue(Attributes.Name.EXTENSION_NAME);
String s = attrs.getValue(Attributes.Name.SPECIFICATION_VERSION);
DeweyDecimal specVer = null;
try {
specVer = s != null ? new DeweyDecimal(s) : null;
} catch (NumberFormatException e) {
logger.log(Level.WARNING, getClass().getName() + ".warning1", new Object[]{e.getMessage(), another.toString()});
return false;
}
String implVendorId = attrs.getValue(
Attributes.Name.IMPLEMENTATION_VENDOR_ID);
String implVer = attrs.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
//implVendor is not used for comparision because it is not supposed to be used.
//See optional package versioning.
//The order of comparision is very well defined in
//http://java.sun.com/j2se/1.4.2/docs/guide/extensions/versioning.html
//Although that is specified for Java plugins for applets, it is equally
//applicable for J2EE.
//See J2EE 1.4 section#8.2
return this.name.equals(name) &&
(this.specVer == null || this.specVer.isCompatible(specVer)) &&
(this.implVendorId == null ||
this.implVendorId.equals(implVendorId)) &&
(this.implVer == null || this.implVer.equals(implVer));
| public java.lang.String | toString()Used for pretty printing.
return "Extension-Name: " + name + "\n" + // NOI18N
(specVer != null ? "Specification-Version: " + specVer + "\n" : "") + // NOI18N
(implVendorId != null ?
"Implementation-Vendor-Id: " + implVendorId + "\n" : "") + // NOI18N
(implVer != null ? "Implementation-Version: " + implVer + "\n" : ""); // NOI18N
| private void | validate()
if (name == null || name.length() <= 0) {
throw new IllegalArgumentException("Extension-Name can not be empty.");
}
|
|