view com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/BundleInformationExtractor.java @ 90:8f2dd0dbdb87

Externalize strings
author Omair Majid <omajid@redhat.com>
date Tue, 21 Jan 2014 19:51:04 -0500
parents b788a26c0d4d
children 10ffc183f39e
line wrap: on
line source

package com.redhat.thermostat.tools.eclipse.plugin;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.jar.Attributes;
import java.util.jar.JarInputStream;

import com.redhat.thermostat.tools.eclipse.plugin.model.Bundle;

public class BundleInformationExtractor {

    public Bundle extract(String path) throws FileNotFoundException, IOException {

        try (JarInputStream in = new JarInputStream(new FileInputStream(path))) {
            Attributes attr = in.getManifest().getMainAttributes();
            String name = attr.getValue("Bundle-SymbolicName"); //$NON-NLS-1$
            String version = attr.getValue("Bundle-Version"); //$NON-NLS-1$

            return new Bundle(name, version);
        }
    }

}