Package org.kiwiproject.beta.base.jar
Class JarManifestHelper
java.lang.Object
org.kiwiproject.beta.base.jar.JarManifestHelper
Utilities for working with JAR manifests.
Unlike JarManifests, this is an instance-based class, which allows
for easier testing using techniques such as mocking. In addition, some methods
in this class return "result" objects, which contain more information than
an Optional can convey.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetMainAttributes(Class<?> theClass) Return the main attributes of the Manifest, using the given Class to locate the associatedMANIFEST.MFfile.getMainAttributes(Manifest manifest) Return the main attributes of the given Manifest as a Map of String keys to String values.getMainAttributeValue(Class<?> theClass, String name) Get the main attribute value in a Manifest, using the given Class to locate the associatedMANIFEST.MFfile.getMainAttributeValue(Manifest manifest, String name) Get the main attribute value in a Manifest having the given name.getManifest(Class<?> theClass) Use the given Class to locate the associatedMANIFEST.MFfile.getManifest(URI jarFileURI) Use the given URI to locate the associatedMANIFEST.MFfile.getManifestWithResult(Class<?> theClass) Use the given Class to locate the associatedMANIFEST.MFfile.getManifestWithResult(URI jarFileURI) Use the given URI to locate the associatedMANIFEST.MFfile.
-
Constructor Details
-
JarManifestHelper
public JarManifestHelper()
-
-
Method Details
-
getMainAttributeValue
@CheckReturnValue public AttributeLookupResult getMainAttributeValue(Class<?> theClass, String name) Get the main attribute value in a Manifest, using the given Class to locate the associatedMANIFEST.MFfile.- Parameters:
theClass- the Class to use for finding the Manifestname- the name of the main attribute- Returns:
- a lookup result
-
getMainAttributeValue
@CheckReturnValue public AttributeLookupResult getMainAttributeValue(Manifest manifest, String name) Get the main attribute value in a Manifest having the given name.- Parameters:
manifest- the Manifestname- the name of the main attribute- Returns:
- a lookup result
-
getMainAttributes
Return the main attributes of the Manifest, using the given Class to locate the associatedMANIFEST.MFfile.- Parameters:
theClass- the Class to use for finding the Manifest- Returns:
- a lookup result
-
getMainAttributes
Return the main attributes of the given Manifest as a Map of String keys to String values.- Parameters:
manifest- the manifest- Returns:
- a map containing the main attributes
-
getManifest
Use the given Class to locate the associatedMANIFEST.MFfile.- Parameters:
theClass- the Class to use for finding the Manifest- Returns:
- an Optional containing the Manifest, or an empty Optional if any error occurs
-
getManifestWithResult
Use the given Class to locate the associatedMANIFEST.MFfile.- Parameters:
theClass- the Class to use for finding the Manifest- Returns:
- a
ManifestLookupResultcontaining information about the lookup
-
getManifest
Use the given URI to locate the associatedMANIFEST.MFfile.- Parameters:
jarFileURI- the URI of the JAR file in which the manifest resides- Returns:
- an Optional containing the Manifest, or an empty Optional if any error occurs
-
getManifestWithResult
Use the given URI to locate the associatedMANIFEST.MFfile.- Parameters:
jarFileURI- the URI of the JAR file in which the manifest resides- Returns:
- a
ManifestLookupResultcontaining information about the lookup
-