Logo Search packages:      
Sourcecode: icedtea-web version File versions  Download package

ExtensionDesc.java

// Copyright (C) 2001-2003 Jon A. Maxwell (JAM)
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


package net.sourceforge.jnlp;

import java.io.*;
import java.net.*;
import java.util.*;

import net.sourceforge.jnlp.runtime.JNLPRuntime;


/**
 * The extension element.
 *
 * @author <a href="mailto:jmaxwell@users.sourceforge.net">Jon A. Maxwell (JAM)</a> - initial author
 * @version $Revision: 1.8 $
 */
00033 public class ExtensionDesc {

    /** the extension name */
00036     private String name;

    /** the required extension version */
00039     private Version version;

    /** the location of the extension JNLP file */
00042     private URL location;

    /** the JNLPFile the extension refers to */
00045     private JNLPFile file;

    /** map from ext-part to local part */
00048     private Map extToPart = new HashMap();

    /** eager ext parts */
00051     private List eagerExtParts = new ArrayList();


    /**
     * Create an extention descriptor.
     *
     * @param name the extension name
     * @param version the required version of the extention JNLPFile
     * @param location the location of the extention JNLP file
     */
00061     public ExtensionDesc(String name, Version version, URL location) {
        this.name = name;
        this.version = version;
        this.location = location;
    }

    /**
     * Adds an extension part to be downloaded when the specified
     * part of the main JNLP file is loaded.  The extension part
     * will be downloaded before the application is launched if the
     * lazy value is false or the part is empty or null.
     *
     * @param extPart the part name in the extension file
     * @param part the part name in the main file
     * @param lazy whether to load the part before launching
     */
00077     protected void addPart(String extPart, String part, boolean lazy) {
        extToPart.put(extPart, part);

        if (!lazy || part == null || part.length() == 0)
            eagerExtParts.add(extPart);
    }

    /**
     * Returns the parts in the extension JNLP file mapped to the
     * part of the main file.
     */
00088     public String[] getExtensionParts(String thisPart) {

        return null;
    }

    /**
     * Returns the name of the extension.
     */
00096     public String getName() {
        return name;
    }

    /**
     * Returns the required version of the extension JNLP file.
     */
00103     public Version getVersion() {
        return version;
    }

    /**
     * Returns the location of the extension JNLP file.
     */
00110     public URL getLocation() {
        return location;
    }

    /**
     * Resolves the extension by creating a JNLPFile from the file
     * specified by the extension's location property.
     *
     * @throws IOException if the extension JNLPFile could not be resolved.
     * @throws ParseException if the extension JNLPFile could not be
     * parsed or was not a component or installer descriptor.
     */
00122     public void resolve() throws ParseException, IOException {
        if (file == null) {
            file = new JNLPFile(location);

            if (JNLPRuntime.isDebug())
                System.out.println("Resolve: "+file.getInformation().getTitle());

            // check for it being an extension descriptor
            if (!file.isComponent() && !file.isInstaller())
                throw new ParseException(JNLPRuntime.getMessage("JInvalidExtensionDescriptor", new Object[] {name, location} ));
        }

    }

    /**
     * Returns a JNLPFile for the extension, or null if the JNLP
     * file has not been resolved.
     */
00140     public JNLPFile getJNLPFile() {
        return file;
    }
}

Generated by  Doxygen 1.6.0   Back to index