Added title to ProviderInfo.

Added toString method.
This commit is contained in:
Harald Kuhr 2009-11-04 01:22:35 +01:00
parent 317ed16814
commit ebc365528a

View File

@ -16,6 +16,7 @@ public class ProviderInfo {
// TODO: Consider reading the META-INF/MANIFEST.MF from the class path using java.util.jar.Manifest.
// Use the manifest that is located in the same class path folder as the package.
private final String mTitle;
private final String mVendorName;
private final String mVersion;
@ -30,6 +31,9 @@ public class ProviderInfo {
public ProviderInfo(final Package pPackage) {
Validate.notNull(pPackage, "package");
String title = pPackage.getImplementationTitle();
mTitle = title != null ? title : pPackage.getName();
String vendor = pPackage.getImplementationVendor();
mVendorName = vendor != null ? vendor : fakeVendor(pPackage);
@ -47,6 +51,18 @@ public class ProviderInfo {
return name.startsWith("com.twelvemonkeys") ? "DEV" : "Unspecified";
}
/**
* Returns the implementation title, as specified in the manifest entry
* {@code Implementation-Title} for the package.
* If the title is unavailable, the package name or some default name
* for known packages are used.
*
* @return the implementation title
*/
final String getImplementationTitle() {
return mTitle;
}
/**
* Returns the vendor name, as specified in the manifest entry
* {@code Implementation-Vendor} for the package.
@ -69,4 +85,9 @@ public class ProviderInfo {
public final String getVersion() {
return mVersion;
}
@Override
public String toString() {
return mTitle + ", " + mVersion + " by " + mVendorName;
}
}