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