installstateimpl.java

来自「This is a resource based on j2me embedde」· Java 代码 · 共 584 行 · 第 1/2 页

JAVA
584
字号
/* * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER *  * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. *  * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). *  * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA *  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. */package com.sun.midp.jump.installer;import com.sun.midp.security.SecurityHandler;import com.sun.midp.security.SecurityToken;import com.sun.midp.security.Permissions;import com.sun.midp.midlet.MIDletSuite;import com.sun.midp.midletsuite.MIDletSuiteStorage;import com.sun.midp.midletsuite.MIDletSuiteImpl;import com.sun.midp.midletsuite.MIDletInfo;import com.sun.midp.midletsuite.MIDletSuiteInfo;import com.sun.midp.midletsuite.InstallInfo;import com.sun.midp.midletsuite.SuiteSettings;import com.sun.midp.midletsuite.MIDletSuiteLockedException;import com.sun.midp.midletsuite.MIDletSuiteCorruptedException;import com.sun.midp.io.j2me.storage.RandomAccessStream;import com.sun.midp.io.j2me.storage.File;//import com.sun.midp.content.CHManager;import com.sun.midp.installer.InvalidJadException;import com.sun.midp.installer.ManifestProperties;import com.sun.midp.installer.VerifierImpl;import com.sun.midp.installer.InstallListener;import com.sun.midp.installer.InstallState;import com.sun.midp.installer.JadProperties;/** * Holds the state of an installation, so it can restarted after it has * been stopped. */public class InstallStateImpl implements InstallState, MIDletSuite {    /** Location for the downloaded JAD, could be null */    public String localJadUrl;    /** Location for the downloaded JAR */    public String localJarUrl;    /** Contains the data obtained during the installation process */    public InstallInfo installInfo;    /** Contains the data obtained during the installation process */    public SuiteSettings suiteSettings;    /** ID of the storage where the new midlet suite will be installed. */    public int storageId;    /** Receives warnings and status. */    public InstallListener listener;    /** When the install started, in milliseconds. */    public long startTime;    /** What to do next. */    public int nextStep;    /** Signals the installation to stop. */    public boolean stopInstallation;    /**     * Signals that installation is at a point where cancel     * requests are ignored     */    public boolean ignoreCancel;    /** exception that stopped the installation. */    public InvalidJadException exception;    /**     * Option to force an overwrite of existing components without     * any version comparison.     */    public boolean force;    /**     * Option to force the RMS data of the suite to be overwritten to     * be removed without comparison to the new suite.     */    public boolean removeRMS;    /** Raw JAD. */    public byte[] jad;    /** character encoding of the JAD. */    public String jadEncoding;    /** Parsed JAD. */    public JadProperties jadProps;    /** Parsed manifest. */    public ManifestProperties jarProps;    /** Cached File object. */    public File file;    /** User name for authentication. */    protected String username;    /** Password for authentication. */    protected String password;    /** User name for proxyAuthentication. */    public String proxyUsername;    /** Password for proxy authentication. */    public String proxyPassword;    /** Status to signal the beginning of the data transfer. */    public int beginTransferDataStatus;    /** Status for the data transfer method to give to the listener. */    public int transferStatus;    /** Security Handler. */    public SecurityHandler securityHandler;    /** Holds the unzipped JAR manifest to be saved. */    public byte[] manifest;    /** Cache of storage object. */    public RandomAccessStream storage;    /** Cache of MIDlet suite storage object. */    public MIDletSuiteStorage midletSuiteStorage;    /** The root of all MIDP persistent system data. */    public String storageRoot;    /** Signals that previous version exists. */    public boolean isPreviousVersion;    /** Previous MIDlet suite info. */    public MIDletSuiteImpl previousSuite;    /** Previous MIDlet suite install info. */    public InstallInfo previousInstallInfo;    /** The ContentHandler installer state. */    // public CHManager chmanager;    /** Constructor. */    public InstallStateImpl() {        installInfo   = new InstallInfo(UNUSED_SUITE_ID);        suiteSettings = new SuiteSettings(UNUSED_SUITE_ID);    }    /**     * Gets the last recoverable exception that stopped the install.     * Non-recoverable exceptions are thrown and not saved in the state.     *     * @return last exception that stopped the install     */    public InvalidJadException getLastException() {        return exception;    }    /**     * Gets the unique ID that the installed suite was stored with.     *     * @return storage name that can be used to load the suite     */    public int getID() {        return installInfo.id;    }    /**     * Sets the username to be used for HTTP authentication.     *     * @param theUsername 8 bit username, cannot contain a ":"     */    public void setUsername(String theUsername) {        username = theUsername;    }    /**     * Sets the password to be used for HTTP authentication.     *     * @param thePassword 8 bit password     */    public void setPassword(String thePassword) {        password = thePassword;    }    /**     * Sets the username to be used for HTTP proxy authentication.     *     * @param theUsername 8 bit username, cannot contain a ":"     */    public void setProxyUsername(String theUsername) {        proxyUsername = theUsername;    }    /**     * Sets the password to be used for HTTP proxy authentication.     *     * @param thePassword 8 bit password     */    public void setProxyPassword(String thePassword) {        proxyPassword = thePassword;    }    /**     * Gets a property of the application to be installed.     * First from the jaD, then if not found, the JAR manifeSt.     *     * @param key key of the property     *     * @return value of the property or null if not found     */    public String getAppProperty(String key) {        String value;        if (jadProps != null) {            value = jadProps.getProperty(key);            if (value != null) {                return value;            }        }        if (jarProps != null) {            value = jarProps.getProperty(key);            if (value != null) {                return value;            }        }        return null;    }    /**     * Gets the URL of the JAR.     *     * @return URL of the JAR     */    public String getJarUrl() {        return installInfo.jarUrl;    }    /**     * Gets the label for the downloaded JAR.     *     * @return suite name     */    public String getSuiteName() {        return installInfo.suiteName;    }    /**     * Gets the expected size of the JAR.     *     * @return size of the JAR in K bytes rounded up     */    public int getJarSize() {        return (installInfo.expectedJarSize + 1023) / 1024;    }    /**     * Gets the authorization path of this suite. The path starts with     * the most trusted CA that authorized this suite.     *     * @return array of CA names or null if the suite was not signed     */    public String[] getAuthPath() {        /*         * The auth path returned is no a copy because this object is

⌨️ 快捷键说明

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