Polishing

This commit is contained in:
Juergen Hoeller
2020-08-27 15:33:08 +02:00
parent f7440884c9
commit 2891dc6409
21 changed files with 104 additions and 110 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -291,7 +291,7 @@ public class FastByteArrayOutputStream extends OutputStream {
}
/**
* Create a new buffer and store it in the LinkedList
* Create a new buffer and store it in the LinkedList.
* <p>Adds a new buffer that can store at least {@code minCapacity} bytes.
*/
private void addBuffer(int minCapacity) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,7 +76,7 @@ public abstract class StringUtils {
/**
* Check whether the given object (possibly a {@code String}) is empty.
* This is effectly a shortcut for {@code !hasLength(String)}.
* This is effectively a shortcut for {@code !hasLength(String)}.
* <p>This method accepts any Object as an argument, comparing it to
* {@code null} and the empty String. As a consequence, this method
* will never return {@code true} for a non-null non-String object.
@@ -639,6 +639,9 @@ public abstract class StringUtils {
* inner simple dots.
* <p>The result is convenient for path comparison. For other uses,
* notice that Windows separators ("\") are replaced by simple slashes.
* <p><strong>NOTE</strong> that {@code cleanPath} should not be depended
* upon in a security context. Other mechanisms should be used to prevent
* path-traversal issues.
* @param path the original path
* @return the normalized path
*/
@@ -688,18 +691,18 @@ public abstract class StringUtils {
}
else {
// Normal path element found.
pathElements.add(0, element);
pathElements.addFirst(element);
}
}
}
// Remaining top paths need to be retained.
for (int i = 0; i < tops; i++) {
pathElements.add(0, TOP_PATH);
pathElements.addFirst(TOP_PATH);
}
// If nothing else left, at least explicitly point to current path.
if (pathElements.size() == 1 && "".equals(pathElements.getLast()) && !prefix.endsWith(FOLDER_SEPARATOR)) {
pathElements.add(0, CURRENT_PATH);
if (pathElements.size() == 1 && pathElements.getLast().isEmpty() && !prefix.endsWith(FOLDER_SEPARATOR)) {
pathElements.addFirst(CURRENT_PATH);
}
return prefix + collectionToDelimitedString(pathElements, FOLDER_SEPARATOR);
@@ -737,7 +740,7 @@ public abstract class StringUtils {
}
Assert.notNull(charset, "Charset must not be null");
ByteArrayOutputStream bos = new ByteArrayOutputStream(length);
ByteArrayOutputStream baos = new ByteArrayOutputStream(length);
boolean changed = false;
for (int i = 0; i < length; i++) {
int ch = source.charAt(i);
@@ -750,7 +753,7 @@ public abstract class StringUtils {
if (u == -1 || l == -1) {
throw new IllegalArgumentException("Invalid encoded sequence \"" + source.substring(i) + "\"");
}
bos.write((char) ((u << 4) + l));
baos.write((char) ((u << 4) + l));
i += 2;
changed = true;
}
@@ -759,10 +762,10 @@ public abstract class StringUtils {
}
}
else {
bos.write(ch);
baos.write(ch);
}
}
return (changed ? new String(bos.toByteArray(), charset) : source);
return (changed ? new String(baos.toByteArray(), charset) : source);
}
/**
@@ -995,8 +998,8 @@ public abstract class StringUtils {
}
/**
* Trim the elements of the given {@code String} array,
* calling {@code String.trim()} on each of them.
* Trim the elements of the given {@code String} array, calling
* {@code String.trim()} on each non-null element.
* @param array the original {@code String} array (potentially empty)
* @return the resulting array (of the same size) with trimmed elements
*/