⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jumpinstallertool.java

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                JUMPInstallerModule installers[] = JUMPInstallerModuleFactory.getInstance().getAllInstallers();                int numApps = 0;                for (int i = 0; i < installers.length; i++) {                        JUMPContent[] content = installers[i].getInstalled();            if (content != null) {                for(int j = 0; j < content.length; j++) {                    numApps++;                    JUMPApplication app = (JUMPApplication)content[j];                    System.out.println("App #" + numApps + ": " + app.getTitle());                    JUMPAppModel model = app.getAppType();                    if (model == JUMPAppModel.XLET) {                        XLETApplication xlet = (XLETApplication)app;                        System.out.println("    Bundle: " + xlet.getBundle());                        System.out.println("       Jar: " + xlet.getClasspath());                        System.out.println("Install ID: " + xlet.getId());                        URL iconPath = xlet.getIconPath();                        if (iconPath == null) {                            System.out.println("      Icon: <none>");                        } else {                            System.out.println("      Icon: " + iconPath.getFile());                        }                        System.out.println("     Model: " + JUMPAppModel.XLET.toString());                    } else if (model == JUMPAppModel.MAIN) {                        MAINApplication main = (MAINApplication)app;                        System.out.println("    Bundle: " + main.getBundle());                        System.out.println("       Jar: " + main.getClasspath());                        System.out.println("Install ID: " + main.getId());                        URL iconPath = main.getIconPath();                        if (iconPath == null) {                            System.out.println("      Icon: <none>");                        } else {                            System.out.println("      Icon: " + iconPath.getFile());                        }                        System.out.println("     Model: " + JUMPAppModel.MAIN.toString());                    } else if (model == JUMPAppModel.MIDLET) {                        System.out.println("  Suite ID: " + app.getProperty("MIDletApplication_suiteid"));                        System.out.println("Install ID: " + app.getId());                        URL iconPath = app.getIconPath();                        if (iconPath == null) {                            System.out.println("      Icon: <none>");                        } else {                            if (iconPath.getProtocol().equals("jar")) {                                System.out.println("      Icon: jar:" + iconPath.getFile());                            } else {                                System.out.println("      Icon: " + iconPath.getFile());                            }                        }                        System.out.println("     Model: " + JUMPAppModel.MIDLET.toString());                    }                                        System.out.println("");                }            }        }                System.out.println("");    }        private String getProtocol(String url) {        if (url.endsWith(".jad")) {            return JUMPDownloadModuleFactory.PROTOCOL_MIDP_OTA;        } else if (url.endsWith(".dd")) {            return JUMPDownloadModuleFactory.PROTOCOL_OMA_OTA;        } else {            return null;        }    }            /**     * Install the content described by the specified content descriptor file.     * The content will be automatically downloaded before being installed.     *     * @param descriptorFileUrl A URL to a content desciptor file.     * @return the installed content     */    public JUMPContent[] doInstall(String descriptorFileUrl) {        return doInstall("<no title>", descriptorFileUrl);    }        /**     * Install the content described by the specified content descriptor files.     * The content will be automatically downloaded before being installed.     *     * @param descriptorFileUrl A URL to a content desciptor file.     * @return the installed content     */    public JUMPContent[] doInstall(String descriptorFileUrl[]) {        Vector contentVector = new Vector();        for (int i = 0; i < descriptorFileUrl.length; i++) {            JUMPContent content[] = doInstall("<no title>", descriptorFileUrl[i]);            for (int j = 0; j < content.length; j++)     {                contentVector.add(content[j]);            }        }        return (JUMPContent[])contentVector.toArray(new JUMPContent[]{});    }        /**     * Install content given a list of names and URIs     * to content descriptor files.     * @param downloadNames The title of the content.     * The index of the array for this value     * relates to the same index in teh     * array for downloadURIs.     * @param downloadURIs The URIs to the content descriptor     * files.     *     * The index of the array for this value     * relates to the same index in teh     * array for downloadNames.     * @return the installed content     */    public JUMPContent[] doInstall(String downloadNames[], String downloadURIs[]) {        DownloadTool downloadTool = new DownloadTool();        downloadTool.startTool(downloadNames, downloadURIs);        URL contentURLs[] = downloadTool.getURLs();        JUMPDownloadDescriptor[] descriptors = downloadTool.getDescriptors();        JUMPContent[] content = install(contentURLs, descriptors);        cleanup(contentURLs, descriptors);        return content;    }        /**     * Install content given a name and a URI     * to a content descriptor file.     * @param downloadName The name of the content     * @param downloadURI The URI to the content descriptor file     * @return the installed content     */    public JUMPContent[] doInstall(String downloadName, String downloadURI) {        DownloadTool downloadTool = new DownloadTool();        downloadTool.startTool(downloadName, downloadURI);        URL contentURLs[] = downloadTool.getURLs();        JUMPDownloadDescriptor[] descriptors = downloadTool.getDescriptors();        JUMPContent[] content = install(contentURLs, descriptors);        cleanup(contentURLs, descriptors);        return content;    }        /**     * Given a provisioning server URL, install content     * @param provisioningServerURL The URL to a provisioning server     * @param userInteractive When true, the user chooses an     * application to install among a list     * of available content.     *     * When false, all available content is     * automatically installed.     * @return the installed content     */    public JUMPContent[] doInstall(String provisioningServerURL, boolean userInteractive) {        DownloadTool downloadTool = new DownloadTool(provisioningServerURL);        downloadTool.startTool(userInteractive);        URL contentURLs[] = downloadTool.getURLs();        JUMPDownloadDescriptor[] descriptors = downloadTool.getDescriptors();        JUMPContent[] content = install(contentURLs, descriptors);        cleanup(contentURLs, descriptors);        return content;    }                private void cleanup(URL urls[], JUMPDownloadDescriptor[] descriptors) {        // Remove locally downloaded content, i.e. tmp local jar files        for (int i = 0; i < urls.length; i++) {            File contentFile = new File(urls[i].getFile());            if (contentFile.exists()) {                System.out.println("*** Cleaning up tmp download content: " + contentFile.toString());                contentFile.delete();            }        }        // Remove locally downloaded jad files        for (int i = 0; i < descriptors.length; i++) {            Properties prop = descriptors[i].getApplications()[0];            String localJadFile = prop.getProperty("JUMPApplication_localJadUrl");            if (localJadFile == null) {                continue;            }            File localJad = new File(localJadFile);            if (localJad.exists()) {                System.out.println("*** Cleaning up tmp jad: " + localJad.toString());                localJad.delete();            }        }    }        /**     * Uninstall content given the content type and     * installed application id.     * @param model the content type, i.e.,     *  midlet, xlet, or main     * @param id the installed application id     */    public void doUninstall(JUMPAppModel model, int id) {        JUMPInstallerModule installer = createInstaller(model);        JUMPContent content[] = installer.getInstalled();        int i = 0;        for (i = 0; i < content.length; i++) {            JUMPApplication app = (JUMPApplication)content[i];            if (app.getId() == id) {                break;            }        }        if (i < content.length) {            uninstall((JUMPApplication)content[i]);        }    }        /**     * Uninstall content     * @param app the application to uninstall     */    public void doUninstall(JUMPApplication app) {        uninstall(app);    }        /**     * Uninstall content     * @param apps the content to uninstall     */    public void doUninstall(JUMPApplication apps[]) {        uninstall(apps);    }        /**     * Uninstall content     * @param userInteractive if true, the user chooses an application     * among a list of all installed content     * to uninstall.     *     * if false, all installed content in     * uninstalled.     */    public void doUninstall(boolean userInteractive) {        if (userInteractive) {            userInteractiveUninstall();        } else {            nonInteractiveUninstall();        }    }        private void uninstall(JUMPApplication app) {        JUMPApplication apps[] = new JUMPApplication[1];        apps[0] = app;        uninstall(apps);    }        private void uninstall(JUMPApplication[] apps) {        if (apps == null) {            trace("ERROR: No apps specified to uninstall.");            error();            return;        }                for (int i = 0; i < apps.length; i++) {            System.out.println("");            System.out.println("==> Uninstalling: " + apps[i].getTitle());            if (apps[i] == null) {                System.out.println("ERROR: " + apps[i].getTitle() + " not found in content store.");            } else {                JUMPInstallerModule installer = null;                if (apps[i].getAppType() == JUMPAppModel.XLET) {                    installer = createInstaller(JUMPAppModel.XLET);                } else if (apps[i].getAppType() == JUMPAppModel.MAIN) {                    installer = createInstaller(JUMPAppModel.MAIN);                } else if (apps[i].getAppType() == JUMPAppModel.MIDLET) {                    installer = createInstaller(JUMPAppModel.MIDLET);                }                installer.uninstall(apps[i]);            }            System.out.println("==> Finished Uninstalling: " + apps[i].getTitle());            System.out.println("");        }    }        private void userInteractiveUninstall() {        System.setProperty("jump.installer.interactive", "true");                JUMPInstallerModule installers[] = JUMPInstallerModuleFactory.getInstance().getAllInstallers();                Vector appsVector = new Vector();                // Get all of the apps        for (int i = 0, totalApps = 0; i < installers.length; i++) {            JUMPContent[] content = installers[i].getInstalled();            if (content != null) {                for(int j = 0; j < content.length; j++) {                    appsVector.add(totalApps, content[j]);                    totalApps++;                }            }        }                if (appsVector.size() == 0) {            System.out.println("No applications are installed in the content store.");            return;        }                // Show what is available and read input for a choice.        System.out.println( "uninstall choices: " );        Object apps[] = appsVector.toArray();        for (int i = 0; i < apps.length ; i++ ) {            System.out.println( "(" + i + "): " + ((JUMPApplication)apps[i]).getTitle());        }                String message = "Enter choice (-1 to exit) [-1]: ";        String choice = Utilities.promptUser(message);        int chosenUninstall = Integer.parseInt(choice);                System.out.println( chosenUninstall );                JUMPApplication app = (JUMPApplication)appsVector.get(chosenUninstall);                JUMPApplication[] chosenApps = new JUMPApplication[1];        chosenApps[0] = app;        uninstall(chosenApps);    }        private void nonInteractiveUninstall() {        System.setProperty("jump.installer.interactive", "false");                JUMPInstallerModule installers[] = JUMPInstallerModuleFactory.getInstance().getAllInstallers();                for (int i = 0; i < installers.length; i++) {            JUMPContent[] content = installers[i].getInstalled();            while (content != null && content.length > 0) {                if (content[0] != null) {                    System.out.println("");                    System.out.println("==> Uninstalling: " + ((JUMPApplication)content[0]).getTitle());                    installers[i].uninstall(content[0]);                    System.out.println("==> Finished Uninstalling: " + ((JUMPApplication)content[0]).getTitle());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -