~ubuntu-branches/ubuntu/quantal/netbeans/quantal

« back to all changes in this revision

Viewing changes to autoupdate/services/src/org/netbeans/api/autoupdate/UpdateUnit.java

  • Committer: Bazaar Package Importer
  • Author(s): Marek Slama
  • Date: 2008-01-29 14:11:22 UTC
  • Revision ID: james.westby@ubuntu.com-20080129141122-fnzjbo11ntghxfu7
Tags: upstream-6.0.1
ImportĀ upstreamĀ versionĀ 6.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
3
 *
 
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
 
5
 *
 
6
 * The contents of this file are subject to the terms of either the GNU
 
7
 * General Public License Version 2 only ("GPL") or the Common
 
8
 * Development and Distribution License("CDDL") (collectively, the
 
9
 * "License"). You may not use this file except in compliance with the
 
10
 * License. You can obtain a copy of the License at
 
11
 * http://www.netbeans.org/cddl-gplv2.html
 
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
 
13
 * specific language governing permissions and limitations under the
 
14
 * License.  When distributing the software, include this License Header
 
15
 * Notice in each file and include the License file at
 
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
 
17
 * particular file as subject to the "Classpath" exception as provided
 
18
 * by Sun in the GPL Version 2 section of the License file that
 
19
 * accompanied this code. If applicable, add the following below the
 
20
 * License Header, with the fields enclosed by brackets [] replaced by
 
21
 * your own identifying information:
 
22
 * "Portions Copyrighted [year] [name of copyright owner]"
 
23
 *
 
24
 * Contributor(s):
 
25
 *
 
26
 * The Original Software is NetBeans. The Initial Developer of the Original
 
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
 
28
 * Microsystems, Inc. All Rights Reserved.
 
29
 *
 
30
 * If you wish your version of this file to be governed by only the CDDL
 
31
 * or only the GPL Version 2, indicate your decision by adding
 
32
 * "[Contributor] elects to include this software in this distribution
 
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
 
34
 * single choice of license, a recipient has the option to distribute
 
35
 * your version of this file under either the CDDL, the GPL Version 2 or
 
36
 * to extend the choice of license to its licensees as provided above.
 
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
 
38
 * Version 2 license, then the option applies only if the new code is
 
39
 * made subject to such option by the copyright holder.
 
40
 */
 
41
 
 
42
package org.netbeans.api.autoupdate;
 
43
 
 
44
import java.util.List;
 
45
import org.netbeans.modules.autoupdate.services.Trampoline;
 
46
import org.netbeans.modules.autoupdate.services.UpdateUnitImpl;
 
47
 
 
48
/** Instances provided by the <code>UpdateManager</code> which represents wrapper of
 
49
 * <code>UpdateElement</code>. The one unit contains all available elements of
 
50
 * the same type. For example, Editor module version 1.1 is installed in the IDE; a server with a module
 
51
 * update can contain Editor module version 1.2; and Editor version 1.0 is in
 
52
 * IDE backup.
 
53
 * 
 
54
 * @author Jiri Rechtacek (jrechtacek@netbeans.org)
 
55
 */
 
56
public final class UpdateUnit {
 
57
    static {
 
58
        Trampoline.API = new TrampolineAPI();
 
59
    }
 
60
    
 
61
    final UpdateUnitImpl impl;
 
62
    
 
63
    UpdateUnit (UpdateUnitImpl i) {
 
64
        this.impl = i;
 
65
    }
 
66
 
 
67
    /** Return code name of unit, it's unique among rest of another units.
 
68
     * 
 
69
     * @return code name
 
70
     */
 
71
    public String getCodeName () {
 
72
        return impl.getCodeName();
 
73
    }
 
74
    
 
75
    /** Returns installed <code>UpdateElement</code> if any or null if
 
76
     * no element which unit's code name is already installed.
 
77
     * 
 
78
     * @return installed <code>UpdateElement</code>
 
79
     */
 
80
    public UpdateElement getInstalled () {
 
81
        return impl.getInstalled();
 
82
    }
 
83
    
 
84
    /** Returns list of avaiable element which are not installed in IDE
 
85
     * and has higher version then installed element (is any). These elements
 
86
     * can be installed as new one element or as update of already installed element.
 
87
     * 
 
88
     * @return list of available and not installed <code>UpdateElement</code>
 
89
     */
 
90
    public List<UpdateElement> getAvailableUpdates () {
 
91
        return impl.getAvailableUpdates();
 
92
    }
 
93
    
 
94
    /** Returns <code>UpdateElement</code> in IDE backup if any or null. The element
 
95
     * can found in backup if any another element did update them.
 
96
     * 
 
97
     * @return <code>UpdateElement</code> from backup
 
98
     */
 
99
    public UpdateElement getBackup () {
 
100
        return impl.getBackup();
 
101
    }
 
102
 
 
103
    /** Returns localization <code>UpdateElement</code> active with current <code>Locale</code>
 
104
     * or null.
 
105
     * 
 
106
     * @return localization <code>UpdateElement</code> installed in IDE
 
107
     */
 
108
    public UpdateElement getInstalledLocalization () {
 
109
        return impl.getInstalledLocalization ();
 
110
    }
 
111
    
 
112
    /** Returns list of avaiable localization active with current <code>Locale</code>,
 
113
     * the localization are not installed in IDE and has higher version then
 
114
     * installed localization (is any). These elements can be installed as new one element
 
115
     * or as update of already installed element.
 
116
     * 
 
117
     * @return list of available and not installed localization <code>UpdateElement</code>
 
118
     */
 
119
    public List<UpdateElement> getAvailableLocalizations () {
 
120
        return impl.getAvailableLocalizations ();
 
121
    }
 
122
    
 
123
    public UpdateManager.TYPE getType () {
 
124
        return impl.getType ();
 
125
    }
 
126
    
 
127
    /** Returns if the <code>UpdateUnit</code> is in a pending state.
 
128
     * State of this unit will be changed while restart the application.
 
129
     * 
 
130
     * @return true of UpdateUnit is pending
 
131
     */
 
132
    public boolean isPending () {
 
133
        return impl.isPending ();
 
134
    }
 
135
    
 
136
    @Override
 
137
    public boolean equals(Object obj) {
 
138
        if (obj == null)
 
139
            return false;
 
140
        if (getClass() != obj.getClass())
 
141
            return false;
 
142
        final UpdateUnit other = (UpdateUnit) obj;
 
143
 
 
144
        if (this.impl != other.impl &&
 
145
            (this.impl == null || !this.impl.equals(other.impl)))
 
146
            return false;
 
147
        return true;
 
148
    }
 
149
 
 
150
    @Override
 
151
    public int hashCode() {
 
152
        int hash = 5;
 
153
 
 
154
        hash = 59 * hash + (this.impl != null ? this.impl.hashCode()
 
155
                                              : 0);
 
156
        return hash;
 
157
    }
 
158
 
 
159
    @Override
 
160
    public String toString() {
 
161
        return impl.getCodeName();
 
162
    }
 
163
 
 
164
}