Polishing
This commit is contained in:
@@ -2,14 +2,14 @@ plugins {
|
||||
id 'io.spring.dependency-management' version '1.0.9.RELEASE' apply false
|
||||
id 'io.spring.ge.conventions' version '0.0.7'
|
||||
id 'io.spring.nohttp' version '0.0.5.RELEASE'
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.3.72' apply false
|
||||
id "io.freefair.aspectj" version '4.1.6' apply false
|
||||
id 'org.jetbrains.dokka' version '0.10.1' apply false
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.3.72' apply false
|
||||
id 'org.asciidoctor.jvm.convert' version '2.4.0'
|
||||
id 'org.asciidoctor.jvm.pdf' version '2.4.0'
|
||||
id 'de.undercouch.download' version '4.1.1'
|
||||
id "io.freefair.aspectj" version '4.1.6' apply false
|
||||
id "com.github.ben-manes.versions" version '0.28.0'
|
||||
id 'com.gradle.build-scan' version '3.2'
|
||||
id 'de.undercouch.download' version '4.1.1'
|
||||
}
|
||||
|
||||
apply from: "$rootDir/gradle/build-scan-user-data.gradle"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -83,17 +83,17 @@ class CaptureTheRestPathElement extends PathElement {
|
||||
}
|
||||
|
||||
private String pathToString(int fromSegment, List<Element> pathElements) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = fromSegment, max = pathElements.size(); i < max; i++) {
|
||||
Element element = pathElements.get(i);
|
||||
if (element instanceof PathSegment) {
|
||||
buf.append(((PathSegment)element).valueToMatch());
|
||||
sb.append(((PathSegment)element).valueToMatch());
|
||||
}
|
||||
else {
|
||||
buf.append(element.value());
|
||||
sb.append(element.value());
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,6 +101,11 @@ class CaptureTheRestPathElement extends PathElement {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getChars() {
|
||||
return ("/{*" + this.variableName + "}").toCharArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWildcardCount() {
|
||||
return 0;
|
||||
@@ -117,8 +122,4 @@ class CaptureTheRestPathElement extends PathElement {
|
||||
return "CaptureTheRest(/{*" + this.variableName + "})";
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getChars() {
|
||||
return ("/{*"+this.variableName+"}").toCharArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -35,7 +35,7 @@ class CaptureVariablePathElement extends PathElement {
|
||||
private final String variableName;
|
||||
|
||||
@Nullable
|
||||
private Pattern constraintPattern;
|
||||
private final Pattern constraintPattern;
|
||||
|
||||
|
||||
/**
|
||||
@@ -55,6 +55,7 @@ class CaptureVariablePathElement extends PathElement {
|
||||
if (colon == -1) {
|
||||
// no constraint
|
||||
this.variableName = new String(captureDescriptor, 1, captureDescriptor.length - 2);
|
||||
this.constraintPattern = null;
|
||||
}
|
||||
else {
|
||||
this.variableName = new String(captureDescriptor, 1, colon - 1);
|
||||
@@ -134,6 +135,18 @@ class CaptureVariablePathElement extends PathElement {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getChars() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('{');
|
||||
sb.append(this.variableName);
|
||||
if (this.constraintPattern != null) {
|
||||
sb.append(':').append(this.constraintPattern.pattern());
|
||||
}
|
||||
sb.append('}');
|
||||
return sb.toString().toCharArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWildcardCount() {
|
||||
return 0;
|
||||
@@ -156,16 +169,4 @@ class CaptureVariablePathElement extends PathElement {
|
||||
(this.constraintPattern != null ? ":" + this.constraintPattern.pattern() : "") + "})";
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getChars() {
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append("{");
|
||||
b.append(this.variableName);
|
||||
if (this.constraintPattern != null) {
|
||||
b.append(":").append(this.constraintPattern.pattern());
|
||||
}
|
||||
b.append("}");
|
||||
return b.toString().toCharArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -26,14 +26,15 @@ import org.springframework.web.util.pattern.PathPattern.MatchingContext;
|
||||
* literal path elements 'foo', 'bar' and 'goo'.
|
||||
*
|
||||
* @author Andy Clement
|
||||
* @since 5.0
|
||||
*/
|
||||
class LiteralPathElement extends PathElement {
|
||||
|
||||
private char[] text;
|
||||
private final char[] text;
|
||||
|
||||
private int len;
|
||||
private final int len;
|
||||
|
||||
private boolean caseSensitive;
|
||||
private final boolean caseSensitive;
|
||||
|
||||
|
||||
public LiteralPathElement(int pos, char[] literalText, boolean caseSensitive, char separator) {
|
||||
@@ -69,7 +70,7 @@ class LiteralPathElement extends PathElement {
|
||||
return false;
|
||||
}
|
||||
|
||||
char[] data = ((PathContainer.PathSegment)element).valueToMatchAsChars();
|
||||
char[] data = ((PathContainer.PathSegment) element).valueToMatchAsChars();
|
||||
if (this.caseSensitive) {
|
||||
for (int i = 0; i < this.len; i++) {
|
||||
if (data[i] != this.text[i]) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -332,18 +332,18 @@ public class PathPattern implements Comparable<PathPattern> {
|
||||
PathContainer resultPath = null;
|
||||
if (multipleAdjacentSeparators) {
|
||||
// Need to rebuild the path without the duplicate adjacent separators
|
||||
StringBuilder buf = new StringBuilder();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int i = startIndex;
|
||||
while (i < endIndex) {
|
||||
Element e = pathElements.get(i++);
|
||||
buf.append(e.value());
|
||||
sb.append(e.value());
|
||||
if (e instanceof Separator) {
|
||||
while (i < endIndex && (pathElements.get(i) instanceof Separator)) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
resultPath = PathContainer.parsePath(buf.toString(), this.pathOptions);
|
||||
resultPath = PathContainer.parsePath(sb.toString(), this.pathOptions);
|
||||
}
|
||||
else if (startIndex >= endIndex) {
|
||||
resultPath = PathContainer.parsePath("");
|
||||
@@ -487,13 +487,13 @@ public class PathPattern implements Comparable<PathPattern> {
|
||||
* @return the string form of the pattern
|
||||
*/
|
||||
String computePatternString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
PathElement pe = this.head;
|
||||
while (pe != null) {
|
||||
buf.append(pe.getChars());
|
||||
sb.append(pe.getChars());
|
||||
pe = pe.next;
|
||||
}
|
||||
return buf.toString();
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -66,14 +66,14 @@ public class PatternParseException extends IllegalArgumentException {
|
||||
* with a pointer to the error position, as well as the error message.
|
||||
*/
|
||||
public String toDetailedString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(this.pattern).append('\n');
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(this.pattern).append('\n');
|
||||
for (int i = 0; i < this.position; i++) {
|
||||
buf.append(' ');
|
||||
sb.append(' ');
|
||||
}
|
||||
buf.append("^\n");
|
||||
buf.append(getMessage());
|
||||
return buf.toString();
|
||||
sb.append("^\n");
|
||||
sb.append(getMessage());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public int getPosition() {
|
||||
|
||||
@@ -136,20 +136,19 @@ class RegexPathElement extends PathElement {
|
||||
if (matches) {
|
||||
if (isNoMorePattern()) {
|
||||
if (matchingContext.determineRemainingPath &&
|
||||
(this.variableNames.isEmpty() || textToMatch.length() > 0)) {
|
||||
(this.variableNames.isEmpty() || textToMatch.length() > 0)) {
|
||||
matchingContext.remainingPathIndex = pathIndex + 1;
|
||||
matches = true;
|
||||
}
|
||||
else {
|
||||
// No more pattern, is there more data?
|
||||
// If pattern is capturing variables there must be some actual data to bind to them
|
||||
matches = (pathIndex + 1) >= matchingContext.pathLength
|
||||
&& (this.variableNames.isEmpty() || textToMatch.length() > 0);
|
||||
matches = (pathIndex + 1 >= matchingContext.pathLength) &&
|
||||
(this.variableNames.isEmpty() || textToMatch.length() > 0);
|
||||
if (!matches && matchingContext.isMatchOptionalTrailingSeparator()) {
|
||||
matches = (this.variableNames.isEmpty()
|
||||
|| textToMatch.length() > 0)
|
||||
&& (pathIndex + 2) >= matchingContext.pathLength
|
||||
&& matchingContext.isSeparator(pathIndex + 1);
|
||||
matches = (this.variableNames.isEmpty() || textToMatch.length() > 0) &&
|
||||
(pathIndex + 2 >= matchingContext.pathLength) &&
|
||||
matchingContext.isSeparator(pathIndex + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,11 +159,11 @@ class RegexPathElement extends PathElement {
|
||||
|
||||
if (matches && matchingContext.extractingVariables) {
|
||||
// Process captures
|
||||
if (this.variableNames.size() != matcher.groupCount()) { // SPR-8455
|
||||
throw new IllegalArgumentException("The number of capturing groups in the pattern segment "
|
||||
+ this.pattern + " does not match the number of URI template variables it defines, "
|
||||
+ "which can occur if capturing groups are used in a URI template regex. "
|
||||
+ "Use non-capturing groups instead.");
|
||||
if (this.variableNames.size() != matcher.groupCount()) { // SPR-8455
|
||||
throw new IllegalArgumentException("The number of capturing groups in the pattern segment " +
|
||||
this.pattern + " does not match the number of URI template variables it defines, " +
|
||||
"which can occur if capturing groups are used in a URI template regex. " +
|
||||
"Use non-capturing groups instead.");
|
||||
}
|
||||
for (int i = 1; i <= matcher.groupCount(); i++) {
|
||||
String name = this.variableNames.get(i - 1);
|
||||
@@ -187,6 +186,11 @@ class RegexPathElement extends PathElement {
|
||||
return (this.regex.length - varsLength - this.variableNames.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getChars() {
|
||||
return this.regex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCaptureCount() {
|
||||
return this.variableNames.size();
|
||||
@@ -208,8 +212,4 @@ class RegexPathElement extends PathElement {
|
||||
return "Regex(" + String.valueOf(this.regex) + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getChars() {
|
||||
return this.regex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -62,14 +62,15 @@ class SeparatorPathElement extends PathElement {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Separator(" + this.separator + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getChars() {
|
||||
return new char[] {this.separator};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Separator(" + this.separator + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -74,7 +74,7 @@ class SingleCharWildcardedPathElement extends PathElement {
|
||||
return false;
|
||||
}
|
||||
|
||||
char[] data = ((PathSegment)element).valueToMatchAsChars();
|
||||
char[] data = ((PathSegment) element).valueToMatchAsChars();
|
||||
if (this.caseSensitive) {
|
||||
for (int i = 0; i < this.len; i++) {
|
||||
char ch = this.text[i];
|
||||
@@ -125,15 +125,15 @@ class SingleCharWildcardedPathElement extends PathElement {
|
||||
return this.len;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getChars() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SingleCharWildcarded(" + String.valueOf(this.text) + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getChars() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -86,6 +86,11 @@ class WildcardPathElement extends PathElement {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getChars() {
|
||||
return new char[] {'*'};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWildcardCount() {
|
||||
return 1;
|
||||
@@ -102,8 +107,4 @@ class WildcardPathElement extends PathElement {
|
||||
return "Wildcard(*)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getChars() {
|
||||
return new char[] {'*'};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -47,6 +47,11 @@ class WildcardTheRestPathElement extends PathElement {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getChars() {
|
||||
return (this.separator + "**").toCharArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWildcardCount() {
|
||||
return 1;
|
||||
@@ -58,8 +63,4 @@ class WildcardTheRestPathElement extends PathElement {
|
||||
return "WildcardTheRest(" + this.separator + "**)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getChars() {
|
||||
return (this.separator+"**").toCharArray();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user