Class JarManifestHelper

java.lang.Object
org.kiwiproject.beta.base.jar.JarManifestHelper

@Beta public class JarManifestHelper extends Object
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 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 associated MANIFEST.MF file.
      Parameters:
      theClass - the Class to use for finding the Manifest
      name - 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 Manifest
      name - the name of the main attribute
      Returns:
      a lookup result
    • getMainAttributes

      public AttributesLookupResult getMainAttributes(Class<?> theClass)
      Return the main attributes of the Manifest, using the given Class to locate the associated MANIFEST.MF file.
      Parameters:
      theClass - the Class to use for finding the Manifest
      Returns:
      a lookup result
    • getMainAttributes

      public Map<String,String> getMainAttributes(Manifest manifest)
      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

      public Optional<Manifest> getManifest(Class<?> theClass)
      Use the given Class to locate the associated MANIFEST.MF file.
      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

      public ManifestLookupResult getManifestWithResult(Class<?> theClass)
      Use the given Class to locate the associated MANIFEST.MF file.
      Parameters:
      theClass - the Class to use for finding the Manifest
      Returns:
      a ManifestLookupResult containing information about the lookup
    • getManifest

      public Optional<Manifest> getManifest(URI jarFileURI)
      Use the given URI to locate the associated MANIFEST.MF file.
      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

      public ManifestLookupResult getManifestWithResult(URI jarFileURI)
      Use the given URI to locate the associated MANIFEST.MF file.
      Parameters:
      jarFileURI - the URI of the JAR file in which the manifest resides
      Returns:
      a ManifestLookupResult containing information about the lookup