Polishing

This commit is contained in:
Juergen Hoeller
2017-04-12 18:07:14 +02:00
parent a55a0f26cb
commit 9e55e8f8a6
2 changed files with 8 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@@ -168,11 +168,11 @@ public abstract class ScriptUtils {
String blockCommentStartDelimiter, String blockCommentEndDelimiter, List<String> statements)
throws ScriptException {
Assert.hasText(script, "script must not be null or empty");
Assert.notNull(separator, "separator must not be null");
Assert.hasText(commentPrefix, "commentPrefix must not be null or empty");
Assert.hasText(blockCommentStartDelimiter, "blockCommentStartDelimiter must not be null or empty");
Assert.hasText(blockCommentEndDelimiter, "blockCommentEndDelimiter must not be null or empty");
Assert.hasText(script, "'script' must not be null or empty");
Assert.notNull(separator, "'separator' must not be null");
Assert.hasText(commentPrefix, "'commentPrefix' must not be null or empty");
Assert.hasText(blockCommentStartDelimiter, "'blockCommentStartDelimiter' must not be null or empty");
Assert.hasText(blockCommentEndDelimiter, "'blockCommentEndDelimiter' must not be null or empty");
StringBuilder sb = new StringBuilder();
boolean inSingleQuote = false;

View File

@@ -43,11 +43,8 @@ public class MediaTypeFactory {
private static final String MIME_TYPES_FILE_NAME = "/org/springframework/http/mime.types";
private static final MultiValueMap<String, MediaType> fileExtensionToMediaTypes;
private static final MultiValueMap<String, MediaType> fileExtensionToMediaTypes = parseMimeTypes();
static {
fileExtensionToMediaTypes = parseMimeTypes();
}
/**
* Parse the {@code mime.types} file found in the resources. Format is:
@@ -65,9 +62,7 @@ public class MediaTypeFactory {
InputStream is = null;
try {
is = MediaTypeFactory.class.getResourceAsStream(MIME_TYPES_FILE_NAME);
BufferedReader reader =
new BufferedReader(new InputStreamReader(is, StandardCharsets.US_ASCII));
BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.US_ASCII));
MultiValueMap<String, MediaType> result = new LinkedMultiValueMap<>();
String line;
while ((line = reader.readLine()) != null) {
@@ -76,7 +71,6 @@ public class MediaTypeFactory {
}
String[] tokens = StringUtils.tokenizeToStringArray(line, " \t\n\r\f");
MediaType mediaType = MediaType.parseMediaType(tokens[0]);
for (int i = 1; i < tokens.length; i++) {
String fileExtension = tokens[i].toLowerCase(Locale.ENGLISH);
result.add(fileExtension, mediaType);