Java Code Examples for org.springframework.http.server.PathContainer#PathSegment
The following examples show how to use
org.springframework.http.server.PathContainer#PathSegment .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PathPattern.java From spring-analysis-note with MIT License | 5 votes |
/** * Return the decoded value of the specified element. * @param pathIndex path element index * @return the decoded value */ String pathElementValue(int pathIndex) { Element element = (pathIndex < this.pathLength) ? this.pathElements.get(pathIndex) : null; if (element instanceof PathContainer.PathSegment) { return ((PathContainer.PathSegment)element).valueToMatch(); } return ""; }
Example 2
Source File: PathPattern.java From java-technology-stack with MIT License | 5 votes |
/** * Return the decoded value of the specified element. * @param pathIndex path element index * @return the decoded value */ String pathElementValue(int pathIndex) { Element element = (pathIndex < this.pathLength) ? this.pathElements.get(pathIndex) : null; if (element instanceof PathContainer.PathSegment) { return ((PathContainer.PathSegment)element).valueToMatch(); } return ""; }
Example 3
Source File: LiteralPathElement.java From spring-analysis-note with MIT License | 4 votes |
@Override public boolean matches(int pathIndex, MatchingContext matchingContext) { if (pathIndex >= matchingContext.pathLength) { // no more path left to match this element return false; } Element element = matchingContext.pathElements.get(pathIndex); if (!(element instanceof PathContainer.PathSegment)) { return false; } String value = ((PathSegment)element).valueToMatch(); if (value.length() != this.len) { // Not enough data to match this path element return false; } char[] data = ((PathContainer.PathSegment)element).valueToMatchAsChars(); if (this.caseSensitive) { for (int i = 0; i < this.len; i++) { if (data[i] != this.text[i]) { return false; } } } else { for (int i = 0; i < this.len; i++) { // TODO revisit performance if doing a lot of case insensitive matching if (Character.toLowerCase(data[i]) != this.text[i]) { return false; } } } pathIndex++; if (isNoMorePattern()) { if (matchingContext.determineRemainingPath) { matchingContext.remainingPathIndex = pathIndex; return true; } else { if (pathIndex == matchingContext.pathLength) { return true; } else { return (matchingContext.isMatchOptionalTrailingSeparator() && (pathIndex + 1) == matchingContext.pathLength && matchingContext.isSeparator(pathIndex)); } } } else { return (this.next != null && this.next.matches(pathIndex, matchingContext)); } }
Example 4
Source File: WildcardPathElement.java From spring-analysis-note with MIT License | 4 votes |
/** * Matching on a WildcardPathElement is quite straight forward. Scan the * candidate from the candidateIndex onwards for the next separator or the end of the * candidate. */ @Override public boolean matches(int pathIndex, MatchingContext matchingContext) { String segmentData = null; // Assert if it exists it is a segment if (pathIndex < matchingContext.pathLength) { Element element = matchingContext.pathElements.get(pathIndex); if (!(element instanceof PathContainer.PathSegment)) { // Should not match a separator return false; } segmentData = ((PathContainer.PathSegment)element).valueToMatch(); pathIndex++; } if (isNoMorePattern()) { if (matchingContext.determineRemainingPath) { matchingContext.remainingPathIndex = pathIndex; return true; } else { if (pathIndex == matchingContext.pathLength) { // and the path data has run out too return true; } else { return (matchingContext.isMatchOptionalTrailingSeparator() && // if optional slash is on... segmentData != null && segmentData.length() > 0 && // and there is at least one character to match the *... (pathIndex + 1) == matchingContext.pathLength && // and the next path element is the end of the candidate... matchingContext.isSeparator(pathIndex)); // and the final element is a separator } } } else { // Within a path (e.g. /aa/*/bb) there must be at least one character to match the wildcard if (segmentData == null || segmentData.length() == 0) { return false; } return (this.next != null && this.next.matches(pathIndex, matchingContext)); } }
Example 5
Source File: LiteralPathElement.java From java-technology-stack with MIT License | 4 votes |
@Override public boolean matches(int pathIndex, MatchingContext matchingContext) { if (pathIndex >= matchingContext.pathLength) { // no more path left to match this element return false; } Element element = matchingContext.pathElements.get(pathIndex); if (!(element instanceof PathContainer.PathSegment)) { return false; } String value = ((PathSegment)element).valueToMatch(); if (value.length() != this.len) { // Not enough data to match this path element return false; } char[] data = ((PathContainer.PathSegment)element).valueToMatchAsChars(); if (this.caseSensitive) { for (int i = 0; i < this.len; i++) { if (data[i] != this.text[i]) { return false; } } } else { for (int i = 0; i < this.len; i++) { // TODO revisit performance if doing a lot of case insensitive matching if (Character.toLowerCase(data[i]) != this.text[i]) { return false; } } } pathIndex++; if (isNoMorePattern()) { if (matchingContext.determineRemainingPath) { matchingContext.remainingPathIndex = pathIndex; return true; } else { if (pathIndex == matchingContext.pathLength) { return true; } else { return (matchingContext.isMatchOptionalTrailingSeparator() && (pathIndex + 1) == matchingContext.pathLength && matchingContext.isSeparator(pathIndex)); } } } else { return (this.next != null && this.next.matches(pathIndex, matchingContext)); } }
Example 6
Source File: WildcardPathElement.java From java-technology-stack with MIT License | 4 votes |
/** * Matching on a WildcardPathElement is quite straight forward. Scan the * candidate from the candidateIndex onwards for the next separator or the end of the * candidate. */ @Override public boolean matches(int pathIndex, MatchingContext matchingContext) { String segmentData = null; // Assert if it exists it is a segment if (pathIndex < matchingContext.pathLength) { Element element = matchingContext.pathElements.get(pathIndex); if (!(element instanceof PathContainer.PathSegment)) { // Should not match a separator return false; } segmentData = ((PathContainer.PathSegment)element).valueToMatch(); pathIndex++; } if (isNoMorePattern()) { if (matchingContext.determineRemainingPath) { matchingContext.remainingPathIndex = pathIndex; return true; } else { if (pathIndex == matchingContext.pathLength) { // and the path data has run out too return true; } else { return (matchingContext.isMatchOptionalTrailingSeparator() && // if optional slash is on... segmentData != null && segmentData.length() > 0 && // and there is at least one character to match the *... (pathIndex + 1) == matchingContext.pathLength && // and the next path element is the end of the candidate... matchingContext.isSeparator(pathIndex)); // and the final element is a separator } } } else { // Within a path (e.g. /aa/*/bb) there must be at least one character to match the wildcard if (segmentData == null || segmentData.length() == 0) { return false; } return (this.next != null && this.next.matches(pathIndex, matchingContext)); } }