Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/pathmap/RegexPathSpec.java')
-rw-r--r--jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/pathmap/RegexPathSpec.java157
1 files changed, 6 insertions, 151 deletions
diff --git a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/pathmap/RegexPathSpec.java b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/pathmap/RegexPathSpec.java
index cf5f75809a..a74c4d06a3 100644
--- a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/pathmap/RegexPathSpec.java
+++ b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/pathmap/RegexPathSpec.java
@@ -18,159 +18,14 @@
package org.eclipse.jetty.websocket.server.pathmap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class RegexPathSpec extends PathSpec
+/**
+ * @deprecated moved to jetty-http {@link org.eclipse.jetty.http.pathmap.RegexPathSpec} (this facade will be removed in Jetty 9.4)
+ */
+@Deprecated
+public class RegexPathSpec extends org.eclipse.jetty.http.pathmap.RegexPathSpec
{
- protected Pattern pattern;
-
- protected RegexPathSpec()
- {
- super();
- }
-
public RegexPathSpec(String regex)
{
- super.pathSpec = regex;
- boolean inGrouping = false;
- this.pathDepth = 0;
- this.specLength = pathSpec.length();
- // build up a simple signature we can use to identify the grouping
- StringBuilder signature = new StringBuilder();
- for (char c : pathSpec.toCharArray())
- {
- switch (c)
- {
- case '[':
- inGrouping = true;
- break;
- case ']':
- inGrouping = false;
- signature.append('g'); // glob
- break;
- case '*':
- signature.append('g'); // glob
- break;
- case '/':
- if (!inGrouping)
- {
- this.pathDepth++;
- }
- break;
- default:
- if (!inGrouping)
- {
- if (Character.isLetterOrDigit(c))
- {
- signature.append('l'); // literal (exact)
- }
- }
- break;
- }
- }
- this.pattern = Pattern.compile(pathSpec);
-
- // Figure out the grouping based on the signature
- String sig = signature.toString();
-
- if (Pattern.matches("^l*$",sig))
- {
- this.group = PathSpecGroup.EXACT;
- }
- else if (Pattern.matches("^l*g+",sig))
- {
- this.group = PathSpecGroup.PREFIX_GLOB;
- }
- else if (Pattern.matches("^g+l+$",sig))
- {
- this.group = PathSpecGroup.SUFFIX_GLOB;
- }
- else
- {
- this.group = PathSpecGroup.MIDDLE_GLOB;
- }
- }
-
- public Matcher getMatcher(String path)
- {
- return this.pattern.matcher(path);
- }
-
- @Override
- public String getPathInfo(String path)
- {
- // Path Info only valid for PREFIX_GLOB types
- if (group == PathSpecGroup.PREFIX_GLOB)
- {
- Matcher matcher = getMatcher(path);
- if (matcher.matches())
- {
- if (matcher.groupCount() >= 1)
- {
- String pathInfo = matcher.group(1);
- if ("".equals(pathInfo))
- {
- return "/";
- }
- else
- {
- return pathInfo;
- }
- }
- }
- }
- return null;
- }
-
- @Override
- public String getPathMatch(String path)
- {
- Matcher matcher = getMatcher(path);
- if (matcher.matches())
- {
- if (matcher.groupCount() >= 1)
- {
- int idx = matcher.start(1);
- if (idx > 0)
- {
- if (path.charAt(idx - 1) == '/')
- {
- idx--;
- }
- return path.substring(0,idx);
- }
- }
- return path;
- }
- return null;
- }
-
- public Pattern getPattern()
- {
- return this.pattern;
- }
-
- @Override
- public String getRelativePath(String base, String path)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean matches(final String path)
- {
- int idx = path.indexOf('?');
- if (idx >= 0)
- {
- // match only non-query part
- return getMatcher(path.substring(0,idx)).matches();
- }
- else
- {
- // match entire path
- return getMatcher(path).matches();
- }
+ super(regex);
}
}

Back to the top