~ubuntu-branches/ubuntu/natty/icedtea-web/natty-proposed

« back to all changes in this revision

Viewing changes to netx/net/sourceforge/jnlp/ResourcesDesc.java

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-11-24 13:23:28 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101124132328-2xb9z39vxga63vr9
Tags: 1.0~20101124-0ubuntu1
* Update to hg 20101124.
* Fix xulrunner dependencies for natty.
* Build-depend on pkg-config and libgtk2.0-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
    private JNLPFile jnlpFile;
44
44
 
45
45
    /** list of jars, packages, properties, and extensions */
46
 
    private List resources = new ArrayList(); // mixed list makes easier for lookup code
47
 
 
 
46
    private List<Object> resources = new ArrayList<Object>();
 
47
    // mixed list makes easier for lookup code
48
48
 
49
49
    /**
50
50
     * Create a representation of one information section of the
66
66
     * Returns the JVMs.
67
67
     */
68
68
    public JREDesc[] getJREs() {
69
 
        List resources = getResources(JREDesc.class);
70
 
        return (JREDesc[]) resources.toArray( new JREDesc[resources.size()] );
 
69
        List<JREDesc> resources = getResources(JREDesc.class);
 
70
        return resources.toArray( new JREDesc[resources.size()] );
71
71
    }
72
72
 
73
73
    /**
92
92
     * Returns all of the JARs.
93
93
     */
94
94
    public JARDesc[] getJARs() {
95
 
        List resources = getResources(JARDesc.class);
96
 
        return (JARDesc[]) resources.toArray( new JARDesc[resources.size()] );
 
95
        List<JARDesc> resources = getResources(JARDesc.class);
 
96
        return resources.toArray( new JARDesc[resources.size()] );
97
97
    }
98
98
 
99
99
    /**
102
102
     * @param partName the part name, null and "" equivalent
103
103
     */
104
104
    public JARDesc[] getJARs(String partName) {
105
 
        List resources = getResources(JARDesc.class);
 
105
        List<JARDesc> resources = getResources(JARDesc.class);
106
106
 
107
107
        for (int i = resources.size(); i-- > 0;) {
108
 
            JARDesc jar = (JARDesc) resources.get(i);
 
108
            JARDesc jar = resources.get(i);
109
109
 
110
110
            if (!(""+jar.getPart()).equals(""+partName))
111
111
                resources.remove(i);
112
112
        }
113
113
 
114
 
        return (JARDesc[]) resources.toArray( new JARDesc[resources.size()] );
 
114
        return resources.toArray( new JARDesc[resources.size()] );
115
115
    }
116
116
 
117
117
    /**
118
118
     * Returns the Extensions.
119
119
     */
120
120
    public ExtensionDesc[] getExtensions() {
121
 
        List resources = getResources(ExtensionDesc.class);
122
 
        return (ExtensionDesc[]) resources.toArray( new ExtensionDesc[resources.size()] );
 
121
        List<ExtensionDesc> resources = getResources(ExtensionDesc.class);
 
122
        return resources.toArray( new ExtensionDesc[resources.size()] );
123
123
    }
124
124
 
125
125
    /**
126
126
     * Returns the Packages.
127
127
     */
128
128
    public PackageDesc[] getPackages() {
129
 
        List resources = getResources(PackageDesc.class);
130
 
        return (PackageDesc[]) resources.toArray( new PackageDesc[resources.size()] );
 
129
        List<PackageDesc> resources = getResources(PackageDesc.class);
 
130
        return resources.toArray( new PackageDesc[resources.size()] );
131
131
    }
132
132
 
133
133
    /**
137
137
     * @return the PackageDesc objects matching the class name
138
138
     */
139
139
    public PackageDesc[] getPackages(String className) {
140
 
        List resources = getResources(PackageDesc.class);
 
140
        List<PackageDesc> resources = getResources(PackageDesc.class);
141
141
 
142
142
        for (int i = resources.size(); i-- > 0;) {
143
 
            PackageDesc pk = (PackageDesc) resources.get(i);
 
143
            PackageDesc pk = resources.get(i);
144
144
 
145
145
            if (!pk.matches(className))
146
146
                resources.remove(i);
147
147
        }
148
148
 
149
 
        return (PackageDesc[]) resources.toArray( new PackageDesc[resources.size()] );
 
149
        return resources.toArray( new PackageDesc[resources.size()] );
150
150
    }
151
151
 
152
152
    /**
153
153
     * Returns the Properties as a list.
154
154
     */
155
155
    public PropertyDesc[] getProperties() {
156
 
        List resources = getResources(PropertyDesc.class);
157
 
        return (PropertyDesc[]) resources.toArray( new PropertyDesc[resources.size()] );
 
156
        List<PropertyDesc> resources = getResources(PropertyDesc.class);
 
157
        return resources.toArray( new PropertyDesc[resources.size()] );
158
158
    }
159
159
 
160
160
    /**
161
161
     * Returns the properties as a map.
162
162
     */
163
 
    public Map getPropertiesMap() {
164
 
        Properties properties = new Properties();
165
 
        List resources = getResources(PropertyDesc.class);
 
163
    public Map<String,String> getPropertiesMap() {
 
164
        Map<String,String> properties = new HashMap<String,String>();
 
165
        List<PropertyDesc> resources = getResources(PropertyDesc.class);
166
166
        for (int i=0; i < resources.size(); i++) {
167
 
            PropertyDesc prop = (PropertyDesc) resources.get(i);
 
167
            PropertyDesc prop = resources.get(i);
168
168
            properties.put( prop.getKey(), prop.getValue() );
169
169
        }
170
170
 
205
205
    /**
206
206
     * Returns all resources of the specified type.
207
207
     */
208
 
    public List getResources(Class type) {
209
 
        List result = new ArrayList();
 
208
    public <T> List<T> getResources(Class<T> type) {
 
209
        List<T> result = new ArrayList<T>();
210
210
 
211
211
        for (int i=0; i < resources.size(); i++)
212
212
            if ( type.isAssignableFrom(resources.get(i).getClass()) )
213
 
                result.add(resources.get(i));
 
213
                result.add(type.cast(resources.get(i)));
214
214
 
215
215
        return result;
216
216
    }