MultivaluedMapImpl createMultivalueMap( String paramName, String paramValue ) { MultivaluedMapImpl queryParams = new MultivaluedMapImpl(); queryParams.add( paramName, UriComponent.encode( paramValue, UriComponent.Type.QUERY_PARAM ) ); return queryParams; }
@Override public List<String> getMatchedURIs(boolean decode) { List<String> result; if (decode) { result = new ArrayList<String>(paths.size()); for (String path : paths) { result.add(UriComponent.decode( path, UriComponent.Type.PATH)); } } else { result = paths; } return Collections.unmodifiableList(result); }
@Override public MultivaluedMap<String, String> getQueryParameters(boolean decode) { if (decode) { if (decodedQueryParameters != null) return decodedQueryParameters; return decodedQueryParameters = UriComponent.decodeQuery( getRequestUri(), true); } else { if (encodedQueryParameters != null) return encodedQueryParameters; return encodedQueryParameters = UriComponent.decodeQuery( getRequestUri(), false); } }
tValue = encode ? UriComponent.encode(tValue.toString(), t) : UriComponent.contextualEncode(tValue.toString(), t); b.append(tValue); } else {
return decode(s, n); return decodeHost(s, n); case QUERY_PARAM: return decodeQueryParam(s, n); default: return decode(s, n);
/** * {@inheritDoc} */ @Override protected String encodeLiteralCharacters(final String literalCharacters) { return UriComponent.contextualEncode( literalCharacters, UriComponent.Type.PATH ); } }
@Override public List<PathSegment> getPathSegments(boolean decode) { if (decode) { if (decodedPathSegments != null) return decodedPathSegments; return decodedPathSegments = UriComponent.decodePath(getPath(false), true); } else { if (encodedPathSegments != null) return encodedPathSegments; return encodedPathSegments = UriComponent.decodePath(getPath(false), false); } }
/** * Encodes the characters of string that are either non-ASCII characters * or are ASCII characters that must be percent-encoded using the * UTF-8 encoding. * * @param s the string to be encoded. * @param t the URI component type identifying the ASCII characters that * must be percent-encoded. * @return the encoded string. */ public static String encode(String s, Type t) { return _encode(s, t, false, false); }
/** * Validates the legal characters of a percent-encoded string that * represents a URI component type. * * @param s the encoded string. * @param t the URI component type identifying the legal characters. * @param template true if the encoded string contains URI template variables * @return true if the encoded string is valid, otherwise false. */ public static boolean valid(String s, Type t, boolean template) { return _valid(s, t, template) == -1; }
tValue = encode ? UriComponent.encode(tValue.toString(), t) : UriComponent.contextualEncode(tValue.toString(), t); b.append(tValue); } else {
return decode(s, n); return decodeHost(s, n); case QUERY_PARAM: return decodeQueryParam(s, n); default: return decode(s, n);
private <T> void encodeKeys(Map<String, T> map) { Map<String, T> tempMap = new HashMap<String, T>(); for(Map.Entry<String, T> entry : map.entrySet()) tempMap.put(UriComponent.contextualEncode(entry.getKey(), UriComponent.Type.PATH_SEGMENT), entry.getValue()); map.clear(); map.putAll(tempMap); }
/** * Decode the path component of a URI as path segments. * * @param u the URI. If the path component is an absolute path component * then the leading '/' is ignored and is not considered a delimiator * of a path segment. * @param decode true if the path segments of the path component * should be in decoded form. * @return the list of path segments. */ public static List<PathSegment> decodePath(URI u, boolean decode) { String rawPath = u.getRawPath(); if (rawPath != null && rawPath.length() > 0 && rawPath.charAt(0) == '/') { rawPath = rawPath.substring(1); } return decodePath(rawPath, decode); }
/** * Encodes the characters of string that are either non-ASCII characters * or are ASCII characters that must be percent-encoded using the * UTF-8 encoding. * * @param s the string to be encoded. * @param t the URI component type identifying the ASCII characters that * must be percent-encoded. * @param template true if the encoded string contains URI template variables * @return the encoded string. */ public static String encode(String s, Type t, boolean template) { return _encode(s, t, template, false); }
/** * Validates the legal characters of a percent-encoded string that * represents a URI component type. * * @param s the encoded string. * @param t the URI component type identifying the legal characters. * @param template true if the encoded string contains URI template variables * @return true if the encoded string is valid, otherwise false. */ public static boolean valid(String s, Type t, boolean template) { return _valid(s, t, template) == -1; }
logDebug( BaseMessages.getString( PKG, "Rest.Log.matrixParameterValue", data.matrixParamNames[i], value ) ); builder = builder.matrixParam( data.matrixParamNames[i], UriComponent.encode( value, UriComponent.Type.QUERY_PARAM ) );
@Override public void pushMatch(UriTemplate template, List<String> names) { matchResults.addFirst(matchResult); templates.addFirst(template); if (encodedTemplateValues == null) { encodedTemplateValues = new MultivaluedMapImpl(); } int i = 1; for (String name : names) { final String value = matchResult.group(i++); encodedTemplateValues.addFirst(name, value); if (decodedTemplateValues != null) { decodedTemplateValues.addFirst( UriComponent.decode(name, UriComponent.Type.PATH_SEGMENT), UriComponent.decode(value, UriComponent.Type.PATH)); } } }
/** * Decode the query component of a URI. * <p> * Query parameter names in the returned map are always decoded. Decoding of query parameter * values can be controlled using the {@code decode} parameter flag. * </p> * * @param q the query component in encoded form. * @param decode {@code true} if the returned query parameter values of the query component * should be in decoded form. * @return the multivalued map of query parameters. */ public static MultivaluedMap<String, String> decodeQuery(String q, boolean decode) { return decodeQuery(q, true, decode); }
/** * {@inheritDoc} */ @Override protected String encodeLiteralCharacters(final String literalCharacters) { return UriComponent.contextualEncode( literalCharacters, UriComponent.Type.PATH ); } }
@Override public List<PathSegment> getPathSegments(boolean decode) { if (decode) { if (decodedPathSegments != null) return decodedPathSegments; return decodedPathSegments = UriComponent.decodePath(getPath(false), true); } else { if (encodedPathSegments != null) return encodedPathSegments; return encodedPathSegments = UriComponent.decodePath(getPath(false), false); } }