1/*2 * $Id: URLUtil.java 798956 2009-07-29 15:41:10Z apetrelli $3 *4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122package org.apache.tiles.util;
2324import java.net.URL;
25import java.util.ArrayList;
26import java.util.Collection;
27import java.util.List;
2829/***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.034 */35publicfinalclassURLUtil {
3637/***38 * Private constructor to avoid instantiation.39 */40privateURLUtil() { }
4142/***43 * Filters a collection of URLs and removes all that have an underscore in44 * 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 an48 * underscore in their name.49 * @since 2.2.050 */51publicstatic List<URL> getBaseTilesDefinitionURLs(Collection<? extends URL> urlSet) {
52 List<URL> filteredUrls = new ArrayList<URL>();
53for (URL url : urlSet) {
54 String externalForm = url.toExternalForm();
55if (externalForm.indexOf('_', externalForm.lastIndexOf("/")) < 0) {
56 filteredUrls.add(url);
57 }
58 }
59return filteredUrls;
60 }
61 }