com.sola.instagram.util.UriConstructor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of instagram-java Show documentation
Show all versions of instagram-java Show documentation
Java wrapper for Instagram API v1.
package com.sola.instagram.util;
import java.util.HashMap;
import java.util.Map;
public class UriConstructor {
String accessToken;
public UriConstructor() {
super();
}
public UriConstructor(String accessToken) {
super();
setAccessToken(accessToken);
}
private String getAccessToken() {
return accessToken;
}
private void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
public String constructUri(String uri, HashMap map, boolean addAccessToken) {
try{
for (Map.Entry arg : map.entrySet()) {
uri = uri.replaceAll("\\{"+arg.getKey()+"\\}", arg.getValue().toString());
}
}
catch(NullPointerException e) {}
if(addAccessToken) {
uri += "?access_token=" + getAccessToken();
}
return uri;
}
}