View Javadoc

1   package com.atlassian.plugin.webresource;
2   
3   import java.util.Map;
4   
5   /**
6    * Represents a plugin resource that is a subordinate of the super batch.
7    *
8    * This is typically the case for CSS in the superbatch with relative urls to images. For example:
9    * <code>/download/superbatch/css/images/foo.png</code>
10   */
11  public class SuperBatchSubResource extends SuperBatchPluginResource
12  {
13      public SuperBatchSubResource(String resourceName, String type, Map<String, String> params)
14      {
15          super(resourceName, type, params);
16      }
17  
18      public static boolean matches(String path)
19      {
20          return path.indexOf(URL_PREFIX) != -1;
21      }
22  
23      public static SuperBatchSubResource parse(String path, Map<String, String> params)
24      {
25          String type = getType(path);
26          int i = path.indexOf('?');
27          if (i != -1) // remove query parameters
28          {
29              path = path.substring(0, i);
30          }
31          int startIndex = path.indexOf(URL_PREFIX) + URL_PREFIX.length();
32          String resourceName = path.substring(startIndex);
33          return new SuperBatchSubResource(resourceName, type, params);
34      }
35  }