com.yandex.money.api.utils.UrlEncodedUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ym-java-epr-sdk Show documentation
Show all versions of ym-java-epr-sdk Show documentation
This Java library contains classes that allows you to do payments using Yandex.Money public API.
The newest version!
package com.yandex.money.api.utils;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* Helps to deal with urls.
*
* @author Slava Yasevich ([email protected])
*/
public class UrlEncodedUtils {
/**
* Parses url to key-value pairs of its parameters.
*
* @param url url
* @return key-value pairs
*/
public static Map parse(String url) throws URISyntaxException {
if (Strings.isNullOrEmpty(url)) {
throw new IllegalArgumentException("redirectUrl is null or empty");
}
URI uri = new URI(url);
String query = uri.getQuery();
if (query == null) {
return Collections.unmodifiableMap(new HashMap());
}
Map map = new HashMap<>();
String[] params = query.split("&");
for (String param : params) {
String[] keyValue = param.split("=");
if (keyValue.length == 2) {
map.put(keyValue[0], keyValue[1]);
}
}
return Collections.unmodifiableMap(map);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy