protected void initialize(CharSequence absoluteUri, String queryString, String contextPath) { ResteasyUriBuilder absoluteBuilder = (ResteasyUriBuilder) ((ResteasyUriBuilder) RuntimeDelegate.getInstance() .createUriBuilder()).uriFromCharSequence((CharSequence)absoluteUri); absolutePath = absoluteBuilder.build(); requestURI = absoluteBuilder.replaceQuery(queryString).build(); encodedPath = PathHelper.getEncodedPathInfo(absolutePath.getRawPath(), contextPath); baseURI = absolutePath; if (!encodedPath.trim().equals("")) { String tmpContextPath = contextPath; if (!tmpContextPath.endsWith("/")) tmpContextPath += "/"; baseURI = absoluteBuilder.clone().replacePath(tmpContextPath).replaceQuery(null).build(); } // // make sure there is no trailing '/' // if (encodedPath.length() > 1 && encodedPath.endsWith("/")) // encodedPath = encodedPath.substring(0, encodedPath.length() - 1); // make sure path starts with '/' if (encodedPath.length() == 0 || encodedPath.charAt(0) != '/') { encodedPath = "/" + encodedPath; } path = UriBuilder.fromPath(encodedPath).build().getPath(); processPath(); }
public static boolean savePathParams(String segmentString, StringBuilder newSegment, List<String> params) { boolean foundParam = false; // Regular expressions can have '{' and '}' characters. Replace them to do match CharSequence segment = PathHelper.replaceEnclosedCurlyBracesCS(segmentString); Matcher matcher = PathHelper.URI_TEMPLATE_PATTERN.matcher(segment); int start = 0; while (matcher.find()) { newSegment.append(segment, start, matcher.start()); foundParam = true; String group = matcher.group(); // Regular expressions can have '{' and '}' characters. Recover earlier replacement params.add(PathHelper.recoverEnclosedCurlyBraces(group)); newSegment.append("_resteasy_uri_parameter"); start = matcher.end(); } newSegment.append(segment, start, segment.length()); return foundParam; }
private void printURIParams(String uri, PrintWriter writer) { String replacedCurlyURI = PathHelper.replaceEnclosedCurlyBraces(uri); Matcher matcher = PathHelper.URI_PARAM_PATTERN.matcher(replacedCurlyURI); int i = 0; while (matcher.find()) { if (matcher.start() > i) { writer.println(" uri += '" + replacedCurlyURI.substring(i, matcher.start()) + "';"); } String name = matcher.group(1); writer.println(" uri += REST.Encoding.encodePathSegment(params." + name + ");"); i = matcher.end(); } if (i < replacedCurlyURI.length()) writer.println(" uri += '" + replacedCurlyURI.substring(i) + "';"); } }
public static Matcher createUriParamMatcher(String string) { Matcher matcher = PathHelper.URI_PARAM_PATTERN.matcher(PathHelper.replaceEnclosedCurlyBracesCS(string)); return matcher; }
private void addToPathParamList(List<String> params, HashSet<String> set, String string) { Matcher matcher = PathHelper.URI_PARAM_PATTERN.matcher(PathHelper.replaceEnclosedCurlyBracesCS(string)); while (matcher.find()) { String param = matcher.group(1); if (set.contains(param)) continue; else { set.add(param); params.add(param); } } }
String path = PathHelper.getEncodedPathInfo(absoluteURI.getRawPath(), contextPath); if (!path.startsWith("/"))
public Expression(final String segment, final String additionalRegex) CharSequence replacedCurlySegment = PathHelper.replaceEnclosedCurlyBracesCS(segment); literalCharacters = PathHelper.URI_PARAM_PATTERN.matcher(replacedCurlySegment).replaceAll("").length(); expr = PathHelper.recoverEnclosedCurlyBraces(expr); buffer.append(expr); numNonDefaultGroups++;
public static Matcher createUriParamMatcher(String string) { Matcher matcher = PathHelper.URI_PARAM_PATTERN.matcher(PathHelper.replaceEnclosedCurlyBracesCS(string)); return matcher; }
private void printURIParams(String uri, PrintWriter writer) { String replacedCurlyURI = PathHelper.replaceEnclosedCurlyBraces(uri); Matcher matcher = PathHelper.URI_PARAM_PATTERN.matcher(replacedCurlyURI); int i = 0; while (matcher.find()) { if (matcher.start() > i) { writer.println(" uri += '" + replacedCurlyURI.substring(i, matcher.start()) + "';"); } String name = matcher.group(1); writer.println(" uri += REST.Encoding.encodePathSegment(params." + name + ");"); i = matcher.end(); } if (i < replacedCurlyURI.length()) writer.println(" uri += '" + replacedCurlyURI.substring(i) + "';"); } }
protected void initialize(String absoluteUri, String queryString, String contextPath) {ResteasyUriBuilder absoluteBuilder = (ResteasyUriBuilder) UriBuilder.fromUri(absoluteUri); absolutePath = absoluteBuilder.build(); requestURI = absoluteBuilder.replaceQuery(queryString).build(); encodedPath = PathHelper.getEncodedPathInfo(absolutePath.getRawPath(), contextPath); baseURI = absolutePath; if (!encodedPath.trim().equals("")) { String tmpContextPath = contextPath; if (!tmpContextPath.endsWith("/")) tmpContextPath += "/"; baseURI = absoluteBuilder.clone().replacePath(tmpContextPath).replaceQuery(null).build(); } // // make sure there is no trailing '/' // if (encodedPath.length() > 1 && encodedPath.endsWith("/")) // encodedPath = encodedPath.substring(0, encodedPath.length() - 1); // make sure path starts with '/' if (encodedPath.length() == 0 || encodedPath.charAt(0) != '/') { encodedPath = "/" + encodedPath; } path = UriBuilder.fromPath(encodedPath).build().getPath(); processPath(); }
boolean foundParam = false; CharSequence pathWithoutEnclosedCurlyBraces = PathHelper.replaceEnclosedCurlyBracesCS(this.path); Matcher matcher = PathHelper.URI_TEMPLATE_PATTERN.matcher(pathWithoutEnclosedCurlyBraces); StringBuilder newSegment = new StringBuilder(); foundParam = true; String group = matcher.group(); pathParams.add(PathHelper.recoverEnclosedCurlyBraces(group)); newSegment.append("_resteasy_uri_parameter"); from = matcher.end();
public static Matcher createUriParamMatcher(String string) { Matcher matcher = PathHelper.URI_PARAM_PATTERN.matcher(PathHelper.replaceEnclosedCurlyBracesCS(string)); return matcher; }
public static ResteasyUriInfo extractUriInfo(HttpRequest request, String contextPath, String protocol) { String host = HttpHeaders.getHost(request, "unknown"); String uri = request.getUri(); URI absoluteURI = URI.create(protocol + "://" + host + uri); String path = PathHelper.getEncodedPathInfo(absoluteURI.getRawPath(), contextPath); if (!path.startsWith("/")) { path = "/" + path; } URI baseURI = absoluteURI; if (!path.trim().equals("")) { String tmpContextPath = contextPath; if (!tmpContextPath.endsWith("/")) tmpContextPath += "/"; baseURI = UriBuilder.fromUri(absoluteURI).replacePath(tmpContextPath).replaceQuery(null).build(); } else { baseURI = UriBuilder.fromUri(absoluteURI).replaceQuery(null).build(); } URI relativeURI = UriBuilder.fromUri(path).replaceQuery(absoluteURI.getRawQuery()).build(); //System.out.println("path: " + path); //System.out.println("query string: " + request.getQueryString()); ResteasyUriInfo uriInfo = new ResteasyUriInfo(baseURI, relativeURI); return uriInfo; }
public static boolean savePathParams(String segmentString, StringBuilder newSegment, List<String> params) { boolean foundParam = false; // Regular expressions can have '{' and '}' characters. Replace them to do match CharSequence segment = PathHelper.replaceEnclosedCurlyBracesCS(segmentString); Matcher matcher = PathHelper.URI_TEMPLATE_PATTERN.matcher(segment); int start = 0; while (matcher.find()) { newSegment.append(segment, start, matcher.start()); foundParam = true; String group = matcher.group(); // Regular expressions can have '{' and '}' characters. Recover earlier replacement params.add(PathHelper.recoverEnclosedCurlyBraces(group)); newSegment.append("_resteasy_uri_parameter"); start = matcher.end(); } newSegment.append(segment, start, segment.length()); return foundParam; }
private void addToPathParamList(List<String> params, HashSet<String> set, String string) { Matcher matcher = PathHelper.URI_PARAM_PATTERN.matcher(PathHelper.replaceEnclosedCurlyBracesCS(string)); while (matcher.find()) { String param = matcher.group(1); if (set.contains(param)) continue; else { set.add(param); params.add(param); } } }
String path = PathHelper.getEncodedPathInfo(absolutePath.getRawPath(), contextPath); List<PathSegment> pathSegments = PathSegmentImpl.parseSegments(path, false);
public static boolean savePathParams(String segmentString, StringBuilder newSegment, List<String> params) { boolean foundParam = false; // Regular expressions can have '{' and '}' characters. Replace them to do match CharSequence segment = PathHelper.replaceEnclosedCurlyBracesCS(segmentString); Matcher matcher = PathHelper.URI_TEMPLATE_PATTERN.matcher(segment); int start = 0; while (matcher.find()) { newSegment.append(segment, start, matcher.start()); foundParam = true; String group = matcher.group(); // Regular expressions can have '{' and '}' characters. Recover earlier replacement params.add(PathHelper.recoverEnclosedCurlyBraces(group)); newSegment.append("_resteasy_uri_parameter"); start = matcher.end(); } newSegment.append(segment, start, segment.length()); return foundParam; }
private void addToPathParamList(List<String> params, HashSet<String> set, String string) { Matcher matcher = PathHelper.URI_PARAM_PATTERN.matcher(PathHelper.replaceEnclosedCurlyBracesCS(string)); while (matcher.find()) { String param = matcher.group(1); if (set.contains(param)) continue; else { set.add(param); params.add(param); } } }
protected void initialize(CharSequence absoluteUri, String queryString, String contextPath) { ResteasyUriBuilder absoluteBuilder = (ResteasyUriBuilder) ((ResteasyUriBuilder) RuntimeDelegate.getInstance() .createUriBuilder()).uriFromCharSequence((CharSequence)absoluteUri); absolutePath = absoluteBuilder.build(); requestURI = absoluteBuilder.replaceQuery(queryString).build(); encodedPath = PathHelper.getEncodedPathInfo(absolutePath.getRawPath(), contextPath); baseURI = absolutePath; if (!encodedPath.trim().equals("")) { String tmpContextPath = contextPath; if (!tmpContextPath.endsWith("/")) tmpContextPath += "/"; baseURI = absoluteBuilder.clone().replacePath(tmpContextPath).replaceQuery(null).build(); } // // make sure there is no trailing '/' // if (encodedPath.length() > 1 && encodedPath.endsWith("/")) // encodedPath = encodedPath.substring(0, encodedPath.length() - 1); // make sure path starts with '/' if (encodedPath.length() == 0 || encodedPath.charAt(0) != '/') { encodedPath = "/" + encodedPath; } path = UriBuilder.fromPath(encodedPath).build().getPath(); processPath(); }
public Expression(String segment, String additionalRegex) CharSequence replacedCurlySegment = PathHelper.replaceEnclosedCurlyBracesCS(segment); literalCharacters = PathHelper.URI_PARAM_PATTERN.matcher(replacedCurlySegment).replaceAll("").length(); expr = PathHelper.recoverEnclosedCurlyBraces(expr); buffer.append(expr); numNonDefaultGroups++;