1 package com.atlassian.plugin.loaders;
2
3 import java.util.HashMap;
4 import java.util.List;
5 import java.util.Map;
6
7 import org.dom4j.Element;
8
9 import com.atlassian.plugin.PluginParseException;
10 import com.atlassian.plugin.Resources;
11 import com.atlassian.plugin.elements.ResourceDescriptor;
12
13 public class LoaderUtils
14 {
15
16
17
18 @Deprecated
19 public static List<ResourceDescriptor> getResourceDescriptors(final Element element) throws PluginParseException
20 {
21 return Resources.fromXml(element).getResourceDescriptors();
22 }
23
24 public static Map<String, String> getParams(final Element element)
25 {
26 @SuppressWarnings("unchecked")
27 final List<Element> elements = element.elements("param");
28
29 final Map<String, String> params = new HashMap<String, String>(elements.size());
30
31 for (final Element paramEl : elements)
32 {
33 final String name = paramEl.attributeValue("name");
34 String value = paramEl.attributeValue("value");
35
36 if ((value == null) && (paramEl.getTextTrim() != null) && !"".equals(paramEl.getTextTrim()))
37 {
38 value = paramEl.getTextTrim();
39 }
40
41 params.put(name, value);
42 }
43
44 return params;
45 }
46 }