Here you can find the source of normalizeURI(String prefix, String relativePath)
Parameter | Description |
---|---|
prefix | a parameter |
relativePath | a parameter |
public static String normalizeURI(String prefix, String relativePath)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 Olivier Moises//from www. ja v a 2 s. co m * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Olivier Moises- initial API and implementation *******************************************************************************/ public class Main { /** * Returns the (smart) concatenation of the prefix and the relativePath. * * @param prefix * @param relativePath * @return A normalized URI or null */ public static String normalizeURI(String prefix, String relativePath) { if (prefix == null) return relativePath; if (relativePath == null) return prefix; if (relativePath.startsWith(prefix)) //$NON-NLS-1$ return relativePath; if (!relativePath.startsWith("//")) { if (relativePath.startsWith("/")) //$NON-NLS-1$ relativePath = relativePath.substring(1); if (prefix.endsWith("/")) //$NON-NLS-1$ return prefix + relativePath; else if (prefix.startsWith("urn:")) //$NON-NLS-1$ return prefix + relativePath; else return prefix + '/' + relativePath; } return null; } }