~ubuntu-branches/ubuntu/precise/libjcommon-java/precise

« back to all changes in this revision

Viewing changes to source/org/jfree/base/BootableProjectInfo.java

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-10-01 14:12:07 UTC
  • mfrom: (1.1.2 upstream) (4 edgy)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20061001141207-2aipqlhpmn45t3ng
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ========================================================================
 
2
 * JCommon : a free general purpose class library for the Java(tm) platform
 
3
 * ========================================================================
 
4
 *
 
5
 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
 
6
 * 
 
7
 * Project Info:  http://www.jfree.org/jcommon/index.html
 
8
 *
 
9
 * This library is free software; you can redistribute it and/or modify it 
 
10
 * under the terms of the GNU Lesser General Public License as published by 
 
11
 * the Free Software Foundation; either version 2.1 of the License, or 
 
12
 * (at your option) any later version.
 
13
 *
 
14
 * This library is distributed in the hope that it will be useful, but 
 
15
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 
16
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
 
17
 * License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU Lesser General Public
 
20
 * License along with this library; if not, write to the Free Software
 
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
 
22
 * USA.  
 
23
 *
 
24
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
 
25
 * in the United States and other countries.]
 
26
 * 
 
27
 * ------------------------
 
28
 * BootableProjectInfo.java
 
29
 * ------------------------
 
30
 * (C)opyright 2004, by Thomas Morgner and Contributors.
 
31
 *
 
32
 * Original Author:  Thomas Morgner;
 
33
 * Contributor(s):   David Gilbert (for Object Refinery Limited);
 
34
 *
 
35
 * $Id: BootableProjectInfo.java,v 1.4 2006/03/23 19:47:05 taqua Exp $
 
36
 *
 
37
 * Changes
 
38
 * -------
 
39
 * 07-Jun-2004 : Added source headers (DG);
 
40
 *
 
41
 */
 
42
 
 
43
package org.jfree.base;
 
44
 
 
45
import java.util.ArrayList;
 
46
 
 
47
/**
 
48
 * Project info for a bootable project. A bootable project provides a controlled
 
49
 * way of initalizing all subsystems by providing a Boot loader implementation.
 
50
 *
 
51
 * @author Thomas Morgner
 
52
 */
 
53
public class BootableProjectInfo extends BasicProjectInfo {
 
54
 
 
55
    /** The boot class. */
 
56
    private String bootClass;
 
57
 
 
58
    /** The auto-boot flag. */
 
59
    private boolean autoBoot;
 
60
 
 
61
    /**
 
62
     * Creates a new instance.
 
63
     */
 
64
    public BootableProjectInfo() {
 
65
        this.autoBoot = true;
 
66
    }
 
67
 
 
68
    /**
 
69
     * Creates a new library reference.
 
70
     *
 
71
     * @param name    the name.
 
72
     * @param version the version.
 
73
     * @param licence the licence.
 
74
     * @param info    the web address or other info.
 
75
     */
 
76
    public BootableProjectInfo(final String name, final String version,
 
77
                               final String licence, final String info) {
 
78
        this();
 
79
        setName(name);
 
80
        setVersion(version);
 
81
        setLicenceName(licence);
 
82
        setInfo(info);
 
83
    }
 
84
 
 
85
    /**
 
86
     * Creates a new library reference.
 
87
     *
 
88
     * @param name    the name.
 
89
     * @param version the version.
 
90
     * @param info  the info (for example, the project URL).
 
91
     * @param copyright  the copyright statement.
 
92
     * @param licenceName the license name.
 
93
     */
 
94
    public BootableProjectInfo(final String name, final String version, final String info,
 
95
                               final String copyright, final String licenceName) {
 
96
        this();
 
97
        setName(name);
 
98
        setVersion(version);
 
99
        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
}