JUMPFileInstaller.javaAPI DocphoneME MR2 API (J2ME)6649Wed May 02 18:00:04 BST 2007com.sun.midp.jump.installer


public class JUMPFileInstaller extends JUMPInstaller implements com.sun.midp.jump.installer.JUMPInstallerInterface
An Installer allowing to install a midlet suite from a file. If the midlet suite is given by a descriptor file, the jar URL specified in the descriptor must have a "file" scheme.

Fields Summary
private static final int
Number of bytes to read at one time when copying a file.
Constructors Summary
Methods Summary
protected byte[]downloadJAD()
Downloads an application descriptor file from the given URL.

a byte array representation of the file or null if not found
IOException is thrown if any error prevents the download of the JAD

        RandomAccessStream jadInputStream;
        ByteArrayOutputStream bos = new ByteArrayOutputStream(CHUNK_SIZE);
        String jadFilename = getUrlPath(state.localJadUrl);

        state.beginTransferDataStatus = DOWNLOADING_JAD;
        state.transferStatus = DOWNLOADED_1K_OF_JAD;

        jadInputStream = new RandomAccessStream();
        jadInputStream.connect(jadFilename, Connector.READ);

        transferData(jadInputStream.openInputStream(), bos, CHUNK_SIZE);


        return bos.toByteArray();
protected intdownloadJAR(java.lang.String filename)
Downloads an application archive file from the given URL into the given file. Automatically handle re-tries.

filename name of the file to write. This file resides in the storage area of the given application
size of the JAR
IOException is thrown if any error prevents the download of the JAR

        int jarSize;
        RandomAccessStream jarInputStream, jarOutputStream;
        String jarFilename = getUrlPath(state.localJarUrl);

        // Open source (jar) file
        jarInputStream = new RandomAccessStream();
        jarInputStream.connect(jarFilename, Connector.READ);

        // Open destination (temporary) file
        jarOutputStream = new RandomAccessStream();

        // transfer data
        state.beginTransferDataStatus = DOWNLOADING_JAR;
        state.transferStatus = DOWNLOADED_1K_OF_JAR;

        jarSize = transferData(jarInputStream.openInputStream(),
                               jarOutputStream.openOutputStream(), CHUNK_SIZE);


        return jarSize;
protected booleanisSameUrl(java.lang.String url1, java.lang.String url2)
Compares two URLs for equality in sense that they have the same scheme, host and path.

url1 the first URL for comparision
url2 the second URL for comparision
true if the scheme, host and path of the first given url is identical to the scheme, host and path of the second given url; false otherwise

        try {
            String defaultScheme = "file";
            String scheme1 = getUrlScheme(url1, defaultScheme);
            String scheme2 = getUrlScheme(url2, defaultScheme);

            if (url1.equals(url2)) {
                return true;
        } catch (NullPointerException npe) {
            // no match, fall through

        return true;
public booleanstopInstalling()
Stops the installation. If installer is not installing then this method has no effect. This will cause the install method to throw an IOException if the install is not writing the suite to storage which is the point of no return.

true if the install will stop, false if it is too late

        boolean res = super.stopInstalling();
        if (!res) {
            return res;

        /* some additional actions can be added here */

        return true;
public intverifyAndStoreSuite(java.lang.String jadSourceUrl, java.lang.String encoding, java.lang.String tempJadFileName, java.lang.String tempJarFileName, boolean isUpdate)

           return installJad(jadSourceUrl, tempJadFileName, tempJarFileName,
              encoding, Constants.INTERNAL_STORAGE_ID, isUpdate, false, null);
public intverifyAndStoreSuite(java.lang.String jarSourceUrl, java.lang.String tempJarFileName, java.lang.String suiteName, boolean isUpdate)

           return installJar(jarSourceUrl, tempJarFileName, suiteName,
                   Constants.INTERNAL_STORAGE_ID, isUpdate, false, null);