View Javadoc

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