mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2026-05-01 00:00:02 -04:00
Added title to ProviderInfo.
Added toString method.
This commit is contained in:
+21
@@ -16,6 +16,7 @@ public class ProviderInfo {
|
|||||||
// TODO: Consider reading the META-INF/MANIFEST.MF from the class path using java.util.jar.Manifest.
|
// 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.
|
// 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 mVendorName;
|
||||||
private final String mVersion;
|
private final String mVersion;
|
||||||
|
|
||||||
@@ -30,6 +31,9 @@ public class ProviderInfo {
|
|||||||
public ProviderInfo(final Package pPackage) {
|
public ProviderInfo(final Package pPackage) {
|
||||||
Validate.notNull(pPackage, "package");
|
Validate.notNull(pPackage, "package");
|
||||||
|
|
||||||
|
String title = pPackage.getImplementationTitle();
|
||||||
|
mTitle = title != null ? title : pPackage.getName();
|
||||||
|
|
||||||
String vendor = pPackage.getImplementationVendor();
|
String vendor = pPackage.getImplementationVendor();
|
||||||
mVendorName = vendor != null ? vendor : fakeVendor(pPackage);
|
mVendorName = vendor != null ? vendor : fakeVendor(pPackage);
|
||||||
|
|
||||||
@@ -47,6 +51,18 @@ public class ProviderInfo {
|
|||||||
return name.startsWith("com.twelvemonkeys") ? "DEV" : "Unspecified";
|
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
|
* Returns the vendor name, as specified in the manifest entry
|
||||||
* {@code Implementation-Vendor} for the package.
|
* {@code Implementation-Vendor} for the package.
|
||||||
@@ -69,4 +85,9 @@ public class ProviderInfo {
|
|||||||
public final String getVersion() {
|
public final String getVersion() {
|
||||||
return mVersion;
|
return mVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return mTitle + ", " + mVersion + " by " + mVendorName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user