public UriBuilder createUriBuilder() { return new ResteasyUriBuilderImpl(); }
/** * Return a unique order list of path params. * * @return list of path parameters */ @Override public List<String> getPathParamNamesInDeclarationOrder() { List<String> params = new ArrayList<String>(); HashSet<String> set = new HashSet<String>(); if (scheme != null) addToPathParamList(params, set, scheme); if (userInfo != null) addToPathParamList(params, set, userInfo); if (host != null) addToPathParamList(params, set, host); if (path != null) addToPathParamList(params, set, path); if (query != null) addToPathParamList(params, set, query); if (fragment != null) addToPathParamList(params, set, fragment); return params; }
@Override public UriBuilder resolveTemplates(Map<String, Object> templateValues, boolean encodeSlashInPath) throws IllegalArgumentException { if (templateValues == null) throw new IllegalArgumentException(Messages.MESSAGES.templateValuesParamNull()); if (templateValues.containsKey(null)) throw new IllegalArgumentException(Messages.MESSAGES.mapKeyNull()); return uriTemplate(buildCharSequence(templateValues, false, true, encodeSlashInPath)); }
/** * Get a new UriBuilder explicitly using RESTEasy implementation * (instead of running UriBuilder.fromUri(uri) which relies on * current registered JAX-RS implementation) * * @param uri * @return */ private static UriBuilder uriBuilderFromUri(URI uri) { return new ResteasyUriBuilderImpl().uri(uri); }
group.indexOf('/') > -1 && group.indexOf(':') < group.indexOf('/')) throw new IllegalArgumentException(Messages.MESSAGES.illegalUriTemplate(uriTemplate)); if (!"".equals(group)) replacePath(group); if (match.group(7) != null) replaceQuery(match.group(7)); if (match.group(9) != null) fragment(match.group(9)); return this;
@Override public String toTemplate() { return buildString(new HashMap<String, Object>(), true, true, true); }
@Override public URI build(Object... values) throws IllegalArgumentException, UriBuilderException { if (values == null) throw new IllegalArgumentException(Messages.MESSAGES.valuesParameterNull()); return buildFromValues(true, false, values); }
@Override public URI buildFromEncodedMap(Map<String, ? extends Object> values) throws IllegalArgumentException, UriBuilderException { if (values == null) throw new IllegalArgumentException(Messages.MESSAGES.valuesParameterNull()); return buildUriFromMap(values, true, false); }
protected StringBuilder replacePathParameter(String name, String value, boolean isEncoded, String string, StringBuilder builder, boolean encodeSlash) { if (string.indexOf('{') == -1) { return builder.append(string); } Matcher matcher = createUriParamMatcher(string); int start = 0; while (matcher.find()) { String param = matcher.group(1); if (!param.equals(name)) continue; builder.append(string, start, matcher.start()); if (!isEncoded) { if (encodeSlash) value = Encode.encodePath(value); else value = Encode.encodePathSegment(value); } else { value = Encode.encodeNonCodes(value); } builder.append(value); start = matcher.end(); } builder.append(string, start, string.length()); return builder; }
private String buildString(Map<String, ? extends Object> paramMap, boolean fromEncodedMap, boolean isTemplate, boolean encodeSlash) { return buildCharSequence(paramMap, fromEncodedMap, isTemplate, encodeSlash).toString(); }
return parseHierarchicalUri(uriTemplate, match);
if (path == null) if (values != null && values.length > 0) return matrixParam(name, values); return this; if (values != null && values.length > 0) matrixParam(name, values);
private static UriBuilder uriBuilderFromUri(String uri) { return new ResteasyUriBuilderImpl().uri(uri); }
group.indexOf('/') > -1 && group.indexOf(':') < group.indexOf('/')) throw new IllegalArgumentException(Messages.MESSAGES.illegalUriTemplate(uriTemplate)); if (!"".equals(group)) replacePath(group); if (match.group(7) != null) replaceQuery(match.group(7)); if (match.group(9) != null) fragment(match.group(9)); return this;
protected URI buildUriFromMap(Map<String, ? extends Object> paramMap, boolean fromEncodedMap, boolean encodeSlash) throws IllegalArgumentException, UriBuilderException { String buf = buildString(paramMap, fromEncodedMap, false, encodeSlash); try { return URI.create(buf); } catch (Exception e) { throw new RuntimeException(Messages.MESSAGES.failedToCreateUri(buf), e); } }
@Override public URI build(Object[] values, boolean encodeSlashInPath) throws IllegalArgumentException, UriBuilderException { if (values == null) throw new IllegalArgumentException(Messages.MESSAGES.valuesParamIsNull()); return buildFromValues(encodeSlashInPath, false, values); }
@Override public URI buildFromMap(Map<String, ?> values, boolean encodeSlashInPath) throws IllegalArgumentException, UriBuilderException { if (values == null) throw new IllegalArgumentException(Messages.MESSAGES.valuesParameterNull()); return buildUriFromMap(values, false, encodeSlashInPath); }
Matcher matcher = createUriParamMatcher(string); int start = 0; while (matcher.find())
private String buildString(Map<String, ? extends Object> paramMap, boolean fromEncodedMap, boolean isTemplate, boolean encodeSlash) { return buildCharSequence(paramMap, fromEncodedMap, isTemplate, encodeSlash).toString(); }
return parseHierarchicalUri(uriTemplate, match);