1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
// 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 $
*/
public class ExtensionDesc {
/** the extension name */
private String name;
/** the required extension version */
private Version version;
/** the location of the extension JNLP file */
private URL location;
/** the JNLPFile the extension refers to */
private JNLPFile file;
/** map from ext-part to local part */
private Map<String,String> extToPart = new HashMap<String,String>();
/** eager ext parts */
private List<String> eagerExtParts = new ArrayList<String>();
/**
* 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
*/
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
*/
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.
*/
public String[] getExtensionParts(String thisPart) {
return null;
}
/**
* Returns the name of the extension.
*/
public String getName() {
return name;
}
/**
* Returns the required version of the extension JNLP file.
*/
public Version getVersion() {
return version;
}
/**
* Returns the location of the extension JNLP file.
*/
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.
*/
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.
*/
public JNLPFile getJNLPFile() {
return file;
}
}
|