@@ -70,25 +70,17 @@ import java.util.jar.Manifest;
* Java2 Standard Edition package, in file
* Java2 Standard Edition package, in file
* <code>guide/extensions/versioning.html</code>.</p>
* <code>guide/extensions/versioning.html</code>.</p>
*
*
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
* This file is from excalibur.extension package. Dont edit this file
* directly as there is no unit tests to make sure it is operational
* in ant. Edit file in excalibur and run tests there before changing
* ants file.
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
*
* @author <a href="mailto:craigmcc@apache.org">Craig R. McClanahan</a>
* @author <a href="mailto:craigmcc@apache.org">Craig R. McClanahan</a>
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
* @version $Revision$ $Date$
* @version $Revision$ $Date$
*/
*/
public final class Extension
{
public final class Extension {
/**
/**
* Manifest Attribute Name object for EXTENSION_LIST.
* Manifest Attribute Name object for EXTENSION_LIST.
* @see Attributes.Name#EXTENSION_LIST
* @see Attributes.Name#EXTENSION_LIST
*/
*/
public static final Attributes.Name EXTENSION_LIST =
new Attributes.Name( "Extension-List" );//Attributes.Name.EXTENSION_LIST;
public static final Attributes.Name EXTENSION_LIST
= new Attributes.Name("Extension-List");
/**
/**
* <code>Name</code> object for <code>Optional-Extension-List</code>
* <code>Name</code> object for <code>Optional-Extension-List</code>
@@ -100,79 +92,83 @@ public final class Extension
* @see <a href="http://java.sun.com/j2se/1.3/docs/guide/extensions/spec.html#dependnecy">
* @see <a href="http://java.sun.com/j2se/1.3/docs/guide/extensions/spec.html#dependnecy">
* Installed extension dependency</a>
* Installed extension dependency</a>
*/
*/
public static final Attributes.Name OPTIONAL_EXTENSION_LIST =
new Attributes.Name( "Optional-Extension-List" );
public static final Attributes.Name OPTIONAL_EXTENSION_LIST
= new Attributes.Name("Optional-Extension-List");
/**
/**
* Manifest Attribute Name object for EXTENSION_NAME.
* Manifest Attribute Name object for EXTENSION_NAME.
* @see Attributes.Name#EXTENSION_NAME
* @see Attributes.Name#EXTENSION_NAME
*/
*/
public static final Attributes.Name EXTENSION_NAME =
public static final Attributes.Name EXTENSION_NAME =
new Attributes.Name( "Extension-Name" );//Attributes.Name.EXTENSION_NAME;
new Attributes.Name("Extension-Name");
/**
/**
* Manifest Attribute Name object for SPECIFICATION_VERSION.
* Manifest Attribute Name object for SPECIFICATION_VERSION.
* @see Attributes.Name#SPECIFICATION_VERSION
* @see Attributes.Name#SPECIFICATION_VERSION
*/
*/
public static final Attributes.Name SPECIFICATION_VERSION = Attributes.Name.SPECIFICATION_VERSION;
public static final Attributes.Name SPECIFICATION_VERSION
= Attributes.Name.SPECIFICATION_VERSION;
/**
/**
* Manifest Attribute Name object for SPECIFICATION_VENDOR.
* Manifest Attribute Name object for SPECIFICATION_VENDOR.
* @see Attributes.Name#SPECIFICATION_VENDOR
* @see Attributes.Name#SPECIFICATION_VENDOR
*/
*/
public static final Attributes.Name SPECIFICATION_VENDOR = Attributes.Name.SPECIFICATION_VENDOR;
public static final Attributes.Name SPECIFICATION_VENDOR
= Attributes.Name.SPECIFICATION_VENDOR;
/**
/**
* Manifest Attribute Name object for IMPLEMENTATION_VERSION.
* Manifest Attribute Name object for IMPLEMENTATION_VERSION.
* @see Attributes.Name#IMPLEMENTATION_VERSION
* @see Attributes.Name#IMPLEMENTATION_VERSION
*/
*/
public static final Attributes.Name IMPLEMENTATION_VERSION = Attributes.Name.IMPLEMENTATION_VERSION;
public static final Attributes.Name IMPLEMENTATION_VERSION
= Attributes.Name.IMPLEMENTATION_VERSION;
/**
/**
* Manifest Attribute Name object for IMPLEMENTATION_VENDOR.
* Manifest Attribute Name object for IMPLEMENTATION_VENDOR.
* @see Attributes.Name#IMPLEMENTATION_VENDOR
* @see Attributes.Name#IMPLEMENTATION_VENDOR
*/
*/
public static final Attributes.Name IMPLEMENTATION_VENDOR = Attributes.Name.IMPLEMENTATION_VENDOR;
public static final Attributes.Name IMPLEMENTATION_VENDOR
= Attributes.Name.IMPLEMENTATION_VENDOR;
/**
/**
* Manifest Attribute Name object for IMPLEMENTATION_URL.
* Manifest Attribute Name object for IMPLEMENTATION_URL.
* @see Attributes.Name#IMPLEMENTATION_URL
* @see Attributes.Name#IMPLEMENTATION_URL
*/
*/
public static final Attributes.Name IMPLEMENTATION_URL =
new Attributes.Name( "Implementation-URL" );//Attributes.Name.IMPLEMENTATION_URL;
public static final Attributes.Name IMPLEMENTATION_URL
= new Attributes.Name("Implementation-URL");
/**
/**
* Manifest Attribute Name object for IMPLEMENTATION_VENDOR_ID.
* Manifest Attribute Name object for IMPLEMENTATION_VENDOR_ID.
* @see Attributes.Name#IMPLEMENTATION_VENDOR_ID
* @see Attributes.Name#IMPLEMENTATION_VENDOR_ID
*/
*/
public static final Attributes.Name IMPLEMENTATION_VENDOR_ID =
new Attributes.Name( "Implementation-Vendor-Id" );//Attributes.Name.IMPLEMENTATION_VENDOR_ID;
public static final Attributes.Name IMPLEMENTATION_VENDOR_ID
= new Attributes.Name("Implementation-Vendor-Id");
/**
/**
* Enum indicating that extension is compatible with other extension.
* Enum indicating that extension is compatible with other extension.
*/
*/
public static final Compatibility COMPATIBLE =
new Compatibility( "COMPATIBLE" );
public static final Compatibility COMPATIBLE
= new Compatibility("COMPATIBLE");
/**
/**
* Enum indicating that extension requires an upgrade
* Enum indicating that extension requires an upgrade
* of specification to be compatible with other extension.
* of specification to be compatible with other extension.
*/
*/
public static final Compatibility REQUIRE_SPECIFICATION_UPGRADE =
new Compatibility( "REQUIRE_SPECIFICATION_UPGRADE" );
public static final Compatibility REQUIRE_SPECIFICATION_UPGRADE
= new Compatibility("REQUIRE_SPECIFICATION_UPGRADE");
/**
/**
* Enum indicating that extension requires a vendor
* Enum indicating that extension requires a vendor
* switch to be compatible with other extension.
* switch to be compatible with other extension.
*/
*/
public static final Compatibility REQUIRE_VENDOR_SWITCH =
new Compatibility( "REQUIRE_VENDOR_SWITCH" );
public static final Compatibility REQUIRE_VENDOR_SWITCH
= new Compatibility("REQUIRE_VENDOR_SWITCH");
/**
/**
* Enum indicating that extension requires an upgrade
* Enum indicating that extension requires an upgrade
* of implementation to be compatible with other extension.
* of implementation to be compatible with other extension.
*/
*/
public static final Compatibility REQUIRE_IMPLEMENTATION_UPGRADE =
new Compatibility( "REQUIRE_IMPLEMENTATION_UPGRADE" );
public static final Compatibility REQUIRE_IMPLEMENTATION_UPGRADE
= new Compatibility("REQUIRE_IMPLEMENTATION_UPGRADE");
/**
/**
* Enum indicating that extension is incompatible with
* Enum indicating that extension is incompatible with
@@ -180,49 +176,49 @@ public final class Extension
* indicate). For example the other extension may have
* indicate). For example the other extension may have
* a different ID.
* a different ID.
*/
*/
public static final Compatibility INCOMPATIBLE =
new Compatibility( "INCOMPATIBLE" );
public static final Compatibility INCOMPATIBLE
= new Compatibility("INCOMPATIBLE");
/**
/**
* The name of the optional package being made available, or required.
* The name of the optional package being made available, or required.
*/
*/
private String m_ extensionName;
private String extensionName;
/**
/**
* The version number (dotted decimal notation) of the specification
* The version number (dotted decimal notation) of the specification
* to which this optional package conforms.
* to which this optional package conforms.
*/
*/
private DeweyDecimal m_ specificationVersion;
private DeweyDecimal specificationVersion;
/**
/**
* The name of the company or organization that originated the
* The name of the company or organization that originated the
* specification to which this optional package conforms.
* specification to which this optional package conforms.
*/
*/
private String m_ specificationVendor;
private String specificationVendor;
/**
/**
* The unique identifier of the company that produced the optional
* The unique identifier of the company that produced the optional
* package contained in this JAR file.
* package contained in this JAR file.
*/
*/
private String m_ implementationVendorID;
private String implementationVendorID;
/**
/**
* The name of the company or organization that produced this
* The name of the company or organization that produced this
* implementation of this optional package.
* implementation of this optional package.
*/
*/
private String m_ implementationVendor;
private String implementationVendor;
/**
/**
* The version number (dotted decimal notation) for this implementation
* The version number (dotted decimal notation) for this implementation
* of the optional package.
* of the optional package.
*/
*/
private DeweyDecimal m_ implementationVersion;
private DeweyDecimal implementationVersion;
/**
/**
* The URL from which the most recent version of this optional package
* The URL from which the most recent version of this optional package
* can be obtained if it is not already installed.
* can be obtained if it is not already installed.
*/
*/
private String m_ implementationURL;
private String implementationURL;
/**
/**
* Return an array of <code>Extension</code> objects representing optional
* Return an array of <code>Extension</code> objects representing optional
@@ -233,39 +229,33 @@ public final class Extension
* @param manifest Manifest to be parsed
* @param manifest Manifest to be parsed
* @return the "available" extensions in specified manifest
* @return the "available" extensions in specified manifest
*/
*/
public static Extension[] getAvailable( final Manifest manifest )
{
if( null == manifest )
{
public static Extension[] getAvailable(final Manifest manifest) {
if (null == manifest) {
return new Extension[ 0 ];
return new Extension[ 0 ];
}
}
final ArrayList results = new ArrayList();
final ArrayList results = new ArrayList();
final Attributes mainAttributes = manifest.getMainAttributes();
final Attributes mainAttributes = manifest.getMainAttributes();
if( null != mainAttributes )
{
final Extension extension = getExtension( "", mainAttributes );
if( null != extension )
{
results.add( extension );
if (null != mainAttributes) {
final Extension extension = getExtension("", mainAttributes);
if (null != extension) {
results.add(extension);
}
}
}
}
final Map entries = manifest.getEntries();
final Map entries = manifest.getEntries();
final Iterator keys = entries.keySet().iterator();
final Iterator keys = entries.keySet().iterator();
while( keys.hasNext() )
{
final String key = (String)keys.next();
final Attributes attributes = (Attributes)entries.get( key );
final Extension extension = getExtension( "", attributes );
if( null != extension )
{
results.add( extension );
while (keys.hasNext()) {
final String key = (String) keys.next();
final Attributes attributes = (Attributes) entries.get(key);
final Extension extension = getExtension("", attributes);
if (null != extension) {
results.add(extension);
}
}
}
}
return (Extension[])results.toArray( new Extension[ 0 ] );
return (Extension[]) results.toArray(new Extension[0]);
}
}
/**
/**
@@ -277,9 +267,8 @@ public final class Extension
* @param manifest Manifest to be parsed
* @param manifest Manifest to be parsed
* @return the dependencies that are specified in manifes
* @return the dependencies that are specified in manifes
*/
*/
public static Extension[] getRequired( final Manifest manifest )
{
return getListed( manifest, EXTENSION_LIST );
public static Extension[] getRequired(final Manifest manifest) {
return getListed(manifest, Attributes.Name.EXTENSION_LIST);
}
}
/**
/**
@@ -290,9 +279,8 @@ public final class Extension
* @param manifest Manifest to be parsed
* @param manifest Manifest to be parsed
* @return the optional dependencies that are specified in manifest
* @return the optional dependencies that are specified in manifest
*/
*/
public static Extension[] getOptions( final Manifest manifest )
{
return getListed( manifest, OPTIONAL_EXTENSION_LIST );
public static Extension[] getOptions(final Manifest manifest) {
return getListed(manifest, OPTIONAL_EXTENSION_LIST);
}
}
/**
/**
@@ -301,10 +289,9 @@ public final class Extension
* @param attributes the attributes of manifest to add to
* @param attributes the attributes of manifest to add to
* @param extension the extension
* @param extension the extension
*/
*/
public static void addExtension( final Extension extension,
final Attributes attributes )
{
addExtension( extension, "", attributes );
public static void addExtension(final Extension extension,
final Attributes attributes) {
addExtension(extension, "", attributes);
}
}
/**
/**
@@ -316,53 +303,49 @@ public final class Extension
* @param extension the extension
* @param extension the extension
* @param prefix the name to prefix to extension
* @param prefix the name to prefix to extension
*/
*/
public static void addExtension( final Extension extension,
public static void addExtension(final Extension extension,
final String prefix,
final String prefix,
final Attributes attributes )
{
attributes.putValue( prefix + EXTENSION_NAME,
extension.getExtensionName() );
final Attributes attributes) {
attributes.putValue(prefix + EXTENSION_NAME,
extension.getExtensionName());
final String specificationVendor = extension.getSpecificationVendor();
final String specificationVendor = extension.getSpecificationVendor();
if( null != specificationVendor )
{
attributes.putValue( prefix + SPECIFICATION_VENDOR,
specificationVendor );
if (null != specificationVendor) {
attributes.putValue(prefix + SPECIFICATION_VENDOR,
specificationVendor);
}
}
final DeweyDecimal specificationVersion = extension.getSpecificationVersion();
if( null != specificationVersion )
{
attributes.putValue( prefix + SPECIFICATION_VERSION,
specificationVersion.toString() );
final DeweyDecimal specificationVersion
= extension.getSpecificationVersion();
if (null != specificationVersion) {
attributes.putValue(prefix + SPECIFICATION_VERSION,
specificationVersion.toString());
}
}
final String implementationVendorID = extension.getImplementationVendorID();
if( null != implementationVendorID )
{
attributes.putValue( prefix + IMPLEMENTATION_VENDOR_ID,
implementationVendorID );
final String implementationVendorID
= extension.getImplementationVendorID();
if (null != implementationVendorID) {
attributes.putValue(prefix + IMPLEMENTATION_VENDOR_ID,
implementationVendorID);
}
}
final String implementationVendor = extension.getImplementationVendor();
final String implementationVendor = extension.getImplementationVendor();
if( null != implementationVendor )
{
attributes.putValue( prefix + IMPLEMENTATION_VENDOR,
implementationVendor );
if (null != implementationVendor) {
attributes.putValue(prefix + IMPLEMENTATION_VENDOR,
implementationVendor);
}
}
final DeweyDecimal implementationVersion = extension.getImplementationVersion();
if( null != implementationVersion )
{
attributes.putValue( prefix + IMPLEMENTATION_VERSION,
implementationVersion.toString() );
final DeweyDecimal implementationVersion
= extension.getImplementationVersion();
if (null != implementationVersion) {
attributes.putValue(prefix + IMPLEMENTATION_VERSION,
implementationVersion.toString());
}
}
final String implementationURL = extension.getImplementationURL();
final String implementationURL = extension.getImplementationURL();
if( null != implementationURL )
{
attributes.putValue( prefix + IMPLEMENTATION_URL,
implementationURL );
if (null != implementationURL) {
attributes.putValue(prefix + IMPLEMENTATION_URL,
implementationURL);
}
}
}
}
@@ -379,52 +362,46 @@ public final class Extension
* @param implementationVendorId the implementation VendorId of extension.
* @param implementationVendorId the implementation VendorId of extension.
* @param implementationURL the implementation URL of extension.
* @param implementationURL the implementation URL of extension.
*/
*/
public Extension( final String extensionName,
public Extension(final String extensionName,
final String specificationVersion,
final String specificationVersion,
final String specificationVendor,
final String specificationVendor,
final String implementationVersion,
final String implementationVersion,
final String implementationVendor,
final String implementationVendor,
final String implementationVendorId,
final String implementationVendorId,
final String implementationURL )
{
m_extensionName = extensionName;
m_specificationVendor = specificationVendor;
if( null != specificationVersion )
{
try
{
m_specificationVersion = new DeweyDecimal( specificationVersion );
}
catch( final NumberFormatException nfe )
{
final String error = "Bad specification version format '" + specificationVersion +
"' in '" + extensionName + "'. (Reason: " + nfe + ")";
throw new IllegalArgumentException( error );
final String implementationURL) {
this.extensionName = extensionName;
this.specificationVendor = specificationVendor;
if (null != specificationVersion) {
try {
this.specificationVersion
= new DeweyDecimal(specificationVersion);
} catch (final NumberFormatException nfe) {
final String error = "Bad specification version format '"
+ specificationVersion + "' in '" + extensionName
+ "'. (Reason: " + nfe + ")";
throw new IllegalArgumentException(error);
}
}
}
}
m_implementationURL = implementationURL;
m_implementationVendor = implementationVendor;
m_implementationVendorID = implementationVendorId;
if( null != implementationVersion )
{
try
{
m_implementationVersion = new DeweyDecimal( implementationVersion );
}
catch( final NumberFormatException nfe )
{
final String error = "Bad implementation version format '" + implementationVersion +
"' in '" + extensionName + "'. (Reason: " + nfe + ")";
throw new IllegalArgumentException( error );
this.implementationURL = implementationURL;
this.implementationVendor = implementationVendor;
this.implementationVendorID = implementationVendorId;
if (null != implementationVersion) {
try {
this.implementationVersion
= new DeweyDecimal(implementationVersion);
} catch (final NumberFormatException nfe) {
final String error = "Bad implementation version format '"
+ implementationVersion + "' in '" + extensionName
+ "'. (Reason: " + nfe + ")";
throw new IllegalArgumentException(error);
}
}
}
}
if( null == m_extensionName )
{
throw new NullPointerException( "extensionName property is null" );
if (null == this.extensionName) {
throw new NullPointerException("extensionName property is null");
}
}
}
}
@@ -433,9 +410,8 @@ public final class Extension
*
*
* @return the name of the extension
* @return the name of the extension
*/
*/
public String getExtensionName()
{
return m_extensionName;
public String getExtensionName() {
return extensionName;
}
}
/**
/**
@@ -443,9 +419,8 @@ public final class Extension
*
*
* @return the vendor of the extensions specification.
* @return the vendor of the extensions specification.
*/
*/
public String getSpecificationVendor()
{
return m_specificationVendor;
public String getSpecificationVendor() {
return specificationVendor;
}
}
/**
/**
@@ -453,9 +428,8 @@ public final class Extension
*
*
* @return the version of the extensions specification.
* @return the version of the extensions specification.
*/
*/
public DeweyDecimal getSpecificationVersion()
{
return m_specificationVersion;
public DeweyDecimal getSpecificationVersion() {
return specificationVersion;
}
}
/**
/**
@@ -463,9 +437,8 @@ public final class Extension
*
*
* @return the url of the extensions implementation.
* @return the url of the extensions implementation.
*/
*/
public String getImplementationURL()
{
return m_implementationURL;
public String getImplementationURL() {
return implementationURL;
}
}
/**
/**
@@ -473,9 +446,8 @@ public final class Extension
*
*
* @return the vendor of the extensions implementation.
* @return the vendor of the extensions implementation.
*/
*/
public String getImplementationVendor()
{
return m_implementationVendor;
public String getImplementationVendor() {
return implementationVendor;
}
}
/**
/**
@@ -483,9 +455,8 @@ public final class Extension
*
*
* @return the vendorID of the extensions implementation.
* @return the vendorID of the extensions implementation.
*/
*/
public String getImplementationVendorID()
{
return m_implementationVendorID;
public String getImplementationVendorID() {
return implementationVendorID;
}
}
/**
/**
@@ -493,9 +464,8 @@ public final class Extension
*
*
* @return the version of the extensions implementation.
* @return the version of the extensions implementation.
*/
*/
public DeweyDecimal getImplementationVersion()
{
return m_implementationVersion;
public DeweyDecimal getImplementationVersion() {
return implementationVersion;
}
}
/**
/**
@@ -506,43 +476,38 @@ public final class Extension
* @return the enum indicating the compatibility (or lack thereof)
* @return the enum indicating the compatibility (or lack thereof)
* of specifed extension
* of specifed extension
*/
*/
public Compatibility getCompatibilityWith( final Extension required )
{
public Compatibility getCompatibilityWith(final Extension required) {
// Extension Name must match
// Extension Name must match
if( !m_extensionName.equals( required.getExtensionName() ) )
{
if (!extensionName.equals(required.getExtensionName())) {
return INCOMPATIBLE;
return INCOMPATIBLE;
}
}
// Available specification version must be >= required
// Available specification version must be >= required
final DeweyDecimal specificationVersion = required.getSpecificationVersion();
if( null != specificationVersion )
{
if( null == m_specificationVersion ||
!isCompatible( m_specificationVersion, specificationVersion ) )
{
final DeweyDecimal specificationVersion
= required.getSpecificationVersion();
if (null != specificationVersion) {
if (null == specificationVersion
|| !isCompatible(specificationVersion, specificationVersion)) {
return REQUIRE_SPECIFICATION_UPGRADE;
return REQUIRE_SPECIFICATION_UPGRADE;
}
}
}
}
// Implementation Vendor ID must match
// Implementation Vendor ID must match
final String implementationVendorId = required.getImplementationVendorID();
if( null != implementationVendorId )
{
if( null == m_implementationVendorID ||
!m_implementationVendorID.equals( implementationVendorId ) )
{
final String implementationVendorId
= required.getImplementationVendorID();
if (null != implementationVendorId) {
if (null == implementationVendorID
|| !implementationVendorID.equals(implementationVendorId)) {
return REQUIRE_VENDOR_SWITCH;
return REQUIRE_VENDOR_SWITCH;
}
}
}
}
// Implementation version must be >= required
// Implementation version must be >= required
final DeweyDecimal implementationVersion = required.getImplementationVersion();
if( null != implementationVersion )
{
if( null == m_implementationVersion ||
!isCompatible( m_implementationVersion, implementationVersion ) )
{
final DeweyDecimal implementationVersion
= required.getImplementationVersion();
if (null != implementationVersion) {
if (null == implementationVersion
|| !isCompatible(implementationVersion, implementationVersion)) {
return REQUIRE_IMPLEMENTATION_UPGRADE;
return REQUIRE_IMPLEMENTATION_UPGRADE;
}
}
}
}
@@ -561,9 +526,8 @@ public final class Extension
* @param required Description of the required optional package
* @param required Description of the required optional package
* @return true if the specified extension is compatible with this extension
* @return true if the specified extension is compatible with this extension
*/
*/
public boolean isCompatibleWith( final Extension required )
{
return ( COMPATIBLE == getCompatibilityWith( required ) );
public boolean isCompatibleWith(final Extension required) {
return (COMPATIBLE == getCompatibilityWith(required));
}
}
/**
/**
@@ -571,62 +535,55 @@ public final class Extension
*
*
* @return string representation of object.
* @return string representation of object.
*/
*/
public String toString()
{
final String lineSeparator = System.getProperty( "line.separator" );
public String toString() {
final String lineSeparator = System.getProperty("line.separator");
final String brace = ": ";
final String brace = ": ";
final StringBuffer sb = new StringBuffer( EXTENSION_NAME.toString() );
sb.append( brace );
sb.append( m_extensionName );
sb.append( lineSeparator );
if( null != m_specificationVersion )
{
sb.append( SPECIFICATION_VERSION );
sb.append( brace );
sb.append( m_specificationVersion );
sb.append( lineSeparator );
final StringBuffer sb = new StringBuffer(EXTENSION_NAME.toString());
sb.append(brace);
sb.append(extensionName);
sb.append(lineSeparator);
if (null != specificationVersion) {
sb.append(SPECIFICATION_VERSION);
sb.append(brace);
sb.append(specificationVersion);
sb.append(lineSeparator);
}
}
if( null != m_specificationVendor )
{
sb.append( SPECIFICATION_VENDOR );
sb.append( brace );
sb.append( m_specificationVendor );
sb.append( lineSeparator );
if (null != specificationVendor) {
sb.append(SPECIFICATION_VENDOR);
sb.append(brace);
sb.append(specificationVendor);
sb.append(lineSeparator);
}
}
if( null != m_implementationVersion )
{
sb.append( IMPLEMENTATION_VERSION );
sb.append( brace );
sb.append( m_implementationVersion );
sb.append( lineSeparator );
if (null != implementationVersion) {
sb.append(IMPLEMENTATION_VERSION);
sb.append(brace);
sb.append(implementationVersion);
sb.append(lineSeparator);
}
}
if( null != m_implementationVendorID )
{
sb.append( IMPLEMENTATION_VENDOR_ID );
sb.append( brace );
sb.append( m_implementationVendorID );
sb.append( lineSeparator );
if (null != implementationVendorID) {
sb.append(IMPLEMENTATION_VENDOR_ID);
sb.append(brace);
sb.append(implementationVendorID);
sb.append(lineSeparator);
}
}
if( null != m_implementationVendor )
{
sb.append( IMPLEMENTATION_VENDOR );
sb.append( brace );
sb.append( m_implementationVendor );
sb.append( lineSeparator );
if (null != implementationVendor) {
sb.append(IMPLEMENTATION_VENDOR);
sb.append(brace);
sb.append(implementationVendor);
sb.append(lineSeparator);
}
}
if( null != m_implementationURL )
{
sb.append( IMPLEMENTATION_URL );
sb.append( brace );
sb.append( m_implementationURL );
sb.append( lineSeparator );
if (null != implementationURL) {
sb.append(IMPLEMENTATION_URL);
sb.append(brace);
sb.append(implementationURL);
sb.append(lineSeparator);
}
}
return sb.toString();
return sb.toString();
@@ -639,9 +596,9 @@ public final class Extension
* @param first First version number (dotted decimal)
* @param first First version number (dotted decimal)
* @param second Second version number (dotted decimal)
* @param second Second version number (dotted decimal)
*/
*/
private boolean isCompatible( final DeweyDecimal first, final DeweyDecimal second )
{
return first.isGreaterThanOrEqual( second );
private boolean isCompatible(final DeweyDecimal first,
final DeweyDecimal second) {
return first.isGreaterThanOrEqual(second);
}
}
/**
/**
@@ -653,56 +610,50 @@ public final class Extension
* EXTENSION_LIST or OPTIONAL_EXTENSION_LIST)
* EXTENSION_LIST or OPTIONAL_EXTENSION_LIST)
* @return the list of listed extensions
* @return the list of listed extensions
*/
*/
private static Extension[] getListed( final Manifest manifest,
final Attributes.Name listKey )
{
private static Extension[] getListed(final Manifest manifest,
final Attributes.Name listKey) {
final ArrayList results = new ArrayList();
final ArrayList results = new ArrayList();
final Attributes mainAttributes = manifest.getMainAttributes();
final Attributes mainAttributes = manifest.getMainAttributes();
if( null != mainAttributes )
{
getExtension( mainAttributes, results, listKey );
if (null != mainAttributes) {
getExtension(mainAttributes, results, listKey);
}
}
final Map entries = manifest.getEntries();
final Map entries = manifest.getEntries();
final Iterator keys = entries.keySet().iterator();
final Iterator keys = entries.keySet().iterator();
while( keys.hasNext() )
{
final String key = (String)keys.next();
final Attributes attributes = (Attributes)entries.get( key );
getExtension( attributes, results, listKey );
while (keys.hasNext()) {
final String key = (String) keys.next();
final Attributes attributes = (Attributes) entries.get(key);
getExtension(attributes, results, listKey);
}
}
return (Extension[])results.toArray( new Extension[ 0 ] );
return (Extension[]) results.toArray(new Extension[ 0 ]);
}
}
/**
/**
* Add required optional packages defined in the specified attributes entry, if any.
* Add required optional packages defined in the specified
* attributes entry, if any.
*
*
* @param attributes Attributes to be parsed
* @param attributes Attributes to be parsed
* @param required list to add required optional packages to
* @param required list to add required optional packages to
* @param listKey the key to use to lookup list, usually EXTENSION_LIST
* @param listKey the key to use to lookup list, usually EXTENSION_LIST
* or OPTIONAL_EXTENSION_LIST
* or OPTIONAL_EXTENSION_LIST
*/
*/
private static void getExtension( final Attributes attributes,
private static void getExtension(final Attributes attributes,
final ArrayList required,
final ArrayList required,
final Attributes.Name listKey )
{
final String names = attributes.getValue( listKey );
if( null == names )
{
final Attributes.Name listKey) {
final String names = attributes.getValue(listKey);
if (null == names) {
return;
return;
}
}
final String[] extentions = split( names, " " );
for( int i = 0; i < extentions.length; i++ )
{
final String[] extentions = split(names, " ");
for (int i = 0; i < extentions.length; i++) {
final String prefix = extentions[ i ] + "-";
final String prefix = extentions[ i ] + "-";
final Extension extension = getExtension( prefix, attributes );
final Extension extension = getExtension(prefix, attributes);
if( null != extension )
{
required.add( extension );
if (null != extension) {
required.add(extension);
}
}
}
}
}
}
@@ -714,13 +665,12 @@ public final class Extension
* @param onToken the token
* @param onToken the token
* @return the resultant array
* @return the resultant array
*/
*/
private static final String[] split( final String string, final String onToken )
{
final StringTokenizer tokenizer = new StringTokenizer( string, onToken );
private static final String[] split(final String string,
final String onToken) {
final StringTokenizer tokenizer = new StringTokenizer(string, onToken);
final String[] result = new String[ tokenizer.countTokens() ];
final String[] result = new String[ tokenizer.countTokens() ];
for( int i = 0; i < result.length; i++ )
{
for (int i = 0; i < result.length; i++) {
result[ i ] = tokenizer.nextToken();
result[ i ] = tokenizer.nextToken();
}
}
@@ -731,41 +681,46 @@ public final class Extension
* Extract an Extension from Attributes.
* Extract an Extension from Attributes.
* Prefix indicates the prefix checked for each string.
* Prefix indicates the prefix checked for each string.
* Usually the prefix is <em>"<extension>-"</em> if looking for a
* Usually the prefix is <em>"<extension>-"</em> if looking for a
* <b>Required</b> extension. If you are looking for an <b>Available</b> extension
* <b>Required</b> extension. If you are looking for an
* <b>Available</b> extension
* then the prefix is <em>""</em>.
* then the prefix is <em>""</em>.
*
*
* @param prefix the prefix for each attribute name
* @param prefix the prefix for each attribute name
* @param attributes Attributes to searched
* @param attributes Attributes to searched
* @return the new Extension object, or null
* @return the new Extension object, or null
*/
*/
private static Extension getExtension( final String prefix, final Attributes attributes )
{
private static Extension getExtension(final String prefix,
final Attributes attributes) {
//WARNING: We trim the values of all the attributes because
//WARNING: We trim the values of all the attributes because
//Some extension declarations are badly defined (ie have spaces
//Some extension declarations are badly defined (ie have spaces
//after version or vendorID)
//after version or vendorID)
final String nameKey = prefix + EXTENSION_NAME;
final String nameKey = prefix + EXTENSION_NAME;
final String name = getTrimmedString( attributes.getValue( nameKey ) );
if( null == name )
{
final String name = getTrimmedString(attributes.getValue(nameKey));
if (null == name) {
return null;
return null;
}
}
final String specVendorKey = prefix + SPECIFICATION_VENDOR;
final String specVendorKey = prefix + SPECIFICATION_VENDOR;
final String specVendor = getTrimmedString( attributes.getValue( specVendorKey ) );
final String specVendor
= getTrimmedString(attributes.getValue(specVendorKey));
final String specVersionKey = prefix + SPECIFICATION_VERSION;
final String specVersionKey = prefix + SPECIFICATION_VERSION;
final String specVersion = getTrimmedString( attributes.getValue( specVersionKey ) );
final String specVersion
= getTrimmedString(attributes.getValue(specVersionKey));
final String impVersionKey = prefix + IMPLEMENTATION_VERSION;
final String impVersionKey = prefix + IMPLEMENTATION_VERSION;
final String impVersion = getTrimmedString( attributes.getValue( impVersionKey ) );
final String impVersion
= getTrimmedString(attributes.getValue(impVersionKey));
final String impVendorKey = prefix + IMPLEMENTATION_VENDOR;
final String impVendorKey = prefix + IMPLEMENTATION_VENDOR;
final String impVendor = getTrimmedString( attributes.getValue( impVendorKey ) );
final String impVendor
= getTrimmedString(attributes.getValue(impVendorKey));
final String impVendorIDKey = prefix + IMPLEMENTATION_VENDOR_ID;
final String impVendorIDKey = prefix + IMPLEMENTATION_VENDOR_ID;
final String impVendorId = getTrimmedString( attributes.getValue( impVendorIDKey ) );
final String impVendorId
= getTrimmedString(attributes.getValue(impVendorIDKey));
final String impURLKey = prefix + IMPLEMENTATION_URL;
final String impURLKey = prefix + IMPLEMENTATION_URL;
final String impURL = getTrimmedString( attributes.getValue( impURLKey ) );
final String impURL = getTrimmedString(attributes.getValue(impURLKey));
return new Extension( name, specVersion, specVendor, impVersion,
impVendor, impVendorId, impURL );
return new Extension(name, specVersion, specVendor, impVersion,
impVendor, impVendorId, impURL);
}
}
/**
/**
@@ -774,14 +729,10 @@ public final class Extension
* @param value the string to trim or null
* @param value the string to trim or null
* @return the trimmed string or null
* @return the trimmed string or null
*/
*/
private static String getTrimmedString( final String value )
{
if( null == value )
{
private static String getTrimmedString(final String value) {
if (null == value) {
return null;
return null;
}
else
{
} else {
return value.trim();
return value.trim();
}
}
}
}