/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Utility methods to convert between Path and URIs.
*/
class WindowsUriSupport {
private WindowsUriSupport() {
}
// suffix for IPv6 literal address
/**
* Returns URI to represent the given (absolute) path
*/
if (isUnc) {
// handle IPv6 literal addresses
// 1. drop .ivp6-literal.net
// 2. replace "-" with ":"
}
} else {
uriHost = "";
}
// append slash if known to be directory
if (addSlash)
uriPath += "/";
try {
} catch (URISyntaxException x) {
if (!isUnc)
throw new AssertionError(x);
}
// if we get here it means we've got a UNC with reserved characters
// in the server name. The authority component cannot contain escaped
// octets so fallback to encoding the server name into the URI path
// component.
if (addSlash)
uriPath += "/";
try {
} catch (URISyntaxException x) {
throw new AssertionError(x);
}
}
/**
* Converts given Path to a URI
*/
// trailing slash will be added if file is a directory. Skip check if
// already have trailing space
boolean addSlash = false;
if (!s.endsWith("\\")) {
try {
} catch (WindowsException x) {
}
}
}
/**
* Converts given URI to a Path
*/
if (!uri.isAbsolute())
throw new IllegalArgumentException("URI is not absolute");
throw new IllegalArgumentException("URI is not hierarchical");
throw new IllegalArgumentException("URI scheme is not \"file\"");
throw new IllegalArgumentException("URI has a fragment component");
throw new IllegalArgumentException("URI has a query component");
throw new IllegalArgumentException("URI path component is empty");
// UNC
throw new IllegalArgumentException("URI authority component has undefined host");
throw new IllegalArgumentException("URI authority component has user-info");
throw new IllegalArgumentException("URI authority component has port number");
// IPv6 literal
// 1. drop enclosing brackets
// 2. replace ":" with "-"
// 4. Append .ivp6-literal.net
}
// reconstitute the UNC
} else {
// "/c:/foo" --> "c:/foo"
}
}
}
}