Top Description Fields Constructors Methods
org.apache.tools.ant.taskdefs.optional.extension

public final Class Extension

extends Object
Class Inheritance
Imports
java.util.ArrayList, .List, .Objects, .Optional, .StringTokenizer, java.util.jar.Attributes, .Manifest, java.util.stream.Stream, org.apache.tools.ant.util.DeweyDecimal

Utility class that represents either an available "Optional Package" (formerly known as "Standard Extension") as described in the manifest of a JAR file, or the requirement for such an optional package.

For more information about optional packages, see the document Optional Package Versioning in the documentation bundle for your Java2 Standard Edition package, in file guide/extensions/versioning.html.

Field Summary

Modifier and TypeField and Description
public static final Compatibility
COMPATIBLE

Enum indicating that extension is compatible with other extension.

public static final Attributes.Name
EXTENSION_LIST

Manifest Attribute Name object for EXTENSION_LIST.

public static final Attributes.Name
EXTENSION_NAME

Manifest Attribute Name object for EXTENSION_NAME.

private String
extensionName

The name of the optional package being made available, or required.

public static final Attributes.Name
IMPLEMENTATION_URL

Manifest Attribute Name object for IMPLEMENTATION_URL.

public static final Attributes.Name
IMPLEMENTATION_VENDOR

Manifest Attribute Name object for IMPLEMENTATION_VENDOR.

public static final Attributes.Name
IMPLEMENTATION_VENDOR_ID

Manifest Attribute Name object for IMPLEMENTATION_VENDOR_ID.

public static final Attributes.Name
IMPLEMENTATION_VERSION

Manifest Attribute Name object for IMPLEMENTATION_VERSION.

private String
implementationURL

The URL from which the most recent version of this optional package can be obtained if it is not already installed.

private String
implementationVendor

The name of the company or organization that produced this implementation of this optional package.

private String
implementationVendorID

The unique identifier of the company that produced the optional package contained in this JAR file.

private DeweyDecimal
implementationVersion

The version number (dotted decimal notation) for this implementation of the optional package.

public static final Compatibility
INCOMPATIBLE

Enum indicating that extension is incompatible with other extension in ways other than other enums indicate).

public static final Attributes.Name
OPTIONAL_EXTENSION_LIST

Name object for Optional-Extension-List manifest attribute used for declaring optional dependencies on installed extensions.

public static final Compatibility
REQUIRE_IMPLEMENTATION_UPGRADE

Enum indicating that extension requires an upgrade of implementation to be compatible with other extension.

public static final Compatibility
REQUIRE_SPECIFICATION_UPGRADE

Enum indicating that extension requires an upgrade of specification to be compatible with other extension.

public static final Compatibility
REQUIRE_VENDOR_SWITCH

Enum indicating that extension requires a vendor switch to be compatible with other extension.

public static final Attributes.Name
SPECIFICATION_VENDOR

Manifest Attribute Name object for SPECIFICATION_VENDOR.

public static final Attributes.Name
SPECIFICATION_VERSION

Manifest Attribute Name object for SPECIFICATION_VERSION.

private String
specificationVendor

The name of the company or organization that originated the specification to which this optional package conforms.

private DeweyDecimal
specificationVersion

The version number (dotted decimal notation) of the specification to which this optional package conforms.

Constructor Summary

AccessConstructor and Description
public
Extension(final String
the name of extension.
extensionName
,
final String
the specification Version of extension.
specificationVersion
,
final String
the specification Vendor of extension.
specificationVendor
,
final String
the implementation Version of extension.
implementationVersion
,
final String
the implementation Vendor of extension.
implementationVendor
,
final String
the implementation VendorId of extension.
implementationVendorId
,
final String
the implementation URL of extension.
implementationURL
)

The constructor to create Extension object.

Method Summary

Modifier and TypeMethod and Description
public static void
addExtension(final Extension
the extension
extension
,
final Attributes
the attributes of manifest to add to
attributes
)

Add Extension to the specified manifest Attributes.

public static void
addExtension(final Extension
the extension
extension
,
final String
the name to prefix to extension
prefix
,
final Attributes
the attributes of manifest to add to
attributes
)

Add Extension to the specified manifest Attributes.

public static Extension[]

Returns:

the "available" extensions in specified manifest
getAvailable
(final Manifest
Manifest to be parsed
manifest
)

Return an array of Extension objects representing optional packages that are available in the JAR file associated with the specified Manifest.

public Compatibility

Returns:

the enum indicating the compatibility (or lack thereof) of specified extension
getCompatibilityWith
(final Extension
Description of the required optional package
required
)

Return a Compatibility enum indicating the relationship of this Extension with the specified Extension.

private static void
getExtension(final Attributes
Attributes to be parsed
attributes
,
final List<Extension>
list to add required optional packages to
required
,
final Attributes.Name
the key to use to lookup list, usually EXTENSION_LIST or OPTIONAL_EXTENSION_LIST
listKey
)

Add required optional packages defined in the specified attributes entry, if any.

private static Extension

Returns:

the new Extension object, or null
getExtension
(final String
the prefix for each attribute name
prefix
,
final Attributes
Attributes to searched
attributes
)

Extract an Extension from Attributes.

public String

Returns:

the name of the extension
getExtensionName
()

Get the name of the extension.

public String

Returns:

the url of the extensions implementation.
getImplementationURL
()

Get the url of the extensions implementation.

public String

Returns:

the vendor of the extensions implementation.
getImplementationVendor
()

Get the vendor of the extensions implementation.

public String

Returns:

the vendorID of the extensions implementation.
getImplementationVendorID
()

Get the vendorID of the extensions implementation.

public DeweyDecimal

Returns:

the version of the extensions implementation.
getImplementationVersion
()

Get the version of the extensions implementation.

private static Extension[]

Returns:

the list of listed extensions
getListed
(final Manifest
the manifest to extract extensions from
manifest
,
final Attributes.Name
the key used to get list (Usually EXTENSION_LIST or OPTIONAL_EXTENSION_LIST)
listKey
)

Retrieve all the extensions listed under a particular key (Usually EXTENSION_LIST or OPTIONAL_EXTENSION_LIST).

public static Extension[]

Returns:

the optional dependencies that are specified in manifest
getOptions
(final Manifest
Manifest to be parsed
manifest
)

Return the set of Extension objects representing "Optional Packages" that the application declares they will use if present.

public static Extension[]

Returns:

the dependencies that are specified in manifest
getRequired
(final Manifest
Manifest to be parsed
manifest
)

Return the set of Extension objects representing optional packages that are required by the application contained in the JAR file associated with the specified Manifest.

public String

Returns:

the vendor of the extensions specification.
getSpecificationVendor
()

Get the vendor of the extensions specification.

public DeweyDecimal

Returns:

the version of the extensions specification.
getSpecificationVersion
()

Get the version of the extensions specification.

private static String

Returns:

the trimmed string or null
getTrimmedString
(final String
the string to trim or null
value
)

Trim the supplied string if the string is non-null

private boolean
isCompatible(final DeweyDecimal
First version number (dotted decimal)
first
,
final DeweyDecimal
Second version number (dotted decimal)
second
)

Return true if the first version number is greater than or equal to the second; otherwise return false.

public boolean

Returns:

true if the specified extension is compatible with this extension
isCompatibleWith
(final Extension
Description of the required optional package
required
)

Return true if the specified Extension (which represents an optional package required by an application) is satisfied by this Extension (which represents an optional package that is already installed.

private static String[]

Returns:

the resultant array
split
(final String
the string
string
,
final String
the token
onToken
)

Splits the string on every token into an array of strings.

public String

Returns:

string representation of object.
toString
()

Overrides java.lang.Object.toString.

Return a String representation of this object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

COMPATIBLEback to summary
public static final Compatibility COMPATIBLE

Enum indicating that extension is compatible with other extension.

EXTENSION_LISTback to summary
public static final Attributes.Name EXTENSION_LIST

Manifest Attribute Name object for EXTENSION_LIST.

EXTENSION_NAMEback to summary
public static final Attributes.Name EXTENSION_NAME

Manifest Attribute Name object for EXTENSION_NAME.

extensionNameback to summary
private String extensionName

The name of the optional package being made available, or required.

IMPLEMENTATION_URLback to summary
public static final Attributes.Name IMPLEMENTATION_URL

Manifest Attribute Name object for IMPLEMENTATION_URL.

IMPLEMENTATION_VENDORback to summary
public static final Attributes.Name IMPLEMENTATION_VENDOR

Manifest Attribute Name object for IMPLEMENTATION_VENDOR.

IMPLEMENTATION_VENDOR_IDback to summary
public static final Attributes.Name IMPLEMENTATION_VENDOR_ID

Manifest Attribute Name object for IMPLEMENTATION_VENDOR_ID.

IMPLEMENTATION_VERSIONback to summary
public static final Attributes.Name IMPLEMENTATION_VERSION

Manifest Attribute Name object for IMPLEMENTATION_VERSION.

implementationURLback to summary
private String implementationURL

The URL from which the most recent version of this optional package can be obtained if it is not already installed.

implementationVendorback to summary
private String implementationVendor

The name of the company or organization that produced this implementation of this optional package.

implementationVendorIDback to summary
private String implementationVendorID

The unique identifier of the company that produced the optional package contained in this JAR file.

implementationVersionback to summary
private DeweyDecimal implementationVersion

The version number (dotted decimal notation) for this implementation of the optional package.

INCOMPATIBLEback to summary
public static final Compatibility INCOMPATIBLE

Enum indicating that extension is incompatible with other extension in ways other than other enums indicate). For example the other extension may have a different ID.

OPTIONAL_EXTENSION_LISTback to summary
public static final Attributes.Name OPTIONAL_EXTENSION_LIST

Name object for Optional-Extension-List manifest attribute used for declaring optional dependencies on installed extensions. Note that the dependencies declared by this method are not required for the library to operate but if present will be used. It is NOT part of the official "Optional Package" specification.

See Also
Installed extension dependency
REQUIRE_IMPLEMENTATION_UPGRADEback to summary
public static final Compatibility REQUIRE_IMPLEMENTATION_UPGRADE

Enum indicating that extension requires an upgrade of implementation to be compatible with other extension.

REQUIRE_SPECIFICATION_UPGRADEback to summary
public static final Compatibility REQUIRE_SPECIFICATION_UPGRADE

Enum indicating that extension requires an upgrade of specification to be compatible with other extension.

REQUIRE_VENDOR_SWITCHback to summary
public static final Compatibility REQUIRE_VENDOR_SWITCH

Enum indicating that extension requires a vendor switch to be compatible with other extension.

SPECIFICATION_VENDORback to summary
public static final Attributes.Name SPECIFICATION_VENDOR

Manifest Attribute Name object for SPECIFICATION_VENDOR.

SPECIFICATION_VERSIONback to summary
public static final Attributes.Name SPECIFICATION_VERSION

Manifest Attribute Name object for SPECIFICATION_VERSION.

specificationVendorback to summary
private String specificationVendor

The name of the company or organization that originated the specification to which this optional package conforms.

specificationVersionback to summary
private DeweyDecimal specificationVersion

The version number (dotted decimal notation) of the specification to which this optional package conforms.

Constructor Detail

Extensionback to summary
public Extension(final String extensionName, final String specificationVersion, final String specificationVendor, final String implementationVersion, final String implementationVendor, final String implementationVendorId, final String implementationURL)

The constructor to create Extension object. Note that every component is allowed to be specified but only the extensionName is mandatory.

Parameters
extensionName:String

the name of extension.

specificationVersion:String

the specification Version of extension.

specificationVendor:String

the specification Vendor of extension.

implementationVersion:String

the implementation Version of extension.

implementationVendor:String

the implementation Vendor of extension.

implementationVendorId:String

the implementation VendorId of extension.

implementationURL:String

the implementation URL of extension.

Method Detail

addExtensionback to summary
public static void addExtension(final Extension extension, final Attributes attributes)

Add Extension to the specified manifest Attributes.

Parameters
extension:Extension

the extension

attributes:Attributes

the attributes of manifest to add to

addExtensionback to summary
public static void addExtension(final Extension extension, final String prefix, final Attributes attributes)

Add Extension to the specified manifest Attributes. Use the specified prefix so that dependencies can added with a prefix such as "java3d-" etc.

Parameters
extension:Extension

the extension

prefix:String

the name to prefix to extension

attributes:Attributes

the attributes of manifest to add to

getAvailableback to summary
public static Extension[] getAvailable(final Manifest manifest)

Return an array of Extension objects representing optional packages that are available in the JAR file associated with the specified Manifest. If there are no such optional packages, a zero-length array is returned.

Parameters
manifest:Manifest

Manifest to be parsed

Returns:Extension[]

the "available" extensions in specified manifest

getCompatibilityWithback to summary
public Compatibility getCompatibilityWith(final Extension required)

Return a Compatibility enum indicating the relationship of this Extension with the specified Extension.

Parameters
required:Extension

Description of the required optional package

Returns:Compatibility

the enum indicating the compatibility (or lack thereof) of specified extension

getExtensionback to summary
private static void getExtension(final Attributes attributes, final List<Extension> required, final Attributes.Name listKey)

Add required optional packages defined in the specified attributes entry, if any.

Parameters
attributes:Attributes

Attributes to be parsed

required:List<Extension>

list to add required optional packages to

listKey:Attributes.Name

the key to use to lookup list, usually EXTENSION_LIST or OPTIONAL_EXTENSION_LIST

getExtensionback to summary
private static Extension getExtension(final String prefix, final Attributes attributes)

Extract an Extension from Attributes. Prefix indicates the prefix checked for each string. Usually the prefix is "<extension>-" if looking for a Required extension. If you are looking for an Available extension then the prefix is "".

Parameters
prefix:String

the prefix for each attribute name

attributes:Attributes

Attributes to searched

Returns:Extension

the new Extension object, or null

getExtensionNameback to summary
public String getExtensionName()

Get the name of the extension.

Returns:String

the name of the extension

getImplementationURLback to summary
public String getImplementationURL()

Get the url of the extensions implementation.

Returns:String

the url of the extensions implementation.

getImplementationVendorback to summary
public String getImplementationVendor()

Get the vendor of the extensions implementation.

Returns:String

the vendor of the extensions implementation.

getImplementationVendorIDback to summary
public String getImplementationVendorID()

Get the vendorID of the extensions implementation.

Returns:String

the vendorID of the extensions implementation.

getImplementationVersionback to summary
public DeweyDecimal getImplementationVersion()

Get the version of the extensions implementation.

Returns:DeweyDecimal

the version of the extensions implementation.

getListedback to summary
private static Extension[] getListed(final Manifest manifest, final Attributes.Name listKey)

Retrieve all the extensions listed under a particular key (Usually EXTENSION_LIST or OPTIONAL_EXTENSION_LIST).

Parameters
manifest:Manifest

the manifest to extract extensions from

listKey:Attributes.Name

the key used to get list (Usually EXTENSION_LIST or OPTIONAL_EXTENSION_LIST)

Returns:Extension[]

the list of listed extensions

getOptionsback to summary
public static Extension[] getOptions(final Manifest manifest)

Return the set of Extension objects representing "Optional Packages" that the application declares they will use if present. If there are no such optional packages, a zero-length list is returned.

Parameters
manifest:Manifest

Manifest to be parsed

Returns:Extension[]

the optional dependencies that are specified in manifest

getRequiredback to summary
public static Extension[] getRequired(final Manifest manifest)

Return the set of Extension objects representing optional packages that are required by the application contained in the JAR file associated with the specified Manifest. If there are no such optional packages, a zero-length list is returned.

Parameters
manifest:Manifest

Manifest to be parsed

Returns:Extension[]

the dependencies that are specified in manifest

getSpecificationVendorback to summary
public String getSpecificationVendor()

Get the vendor of the extensions specification.

Returns:String

the vendor of the extensions specification.

getSpecificationVersionback to summary
public DeweyDecimal getSpecificationVersion()

Get the version of the extensions specification.

Returns:DeweyDecimal

the version of the extensions specification.

getTrimmedStringback to summary
private static String getTrimmedString(final String value)

Trim the supplied string if the string is non-null

Parameters
value:String

the string to trim or null

Returns:String

the trimmed string or null

isCompatibleback to summary
private boolean isCompatible(final DeweyDecimal first, final DeweyDecimal second)

Return true if the first version number is greater than or equal to the second; otherwise return false.

Parameters
first:DeweyDecimal

First version number (dotted decimal)

second:DeweyDecimal

Second version number (dotted decimal)

isCompatibleWithback to summary
public boolean isCompatibleWith(final Extension required)

Return true if the specified Extension (which represents an optional package required by an application) is satisfied by this Extension (which represents an optional package that is already installed. Otherwise, return false.

Parameters
required:Extension

Description of the required optional package

Returns:boolean

true if the specified extension is compatible with this extension

splitback to summary
private static String[] split(final String string, final String onToken)

Splits the string on every token into an array of strings.

Parameters
string:String

the string

onToken:String

the token

Returns:String[]

the resultant array

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Return a String representation of this object.

Returns:String

string representation of object.

Annotations
@Override