Class ManifestFileVar

public class ManifestFileVar extends DefaultingVar
Manifest file entries variable resolver.

The format for this var is "$MF{key[,default]}".

This variable resolver requires that a ManifestFile object be made available by calling the init(ManifestFile) method.


// Create a ManifestFile object that contains the manifest of the jar file containing this class. ManifestFile manifestFile = new ManifestFile(this.getClass()); ManifestFileVar.init(manifestFile); // Create a variable resolver that resolves manifest file entries (e.g. "$MF{Main-Class}") VarResolver varResolver = VarResolver.create().vars(ManifestFile.class).build(); // Use it! System.out.println(varResolver.resolve("The main class is $MF{Main-Class}"));

Since this is a SimpleVar, any variables contained in the result will be recursively resolved. Likewise, if the arguments contain any variables, those will be resolved before they are passed to this var.

See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • init

      public static void init(ManifestFile manifestFile)
      Initialize the manifest file for this variable.
      manifestFile - The parsed manifest file.
    • resolve

      public String resolve(VarResolverSession session, String key)
      Description copied from class: Var
      The interface that needs to be implemented for subclasses of SimpleVar.
      Specified by:
      resolve in class Var
      session - The session object used for a single instance of a var resolution.
      key - The inside argument of the variable.
      The resolved value.