Class ManifestFile

All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>

public class ManifestFile extends JsonMap
Utility class for working with Jar manifest files.

Copies the contents of a Manifest into an JsonMap so that the various convenience methods on that class can be used to retrieve values.

  • Constructor Details

    • ManifestFile

      public ManifestFile(Class<?> c) throws IOException
      Finds and loads the manifest file of the jar file that the specified class is contained within.
      Parameters:
      c - The class to get the manifest file of.
      Throws:
      IOException - If a problem occurred while trying to read the manifest file.
    • ManifestFile

      public ManifestFile(File f) throws IOException
      Create an instance of this class from a manifest file on the file system.
      Parameters:
      f - The manifest file.
      Throws:
      IOException - If a problem occurred while trying to read the manifest file.
    • ManifestFile

      Create an instance of this class loaded from the contents of an input stream.

      Note that the input must end in a newline to pick up the last line!

      Parameters:
      is - The manifest file contents.
      Throws:
      IOException - If a problem occurred while trying to read the manifest file.
    • ManifestFile

      Create an instance of this class from a Manifest object.
      Parameters:
      f - The manifest to read from.
    • ManifestFile

      public ManifestFile(Path path) throws IOException
      Create an instance of this class from a manifest path on the file system.
      Parameters:
      path - The manifest path.
      Throws:
      IOException - If a problem occurred while trying to read the manifest path.
    • ManifestFile

      public ManifestFile(Reader r) throws IOException
      Create an instance of this class loaded from the contents of a reader.

      Note that the input must end in a newline to pick up the last line!

      Parameters:
      r - The manifest file contents.
      Throws:
      IOException - If a problem occurred while trying to read the manifest file.
  • Method Details

    • append

      public ManifestFile append(Map<String,Object> values)
      Description copied from class: JsonMap
      Appends all the entries in the specified map to this map.
      Overrides:
      append in class JsonMap
      Parameters:
      values - The map to copy. Can be null.
      Returns:
      This object.
    • append

      public ManifestFile append(String key, Object value)
      Description copied from class: JsonMap
      Adds an entry to this map.
      Overrides:
      append in class JsonMap
      Parameters:
      key - The key.
      value - The value.
      Returns:
      This object.
    • appendIf

      public ManifestFile appendIf(boolean flag, String key, Object value)
      Description copied from class: JsonMap
      Add if flag is true.
      Overrides:
      appendIf in class JsonMap
      Parameters:
      flag - The flag to check.
      key - The key.
      value - The value.
      Returns:
      This object.
    • filtered

      Description copied from class: JsonMap
      Enables filtering based on a predicate test.

      If the predicate evaluates to false on values added to this map, the entry will be skipped.

      Overrides:
      filtered in class JsonMap
      Parameters:
      value - The value tester predicate.
      Returns:
      This object.
    • inner

      public ManifestFile inner(Map<String,Object> inner)
      Description copied from class: JsonMap
      Set an inner map in this map to allow for chained get calls.

      If JsonMap.get(Object) returns null, then JsonMap.get(Object) will be called on the inner map.

      In addition to providing the ability to chain maps, this method also provides the ability to wrap an existing map inside another map so that you can add entries to the outer map without affecting the values on the inner map.

      JsonMap map1 = JsonMap.ofJson("{foo:1}"); JsonMap map2 = JsonMap.of().setInner(map1); map2.put("foo", 2); // Overwrite the entry int foo1 = map1.getInt("foo"); // foo1 == 1 int foo2 = map2.getInt("foo"); // foo2 == 2

      Overrides:
      inner in class JsonMap
      Parameters:
      inner - The inner map. Can be null to remove the inner map from an existing map.
      Returns:
      This object.
    • keepAll

      public ManifestFile keepAll(String... keys)
      Description copied from class: JsonMap
      The opposite of JsonMap.removeAll(String...).

      Discards all keys from this map that aren't in the specified list.

      Overrides:
      keepAll in class JsonMap
      Parameters:
      keys - The keys to keep.
      Returns:
      This map.
    • modifiable

      Description copied from class: JsonMap
      Returns a modifiable copy of this map if it's unmodifiable.
      Overrides:
      modifiable in class JsonMap
      Returns:
      A modifiable copy of this map if it's unmodifiable, or this map if it is already modifiable.
    • session

      public ManifestFile session(BeanSession session)
      Description copied from class: JsonMap
      Override the default bean session used for converting POJOs.

      Default is BeanContext.DEFAULT, which is sufficient in most cases.

      Useful if you're serializing/parsing beans with transforms defined.

      Overrides:
      session in class JsonMap
      Parameters:
      session - The new bean session.
      Returns:
      This object.
    • setBeanSession

      Description copied from class: JsonMap
      Sets the BeanSession currently associated with this map.
      Overrides:
      setBeanSession in class JsonMap
      Parameters:
      value - The BeanSession currently associated with this map.
      Returns:
      This object.
    • toString

      public String toString()
      Overrides:
      toString in class JsonMap
    • unmodifiable

      Description copied from class: JsonMap
      Returns an unmodifiable copy of this map if it's modifiable.
      Overrides:
      unmodifiable in class JsonMap
      Returns:
      An unmodifiable copy of this map if it's modifiable, or this map if it is already unmodifiable.