public class ZolltyPathMatcher extends Object
路径匹配算法 (URL路径、文件路径均可,但必须以'/'分割路径)
单元测试类
构造器和说明 |
---|
ZolltyPathMatcher(String pattern) |
限定符和类型 | 方法和说明 |
---|---|
String |
getPattern() |
boolean |
isMatch(String path)
Match the given
path against the given pattern , test whether it matched. |
static boolean |
isPattern(String pattern)
判断
pattern 是否为通配Pattern格式 |
static boolean |
isTwoPatternSimilar(String pattern1,
String pattern2)
判断两个URL Pattern 是否有包含或重叠。
|
static boolean |
isTwoPatternSimilar(ZolltyPathMatcher pattern1,
ZolltyPathMatcher pattern2)
判断两个URL Pattern 是否有包含或重叠。
|
List<String> |
match(String path)
Match the given
path against the given pattern , return the matched values. |
static boolean |
match(String pattern,
String path)
Match the given
path against the given pattern , test whether it matched. |
String |
toString() |
public ZolltyPathMatcher(String pattern)
pattern
- the pattern to match, such as "/api/*"public boolean isMatch(String path)
path
against the given pattern
, test whether it matched.path
- the path String to test (must split by '/')true
if the supplied path
matchedpublic List<String> match(String path)
path
against the given pattern
, return the matched values.path
- the path String to test (must split by '/')public static boolean isPattern(String pattern)
pattern
是否为通配Pattern格式public static boolean isTwoPatternSimilar(String pattern1, String pattern2)
public static boolean match(String pattern, String path)
path
against the given pattern
, test whether it matched.pattern
- the pattern to match againstpath
- the path String to testtrue
if the supplied path
matched, false
if it didn'tpublic static boolean isTwoPatternSimilar(ZolltyPathMatcher pattern1, ZolltyPathMatcher pattern2)
注意: 当两个Pattern存在交集时,该方法并不能全面检测出URI的重复匹配。
例如:
Pattern1: \a**c\*\*\b Pattern2: \a\*bc\**\b
URI: \a\bc\k\k\b - ALL \acc\k\k\b - 1 \a\bc\k\k\k\b - 2
这种情况很难检测出来。
public String getPattern()
Copyright © 2018 jretty-org. All rights reserved.