View Javadoc

1   package com.atlassian.plugin.elements;
2   
3   import java.util.Map;
4   import java.util.Map.Entry;
5   
6   import com.google.common.base.Predicate;
7   import com.google.common.collect.ImmutableMap;
8   import com.google.common.collect.Maps;
9   
10  /**
11   * This class gives the location of a particular resource
12   */
13  public class ResourceLocation
14  {
15      private final String location;
16      private final String name;
17      private final String type;
18      private final String contentType;
19      private final String content;
20      private final Map<String,String> params;
21  
22      public ResourceLocation(String location, String name, String type, String contentType, String content, Map<String,String> params)
23      {
24          this.location = location;
25          this.name = name;
26          this.type = type;
27          this.contentType = contentType;
28          this.content = content;
29          this.params = ImmutableMap.copyOf(Maps.filterEntries(params, KEY_AND_VALUE_NOT_NULL));
30      }
31  
32      /**
33       * Necessary because {@link com.atlassian.plugin.loaders.LoaderUtils#getParams(org.dom4j.Element)} allows <code>null</code>s through
34       */
35      private static final Predicate<Map.Entry<?, ?>> KEY_AND_VALUE_NOT_NULL = new Predicate<Map.Entry<?, ?>>() {
36          @Override
37          public boolean apply(Entry<?, ?> e)
38          {
39              return e.getKey() != null && e.getValue() != null;
40          }
41      };
42  
43      public String getLocation()
44      {
45          return location;
46      }
47  
48      public String getName()
49      {
50          return name;
51      }
52  
53      public String getType()
54      {
55          return type;
56      }
57  
58      public String getContentType()
59      {
60          return contentType;
61      }
62  
63      public String getContent()
64      {
65          return content;
66      }
67  
68      public String getParameter(String key)
69      {
70          return params.get(key);
71      }
72  
73      public Map<String, String> getParams()
74      {
75          return params;
76      }
77  }