| Class | Line # | Actions | |||||
|---|---|---|---|---|---|---|---|
| RelativeExtendedURL | 36 | 4 | 0% | 4 | 4 |
| 1 | /* | |
| 2 | * See the NOTICE file distributed with this work for additional | |
| 3 | * information regarding copyright ownership. | |
| 4 | * | |
| 5 | * This is free software; you can redistribute it and/or modify it | |
| 6 | * under the terms of the GNU Lesser General Public License as | |
| 7 | * published by the Free Software Foundation; either version 2.1 of | |
| 8 | * the License, or (at your option) any later version. | |
| 9 | * | |
| 10 | * This software is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | * Lesser General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU Lesser General Public | |
| 16 | * License along with this software; if not, write to the Free | |
| 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
| 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
| 19 | */ | |
| 20 | package org.xwiki.url.internal; | |
| 21 | ||
| 22 | import java.net.URL; | |
| 23 | import java.util.List; | |
| 24 | import java.util.Map; | |
| 25 | ||
| 26 | import org.apache.commons.lang3.StringUtils; | |
| 27 | import org.xwiki.resource.CreateResourceReferenceException; | |
| 28 | import org.xwiki.url.ExtendedURL; | |
| 29 | ||
| 30 | /** | |
| 31 | * Ensures Serialized URL are relative (i.e. without leading "/"). | |
| 32 | * | |
| 33 | * @version $Id: 7caed7aba4c196e627c97491e1195796fe3f4a29 $ | |
| 34 | * @since 7.2M1 | |
| 35 | */ | |
| 36 | public class RelativeExtendedURL extends ExtendedURL | |
| 37 | { | |
| 38 | /** | |
| 39 | * Populate the Extended URL with a list of path segments. | |
| 40 | * | |
| 41 | * @param segments the path segments of the URL | |
| 42 | */ | |
| 43 | 3 | public RelativeExtendedURL(List<String> segments) |
| 44 | { | |
| 45 | 3 | super(segments); |
| 46 | } | |
| 47 | ||
| 48 | /** | |
| 49 | * Populate the Extended URL with a list of path segments. | |
| 50 | * | |
| 51 | * @param segments the path segments of the URL | |
| 52 | * @param parameters the query string parameters of the URL | |
| 53 | */ | |
| 54 | 0 | public RelativeExtendedURL(List<String> segments, Map<String, List<String>> parameters) |
| 55 | { | |
| 56 | 0 | super(segments, parameters); |
| 57 | } | |
| 58 | ||
| 59 | /** | |
| 60 | * @param url the URL being wrapped | |
| 61 | * @param ignorePrefix the ignore prefix must start with "/" (eg "/xwiki"). It can be empty or null too in which | |
| 62 | * case it's not used | |
| 63 | * @throws org.xwiki.resource.CreateResourceReferenceException if the passed URL is invalid which can happen if it | |
| 64 | * has incorrect encoding | |
| 65 | */ | |
| 66 | 0 | public RelativeExtendedURL(URL url, String ignorePrefix) throws CreateResourceReferenceException |
| 67 | { | |
| 68 | 0 | super(url, ignorePrefix); |
| 69 | } | |
| 70 | ||
| 71 | 3 | @Override |
| 72 | public String serialize() | |
| 73 | { | |
| 74 | // Make sure the serialized URL is relative | |
| 75 | 3 | return StringUtils.stripStart(super.serialize(), "/"); |
| 76 | } | |
| 77 | } |