Search in sources :

Example 6 with Name

use of java.util.jar.Attributes.Name in project bnd by bndtools.

the class Analyzer method merge.

/**
	 * @param manifests
	 * @throws Exception
	 */
private void merge(Manifest result, Manifest old) {
    if (old != null) {
        for (Iterator<Map.Entry<Object, Object>> e = old.getMainAttributes().entrySet().iterator(); e.hasNext(); ) {
            Map.Entry<Object, Object> entry = e.next();
            Attributes.Name name = (Attributes.Name) entry.getKey();
            String value = (String) entry.getValue();
            if (name.toString().equalsIgnoreCase(Constants.CREATED_BY))
                name = new Attributes.Name("Originally-Created-By");
            if (!result.getMainAttributes().containsKey(name))
                result.getMainAttributes().put(name, value);
        }
        // do not overwrite existing entries
        Map<String, Attributes> oldEntries = old.getEntries();
        Map<String, Attributes> newEntries = result.getEntries();
        for (Iterator<Map.Entry<String, Attributes>> e = oldEntries.entrySet().iterator(); e.hasNext(); ) {
            Map.Entry<String, Attributes> entry = e.next();
            if (!newEntries.containsKey(entry.getKey())) {
                newEntries.put(entry.getKey(), entry.getValue());
            }
        }
    }
}
Also used : Entry(java.util.Map.Entry) Attributes(java.util.jar.Attributes) Name(java.util.jar.Attributes.Name) MultiMap(aQute.lib.collections.MultiMap) Map(java.util.Map) HashMap(java.util.HashMap) Name(java.util.jar.Attributes.Name)

Aggregations

Name (java.util.jar.Attributes.Name)6 Attributes (java.util.jar.Attributes)4 Manifest (java.util.jar.Manifest)3 PomFromManifest (aQute.bnd.maven.PomFromManifest)1 Instructions (aQute.bnd.osgi.Instructions)1 MultiMap (aQute.lib.collections.MultiMap)1 Description (aQute.lib.getopt.Description)1 UTF8Properties (aQute.lib.utf8properties.UTF8Properties)1 QuotedTokenizer (aQute.libg.qtokens.QuotedTokenizer)1 BaseCmd (com.googlecode.dex2jar.tools.BaseCmd)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Properties (java.util.Properties)1