1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.tiles.util;
23
24 import java.net.URL;
25 import java.util.ArrayList;
26 import java.util.Collection;
27 import java.util.List;
28
29 /***
30 * Utilities to manage URLs in the Tiles environment.
31 *
32 * @version $Rev: 798956 $ $Date: 2009-07-29 17:41:10 +0200 (mer, 29 lug 2009) $
33 * @since 2.2.0
34 */
35 public final class URLUtil {
36
37 /***
38 * Private constructor to avoid instantiation.
39 */
40 private URLUtil() { }
41
42 /***
43 * Filters a collection of URLs and removes all that have an underscore in
44 * their name (not in their path).
45 *
46 * @param urlSet The set of URLs to filter.
47 * @return A new list containing only those URLs that does not have an
48 * underscore in their name.
49 * @since 2.2.0
50 */
51 public static List<URL> getBaseTilesDefinitionURLs(Collection<? extends URL> urlSet) {
52 List<URL> filteredUrls = new ArrayList<URL>();
53 for (URL url : urlSet) {
54 String externalForm = url.toExternalForm();
55 if (externalForm.indexOf('_', externalForm.lastIndexOf("/")) < 0) {
56 filteredUrls.add(url);
57 }
58 }
59 return filteredUrls;
60 }
61 }