Class ManifestProcessor


  • public class ManifestProcessor
    extends java.lang.Object
    This class contains utilities for parsing manifests. It provides methods to parse the manifest, read a manifest into a map and to split an manifest entry that follows the Import-Package syntax.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.jar.Manifest mapToManifest​(java.util.Map<java.lang.String,​java.lang.String> attributes)
      mapToManifest
      static java.util.jar.Manifest obtainManifestFromAppDir​(IDirectory appDir, java.lang.String manifestName)
      Obtain a manifest from an IDirectory.
      static java.util.jar.Manifest parseManifest​(java.io.InputStream in)
      This method parses the manifest using a custom manifest parsing routine.
      static java.util.Map<java.lang.String,​java.lang.String> readManifestIntoMap​(java.util.jar.Manifest mf)
      Reads a manifest's main attributes into a String->String map.
      static java.util.List<java.lang.String> split​(java.lang.String value, java.lang.String delimiter)
      Splits a delimiter separated string, tolerating presence of non separator commas within double quoted segments.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ManifestProcessor

        public ManifestProcessor()
    • Method Detail

      • readManifestIntoMap

        public static java.util.Map<java.lang.String,​java.lang.String> readManifestIntoMap​(java.util.jar.Manifest mf)
        Reads a manifest's main attributes into a String->String map.

        Will always return a map, empty if the manifest had no attributes.

        Parameters:
        mf - The manifest to read.
        Returns:
        Map of manifest main attributes.
      • mapToManifest

        public static java.util.jar.Manifest mapToManifest​(java.util.Map<java.lang.String,​java.lang.String> attributes)
        mapToManifest
      • parseManifest

        public static java.util.jar.Manifest parseManifest​(java.io.InputStream in)
                                                    throws java.io.IOException
        This method parses the manifest using a custom manifest parsing routine. This means that we can avoid the 76 byte line length in a manifest providing a better developer experience.
        Parameters:
        in - the input stream to read the manifest from.
        Returns:
        the parsed manifest
        Throws:
        java.io.IOException
      • obtainManifestFromAppDir

        public static java.util.jar.Manifest obtainManifestFromAppDir​(IDirectory appDir,
                                                                      java.lang.String manifestName)
                                                               throws java.io.IOException
        Obtain a manifest from an IDirectory.
        Parameters:
        appDir -
        manifestName - the name of manifest
        Returns:
        Manifest, or null if none found.
        Throws:
        java.io.IOException
      • split

        public static java.util.List<java.lang.String> split​(java.lang.String value,
                                                             java.lang.String delimiter)
        Splits a delimiter separated string, tolerating presence of non separator commas within double quoted segments. Eg. com.ibm.ws.eba.helloWorldService;version="[1.0.0, 1.0.0]" & com.ibm.ws.eba.helloWorldService;version="1.0.0" com.ibm.ws.eba.helloWorld;version="2";bundle-version="[2,30)" com.acme.foo;weirdAttr="one;two;three";weirdDir:="1;2;3"
        Parameters:
        value - the value to be split
        delimiter - the delimiter string such as ',' etc.
        Returns:
        List the components of the split String in a list