< prev index next >
src/java.base/share/classes/java/net/URI.java
Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD
@@ -1957,14 +1957,12 @@
//
private static void checkPath(String s, String scheme, String path)
throws URISyntaxException
{
if (scheme != null) {
- if ((path != null)
- && ((path.length() > 0) && (path.charAt(0) != '/')))
- throw new URISyntaxException(s,
- "Relative path in absolute URI");
+ if (path != null && !path.isEmpty() && path.charAt(0) != '/')
+ throw new URISyntaxException(s, "Relative path in absolute URI");
}
}
private void appendAuthority(StringBuilder sb,
String authority,
@@ -2161,11 +2159,11 @@
ru.host = base.host;
ru.userInfo = base.userInfo;
ru.port = base.port;
String cp = (child.path == null) ? "" : child.path;
- if ((cp.length() > 0) && (cp.charAt(0) == '/')) {
+ if (!cp.isEmpty() && cp.charAt(0) == '/') {
// 5.2 (5): Child path is absolute
ru.path = child.path;
} else {
// 5.2 (6): Resolve relative path
ru.path = resolvePath(base.path, cp, base.isAbsolute());
@@ -2185,11 +2183,11 @@
// If the given URI's path is normal then return the URI;
// o.w., return a new URI containing the normalized path.
//
private static URI normalize(URI u) {
- if (u.isOpaque() || (u.path == null) || (u.path.length() == 0))
+ if (u.isOpaque() || u.path == null || u.path.isEmpty())
return u;
String np = normalize(u.path);
if (np == u.path)
return u;
< prev index next >