Skip to content

Commit c46b0ae

Browse files
committed
polishing
1 parent 760cab8 commit c46b0ae

File tree

3 files changed

+43
-22
lines changed

3 files changed

+43
-22
lines changed

org.springframework.core/src/main/java/org/springframework/util/AntPatchStringMatcher.java

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1+
/*
2+
* Copyright 2002-2009 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.springframework.util;
218

319
import java.util.Map;
420

521
/**
6-
* Package-protected helper class for {@link AntPathMatcher}. Tests whether or not a string matches against a pattern.
7-
* The pattern may contain special characters:<br> '*' means zero or more characters<br> '?' means one and only one
8-
* character, '{' and '}' indicate a uri template pattern
22+
* Package-protected helper class for {@link AntPathMatcher}.
23+
* Tests whether or not a string matches against a pattern.
24+
*
25+
* <p>The pattern may contain special characters: '*' means zero or more characters;
26+
* '?' means one and only one character; '{' and '}' indicate a URI template pattern.
927
*
1028
* @author Arjen Poutsma
1129
* @since 3.0
@@ -28,29 +46,24 @@ class AntPatchStringMatcher {
2846

2947
private final Map<String, String> uriTemplateVariables;
3048

31-
/** Constructs a new instance of the <code>AntPatchStringMatcher</code>. */
32-
AntPatchStringMatcher(String pattern, String str, Map<String, String> uriTemplateVariables) {
33-
patArr = pattern.toCharArray();
34-
strArr = str.toCharArray();
49+
50+
/**
51+
* Construct a new instance of the <code>AntPatchStringMatcher</code>.
52+
*/
53+
public AntPatchStringMatcher(String pattern, String str, Map<String, String> uriTemplateVariables) {
54+
this.patArr = pattern.toCharArray();
55+
this.strArr = str.toCharArray();
56+
this.patIdxEnd = this.patArr.length - 1;
57+
this.strIdxEnd = this.strArr.length - 1;
3558
this.uriTemplateVariables = uriTemplateVariables;
36-
patIdxEnd = patArr.length - 1;
37-
strIdxEnd = strArr.length - 1;
3859
}
3960

40-
private void addTemplateVariable(int curlyIdxStart, int curlyIdxEnd, int valIdxStart, int valIdxEnd) {
41-
if (uriTemplateVariables != null) {
42-
String varName = new String(patArr, curlyIdxStart + 1, curlyIdxEnd - curlyIdxStart - 1);
43-
String varValue = new String(strArr, valIdxStart, valIdxEnd - valIdxStart + 1);
44-
uriTemplateVariables.put(varName, varValue);
45-
}
46-
}
4761

4862
/**
4963
* Main entry point.
50-
*
5164
* @return <code>true</code> if the string matches against the pattern, or <code>false</code> otherwise.
5265
*/
53-
boolean matchStrings() {
66+
public boolean matchStrings() {
5467
if (shortcutPossible()) {
5568
return doShortcut();
5669
}
@@ -119,6 +132,14 @@ boolean matchStrings() {
119132
return onlyStarsLeft();
120133
}
121134

135+
private void addTemplateVariable(int curlyIdxStart, int curlyIdxEnd, int valIdxStart, int valIdxEnd) {
136+
if (uriTemplateVariables != null) {
137+
String varName = new String(patArr, curlyIdxStart + 1, curlyIdxEnd - curlyIdxStart - 1);
138+
String varValue = new String(strArr, valIdxStart, valIdxEnd - valIdxStart + 1);
139+
uriTemplateVariables.put(varName, varValue);
140+
}
141+
}
142+
122143
private boolean consecutiveStars(int patIdxTmp) {
123144
if (patIdxTmp == patIdxStart + 1 && patArr[patIdxStart] == '*' && patArr[patIdxTmp] == '*') {
124145
// Two stars next to each other, skip the first one.

org.springframework.core/src/main/java/org/springframework/util/CachingMapDecorator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -106,7 +106,7 @@ public CachingMapDecorator(Map<K, V> targetMap) {
106106
*/
107107
@SuppressWarnings("unchecked")
108108
public CachingMapDecorator(Map<K, V> targetMap, boolean synchronize, boolean weak) {
109-
Assert.notNull(targetMap, "Target Map is required");
109+
Assert.notNull(targetMap, "'targetMap' must not be null");
110110
this.targetMap = (Map<K, Object>) (synchronize ? Collections.synchronizedMap(targetMap) : targetMap);
111111
this.synchronize = synchronize;
112112
this.weak = weak;

org.springframework.web.servlet/src/main/java/org/springframework/web/bind/annotation/RequestMethod.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,6 +36,6 @@
3636
*/
3737
public enum RequestMethod {
3838

39-
GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE;
39+
GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE
4040

4141
}

0 commit comments

Comments
 (0)