001    /* ========================================================================
002     * JCommon : a free general purpose class library for the Java(tm) platform
003     * ========================================================================
004     *
005     * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
006     * 
007     * Project Info:  http://www.jfree.org/jcommon/index.html
008     *
009     * This library is free software; you can redistribute it and/or modify it 
010     * under the terms of the GNU Lesser General Public License as published by 
011     * the Free Software Foundation; either version 2.1 of the License, or 
012     * (at your option) any later version.
013     *
014     * This library is distributed in the hope that it will be useful, but 
015     * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
016     * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
017     * License for more details.
018     *
019     * You should have received a copy of the GNU Lesser General Public
020     * License along with this library; if not, write to the Free Software
021     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
022     * USA.  
023     *
024     * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
025     * in the United States and other countries.]
026     * 
027     * ------------------------
028     * BootableProjectInfo.java
029     * ------------------------
030     * (C)opyright 2004, by Thomas Morgner and Contributors.
031     *
032     * Original Author:  Thomas Morgner;
033     * Contributor(s):   David Gilbert (for Object Refinery Limited);
034     *
035     * $Id: BootableProjectInfo.java,v 1.4 2006/03/23 19:47:05 taqua Exp $
036     *
037     * Changes
038     * -------
039     * 07-Jun-2004 : Added source headers (DG);
040     *
041     */
042    
043    package org.jfree.base;
044    
045    import java.util.ArrayList;
046    
047    /**
048     * Project info for a bootable project. A bootable project provides a controlled
049     * way of initalizing all subsystems by providing a Boot loader implementation.
050     *
051     * @author Thomas Morgner
052     */
053    public class BootableProjectInfo extends BasicProjectInfo {
054    
055        /** The boot class. */
056        private String bootClass;
057    
058        /** The auto-boot flag. */
059        private boolean autoBoot;
060    
061        /**
062         * Creates a new instance.
063         */
064        public BootableProjectInfo() {
065            this.autoBoot = true;
066        }
067    
068        /**
069         * Creates a new library reference.
070         *
071         * @param name    the name.
072         * @param version the version.
073         * @param licence the licence.
074         * @param info    the web address or other info.
075         */
076        public BootableProjectInfo(final String name, final String version,
077                                   final String licence, final String info) {
078            this();
079            setName(name);
080            setVersion(version);
081            setLicenceName(licence);
082            setInfo(info);
083        }
084    
085        /**
086         * Creates a new library reference.
087         *
088         * @param name    the name.
089         * @param version the version.
090         * @param info  the info (for example, the project URL).
091         * @param copyright  the copyright statement.
092         * @param licenceName the license name.
093         */
094        public BootableProjectInfo(final String name, final String version, final String info,
095                                   final String copyright, final String licenceName) {
096            this();
097            setName(name);
098            setVersion(version);
099            setLicenceName(licenceName);
100            setInfo(info);
101            setCopyright(copyright);
102        }
103    
104        /**
105         * Returns the dependencies.
106         * 
107         * @return The dependencies.
108         */
109        public BootableProjectInfo[] getDependencies() {
110            final ArrayList dependencies = new ArrayList();
111            final Library[] libraries = getLibraries();
112            for (int i = 0; i < libraries.length; i++) {
113              Library lib = libraries[i];
114              if (lib instanceof BootableProjectInfo) {
115                  dependencies.add(lib);
116              }
117            }
118    
119            final Library[] optionalLibraries = getOptionalLibraries();
120            for (int i = 0; i < optionalLibraries.length; i++) {
121              Library lib = optionalLibraries[i];
122              if (lib instanceof BootableProjectInfo) {
123                  dependencies.add(lib);
124              }
125            }
126            return (BootableProjectInfo[]) dependencies.toArray
127                (new BootableProjectInfo[dependencies.size()]);
128        }
129    
130        /**
131         * Adds a dependency.
132         * 
133         * @param projectInfo  the project.
134         * @deprecated use 'addLibrary' instead.
135         */
136        public void addDependency(final BootableProjectInfo projectInfo) {
137            if (projectInfo == null) {
138                throw new NullPointerException();
139            }
140            addLibrary(projectInfo);
141        }
142    
143        /**
144         * Returns the name of the boot class.
145         * 
146         * @return The name of the boot class.
147         */
148        public String getBootClass() {
149            return this.bootClass;
150        }
151    
152        /**
153         * Sets the boot class name.
154         * 
155         * @param bootClass  the boot class name.
156         */
157        public void setBootClass(final String bootClass) {
158            this.bootClass = bootClass;
159        }
160    
161        /**
162         * Returns, whether the project should be booted automaticly.
163         * 
164         * @return The auto-boot flag.
165         */
166        public boolean isAutoBoot() {
167            return this.autoBoot;
168        }
169    
170        /**
171         * Sets the auto boot flag.
172         *
173         * @param autoBoot true, if the project should be booted automaticly, false otherwise.
174         */
175        public void setAutoBoot(final boolean autoBoot) {
176            this.autoBoot = autoBoot;
177        }
178    
179    }