This project has retired. For details please refer to its Attic page.
URLUtil xref
View Javadoc

1   /*
2    * $Id: URLUtil.java 798956 2009-07-29 15:41:10Z apetrelli $
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
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  }