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

public final Class Specification

extends Object
Class Inheritance
Imports
java.text.ParseException, java.util.ArrayList, .Collections, .Iterator, .List, .Map, .Optional, 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 Package Specification.

public static final Attributes.Name
IMPLEMENTATION_TITLE

Manifest Attribute Name object for IMPLEMENTATION_TITLE.

public static final Attributes.Name
IMPLEMENTATION_VENDOR

Manifest Attribute Name object for IMPLEMENTATION_VENDOR.

public static final Attributes.Name
IMPLEMENTATION_VERSION

Manifest Attribute Name object for IMPLEMENTATION_VERSION.

private String
implementationTitle

The title of implementation.

private String
implementationVendor

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

private String
implementationVersion

The version string for implementation.

public static final Compatibility
INCOMPATIBLE

This enum indicates that an extension is incompatible with other Package Specification in ways other than other enums indicate.

private static final String
public static final Compatibility
REQUIRE_IMPLEMENTATION_CHANGE

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

public static final Compatibility
REQUIRE_SPECIFICATION_UPGRADE

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

public static final Compatibility
REQUIRE_VENDOR_SWITCH

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

private String[]
sections

The sections of jar that the specification applies to.

public static final Attributes.Name
SPECIFICATION_TITLE

Manifest Attribute Name object for SPECIFICATION_TITLE.

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
specificationTitle

The name of the Package Specification.

private String
specificationVendor

The name of the company or organization that originated the specification to which this specification 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
Specification(final String
the name of specification.
specificationTitle
,
final String
the specification Version.
specificationVersion
,
final String
the specification Vendor.
specificationVendor
,
final String
the title of implementation.
implementationTitle
,
final String
the implementation Version.
implementationVersion
,
final String
the implementation Vendor.
implementationVendor
)

The constructor to create Package Specification object.

public
Specification(final String
the name of specification.
specificationTitle
,
final String
the specification Version.
specificationVersion
,
final String
the specification Vendor.
specificationVendor
,
final String
the title of implementation.
implementationTitle
,
final String
the implementation Version.
implementationVersion
,
final String
the implementation Vendor.
implementationVendor
,
final String[]
the sections/packages that Specification applies to.
sections
)

The constructor to create Package Specification object.

Method Summary

Modifier and TypeMethod and Description
public Compatibility

Returns:

the enum indicating the compatibility (or lack thereof) of specified Package Specification
getCompatibilityWith
(final Specification
the other specification
other
)

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

public String

Returns:

the title of the specification.
getImplementationTitle
()

Get the title of the specification.

public String

Returns:

the vendor of the extensions implementation.
getImplementationVendor
()

Get the vendor of the extensions implementation.

public String

Returns:

the version of the implementation.
getImplementationVersion
()

Get the version of the implementation.

public String[]

Returns:

an array containing sections to which specification applies or null if relevant to no sections.
getSections
()

Return an array containing sections to which specification applies or null if relevant to no sections.

private static Specification

Returns:

the new Specification object, or null
getSpecification
(final String section, final Attributes
Attributes to searched
attributes
)

Extract an Package Specification from Attributes.

public static Specification[]

Returns:

the Package Specifications extensions in specified manifest
getSpecifications
(final Manifest
Manifest to be parsed
manifest
)

Return an array of Package Specification objects.

public String

Returns:

the title of specification
getSpecificationTitle
()

Get the title of the specification.

public String

Returns:

the vendor of the specification.
getSpecificationVendor
()

Get the vendor of the specification.

public DeweyDecimal

Returns:

the version of the specification.
getSpecificationVersion
()

Get the version of the 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 specification is compatible with this specification
isCompatibleWith
(final Specification
the specification
other
)

Return true if the specified package is satisfied by this Specification.

private static boolean

Returns:

true if two specifications are equal except for their sections, else false
isEqual
(final Specification
one specification
specification
,
final Specification
the other specification
other
)

Test if two specifications are equal except for their sections.

private static Specification

Returns:

the merged specification
mergeInSections
(final Specification
the specification
specification
,
final List<String>
the list of sections to merge
sectionsToAdd
)

Merge the specified sections into specified section and return result.

private static List<Specification>

Returns:

an array list with all duplicates removed
removeDuplicates
(final List<Specification>
the array of results to trim
list
)

Combine all specifications objects that are identical except for the sections.

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 Package Specification.

IMPLEMENTATION_TITLEback to summary
public static final Attributes.Name IMPLEMENTATION_TITLE

Manifest Attribute Name object for IMPLEMENTATION_TITLE.

IMPLEMENTATION_VENDORback to summary
public static final Attributes.Name IMPLEMENTATION_VENDOR

Manifest Attribute Name object for IMPLEMENTATION_VENDOR.

IMPLEMENTATION_VERSIONback to summary
public static final Attributes.Name IMPLEMENTATION_VERSION

Manifest Attribute Name object for IMPLEMENTATION_VERSION.

implementationTitleback to summary
private String implementationTitle

The title of implementation.

implementationVendorback to summary
private String implementationVendor

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

implementationVersionback to summary
private String implementationVersion

The version string for implementation. The version string is opaque.

INCOMPATIBLEback to summary
public static final Compatibility INCOMPATIBLE

This enum indicates that an extension is incompatible with other Package Specification in ways other than other enums indicate. For example, the other Package Specification may have a different ID.

MISSINGback to summary
private static final String MISSING
REQUIRE_IMPLEMENTATION_CHANGEback to summary
public static final Compatibility REQUIRE_IMPLEMENTATION_CHANGE

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

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 Package Specification.

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 Package Specification.

sectionsback to summary
private String[] sections

The sections of jar that the specification applies to.

SPECIFICATION_TITLEback to summary
public static final Attributes.Name SPECIFICATION_TITLE

Manifest Attribute Name object for SPECIFICATION_TITLE.

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.

specificationTitleback to summary
private String specificationTitle

The name of the Package Specification.

specificationVendorback to summary
private String specificationVendor

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

specificationVersionback to summary
private DeweyDecimal specificationVersion

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

Constructor Detail

Specificationback to summary
public Specification(final String specificationTitle, final String specificationVersion, final String specificationVendor, final String implementationTitle, final String implementationVersion, final String implementationVendor)

The constructor to create Package Specification object. Note that every component is allowed to be specified but only the specificationTitle is mandatory.

Parameters
specificationTitle:String

the name of specification.

specificationVersion:String

the specification Version.

specificationVendor:String

the specification Vendor.

implementationTitle:String

the title of implementation.

implementationVersion:String

the implementation Version.

implementationVendor:String

the implementation Vendor.

Specificationback to summary
public Specification(final String specificationTitle, final String specificationVersion, final String specificationVendor, final String implementationTitle, final String implementationVersion, final String implementationVendor, final String[] sections)

The constructor to create Package Specification object. Note that every component is allowed to be specified but only the specificationTitle is mandatory.

Parameters
specificationTitle:String

the name of specification.

specificationVersion:String

the specification Version.

specificationVendor:String

the specification Vendor.

implementationTitle:String

the title of implementation.

implementationVersion:String

the implementation Version.

implementationVendor:String

the implementation Vendor.

sections:String[]

the sections/packages that Specification applies to.

Method Detail

getCompatibilityWithback to summary
public Compatibility getCompatibilityWith(final Specification other)

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

Parameters
other:Specification

the other specification

Returns:Compatibility

the enum indicating the compatibility (or lack thereof) of specified Package Specification

getImplementationTitleback to summary
public String getImplementationTitle()

Get the title of the specification.

Returns:String

the title of the specification.

getImplementationVendorback to summary
public String getImplementationVendor()

Get the vendor of the extensions implementation.

Returns:String

the vendor of the extensions implementation.

getImplementationVersionback to summary
public String getImplementationVersion()

Get the version of the implementation.

Returns:String

the version of the implementation.

getSectionsback to summary
public String[] getSections()

Return an array containing sections to which specification applies or null if relevant to no sections.

Returns:String[]

an array containing sections to which specification applies or null if relevant to no sections.

getSpecificationback to summary
private static Specification getSpecification(final String section, final Attributes attributes) throws ParseException

Extract an Package Specification from Attributes.

Parameters
attributes:Attributes

Attributes to searched

Returns:Specification

the new Specification object, or null

getSpecificationsback to summary
public static Specification[] getSpecifications(final Manifest manifest) throws ParseException

Return an array of Package Specification objects. If there are no such optional packages, a zero-length array is returned.

Parameters
manifest:Manifest

Manifest to be parsed

Returns:Specification[]

the Package Specifications extensions in specified manifest

Exceptions
ParseException:
if the attributes of the specifications cannot be parsed according to their expected formats.
getSpecificationTitleback to summary
public String getSpecificationTitle()

Get the title of the specification.

Returns:String

the title of specification

getSpecificationVendorback to summary
public String getSpecificationVendor()

Get the vendor of the specification.

Returns:String

the vendor of the specification.

getSpecificationVersionback to summary
public DeweyDecimal getSpecificationVersion()

Get the version of the specification.

Returns:DeweyDecimal

the version of the 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 Specification other)

Return true if the specified package is satisfied by this Specification. Otherwise, return false.

Parameters
other:Specification

the specification

Returns:boolean

true if the specification is compatible with this specification

isEqualback to summary
private static boolean isEqual(final Specification specification, final Specification other)

Test if two specifications are equal except for their sections.

Parameters
specification:Specification

one specification

other:Specification

the other specification

Returns:boolean

true if two specifications are equal except for their sections, else false

mergeInSectionsback to summary
private static Specification mergeInSections(final Specification specification, final List<String> sectionsToAdd)

Merge the specified sections into specified section and return result. If no sections to be added then just return original specification.

Parameters
specification:Specification

the specification

sectionsToAdd:List<String>

the list of sections to merge

Returns:Specification

the merged specification

removeDuplicatesback to summary
private static List<Specification> removeDuplicates(final List<Specification> list)

Combine all specifications objects that are identical except for the sections.

Note this is very inefficient and should probably be fixed in the future.

Parameters
list:List<Specification>

the array of results to trim

Returns:List<Specification>

an array list with all duplicates removed

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