2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
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]"
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.
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.
42
package org.netbeans.api.autoupdate;
44
import java.util.List;
45
import org.netbeans.modules.autoupdate.services.Trampoline;
46
import org.netbeans.modules.autoupdate.services.UpdateUnitImpl;
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
54
* @author Jiri Rechtacek (jrechtacek@netbeans.org)
56
public final class UpdateUnit {
58
Trampoline.API = new TrampolineAPI();
61
final UpdateUnitImpl impl;
63
UpdateUnit (UpdateUnitImpl i) {
67
/** Return code name of unit, it's unique among rest of another units.
71
public String getCodeName () {
72
return impl.getCodeName();
75
/** Returns installed <code>UpdateElement</code> if any or null if
76
* no element which unit's code name is already installed.
78
* @return installed <code>UpdateElement</code>
80
public UpdateElement getInstalled () {
81
return impl.getInstalled();
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.
88
* @return list of available and not installed <code>UpdateElement</code>
90
public List<UpdateElement> getAvailableUpdates () {
91
return impl.getAvailableUpdates();
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.
97
* @return <code>UpdateElement</code> from backup
99
public UpdateElement getBackup () {
100
return impl.getBackup();
103
/** Returns localization <code>UpdateElement</code> active with current <code>Locale</code>
106
* @return localization <code>UpdateElement</code> installed in IDE
108
public UpdateElement getInstalledLocalization () {
109
return impl.getInstalledLocalization ();
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.
117
* @return list of available and not installed localization <code>UpdateElement</code>
119
public List<UpdateElement> getAvailableLocalizations () {
120
return impl.getAvailableLocalizations ();
123
public UpdateManager.TYPE getType () {
124
return impl.getType ();
127
/** Returns if the <code>UpdateUnit</code> is in a pending state.
128
* State of this unit will be changed while restart the application.
130
* @return true of UpdateUnit is pending
132
public boolean isPending () {
133
return impl.isPending ();
137
public boolean equals(Object obj) {
140
if (getClass() != obj.getClass())
142
final UpdateUnit other = (UpdateUnit) obj;
144
if (this.impl != other.impl &&
145
(this.impl == null || !this.impl.equals(other.impl)))
151
public int hashCode() {
154
hash = 59 * hash + (this.impl != null ? this.impl.hashCode()
160
public String toString() {
161
return impl.getCodeName();