Removed reliance on MovieDb object from ApiBuilder

master
Stuart Boston 13 years ago
parent 7d9552a08c
commit 9f135c3ca7

File diff suppressed because it is too large Load Diff

@ -1,354 +1,355 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Movie Bean * Movie Bean
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class MovieDb implements Serializable { public class MovieDb implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/* /*
* Logger * Logger
*/ */
private static final Logger LOG = LoggerFactory.getLogger(MovieDb.class); private static final Logger LOG = LoggerFactory.getLogger(MovieDb.class);
/* /*
* Properties * Properties
*/ */
@JsonProperty("backdrop_path") @JsonProperty("backdrop_path")
private String backdropPath; private String backdropPath;
@JsonProperty("id") @JsonProperty("id")
private int id; private int id;
@JsonProperty("original_title") @JsonProperty("original_title")
private String originalTitle; private String originalTitle;
@JsonProperty("popularity") @JsonProperty("popularity")
private float popularity; private float popularity;
@JsonProperty("poster_path") @JsonProperty("poster_path")
private String posterPath; private String posterPath;
@JsonProperty("release_date") @JsonProperty("release_date")
private String releaseDate; private String releaseDate;
@JsonProperty("title") @JsonProperty("title")
private String title; private String title;
@JsonProperty("adult") @JsonProperty("adult")
private boolean adult; private boolean adult;
@JsonProperty("belongs_to_collection") @JsonProperty("belongs_to_collection")
private Collection belongsToCollection; private Collection belongsToCollection;
@JsonProperty("budget") @JsonProperty("budget")
private long budget; private long budget;
@JsonProperty("genres") @JsonProperty("genres")
private List<Genre> genres; private List<Genre> genres;
@JsonProperty("homepage") @JsonProperty("homepage")
private String homepage; private String homepage;
@JsonProperty("imdb_id") @JsonProperty("imdb_id")
private String imdbID; private String imdbID;
@JsonProperty("overview") @JsonProperty("overview")
private String overview; private String overview;
@JsonProperty("production_companies") @JsonProperty("production_companies")
private List<ProductionCompany> productionCompanies; private List<ProductionCompany> productionCompanies;
@JsonProperty("production_countries") @JsonProperty("production_countries")
private List<ProductionCountry> productionCountries; private List<ProductionCountry> productionCountries;
@JsonProperty("revenue") @JsonProperty("revenue")
private long revenue; private long revenue;
@JsonProperty("runtime") @JsonProperty("runtime")
private int runtime; private int runtime;
@JsonProperty("spoken_languages") @JsonProperty("spoken_languages")
private List<Language> spokenLanguages; private List<Language> spokenLanguages;
@JsonProperty("tagline") @JsonProperty("tagline")
private String tagline; private String tagline;
@JsonProperty("vote_average") @JsonProperty("vote_average")
private float voteAverage; private float voteAverage;
@JsonProperty("vote_count") @JsonProperty("vote_count")
private int voteCount; private int voteCount;
@JsonProperty("status") @JsonProperty("status")
private String status; private String status;
// <editor-fold defaultstate="collapsed" desc="Getter methods"> // <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getBackdropPath() { public String getBackdropPath() {
return backdropPath; return backdropPath;
} }
public int getId() { public int getId() {
return id; return id;
} }
public String getOriginalTitle() { public String getOriginalTitle() {
return originalTitle; return originalTitle;
} }
public float getPopularity() { public float getPopularity() {
return popularity; return popularity;
} }
public String getPosterPath() { public String getPosterPath() {
return posterPath; return posterPath;
} }
public String getReleaseDate() { public String getReleaseDate() {
return releaseDate; return releaseDate;
} }
public String getTitle() { public String getTitle() {
return title; return title;
} }
public boolean isAdult() { public boolean isAdult() {
return adult; return adult;
} }
public Collection getBelongsToCollection() { public Collection getBelongsToCollection() {
return belongsToCollection; return belongsToCollection;
} }
public long getBudget() { public long getBudget() {
return budget; return budget;
} }
public List<Genre> getGenres() { public List<Genre> getGenres() {
return genres; return genres;
} }
public String getHomepage() { public String getHomepage() {
return homepage; return homepage;
} }
public String getImdbID() { public String getImdbID() {
return imdbID; return imdbID;
} }
public String getOverview() { public String getOverview() {
return overview; return overview;
} }
public List<ProductionCompany> getProductionCompanies() { public List<ProductionCompany> getProductionCompanies() {
return productionCompanies; return productionCompanies;
} }
public List<ProductionCountry> getProductionCountries() { public List<ProductionCountry> getProductionCountries() {
return productionCountries; return productionCountries;
} }
public long getRevenue() { public long getRevenue() {
return revenue; return revenue;
} }
public int getRuntime() { public int getRuntime() {
return runtime; return runtime;
} }
public List<Language> getSpokenLanguages() { public List<Language> getSpokenLanguages() {
return spokenLanguages; return spokenLanguages;
} }
public String getTagline() { public String getTagline() {
return tagline; return tagline;
} }
public float getVoteAverage() { public float getVoteAverage() {
return voteAverage; return voteAverage;
} }
public int getVoteCount() { public int getVoteCount() {
return voteCount; return voteCount;
} }
public String getStatus() { public String getStatus() {
return status; return status;
} }
// </editor-fold> // </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods"> // <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setBackdropPath(String backdropPath) { public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath; this.backdropPath = backdropPath;
} }
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
public void setOriginalTitle(String originalTitle) { public void setOriginalTitle(String originalTitle) {
this.originalTitle = originalTitle; this.originalTitle = originalTitle;
} }
public void setPopularity(float popularity) { public void setPopularity(float popularity) {
this.popularity = popularity; this.popularity = popularity;
} }
public void setPosterPath(String posterPath) { public void setPosterPath(String posterPath) {
this.posterPath = posterPath; this.posterPath = posterPath;
} }
public void setReleaseDate(String releaseDate) { public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate; this.releaseDate = releaseDate;
} }
public void setTitle(String title) { public void setTitle(String title) {
this.title = title; this.title = title;
} }
public void setAdult(boolean adult) { public void setAdult(boolean adult) {
this.adult = adult; this.adult = adult;
} }
public void setBelongsToCollection(Collection belongsToCollection) { public void setBelongsToCollection(Collection belongsToCollection) {
this.belongsToCollection = belongsToCollection; this.belongsToCollection = belongsToCollection;
} }
public void setBudget(long budget) { public void setBudget(long budget) {
this.budget = budget; this.budget = budget;
} }
public void setGenres(List<Genre> genres) { public void setGenres(List<Genre> genres) {
this.genres = genres; this.genres = genres;
} }
public void setHomepage(String homepage) { public void setHomepage(String homepage) {
this.homepage = homepage; this.homepage = homepage;
} }
public void setImdbID(String imdbID) { public void setImdbID(String imdbID) {
this.imdbID = imdbID; this.imdbID = imdbID;
} }
public void setOverview(String overview) { public void setOverview(String overview) {
this.overview = overview; this.overview = overview;
} }
public void setProductionCompanies(List<ProductionCompany> productionCompanies) { public void setProductionCompanies(List<ProductionCompany> productionCompanies) {
this.productionCompanies = productionCompanies; this.productionCompanies = productionCompanies;
} }
public void setProductionCountries(List<ProductionCountry> productionCountries) { public void setProductionCountries(List<ProductionCountry> productionCountries) {
this.productionCountries = productionCountries; this.productionCountries = productionCountries;
} }
public void setRevenue(long revenue) { public void setRevenue(long revenue) {
this.revenue = revenue; this.revenue = revenue;
} }
public void setRuntime(int runtime) { public void setRuntime(int runtime) {
this.runtime = runtime; this.runtime = runtime;
} }
public void setSpokenLanguages(List<Language> spokenLanguages) { public void setSpokenLanguages(List<Language> spokenLanguages) {
this.spokenLanguages = spokenLanguages; this.spokenLanguages = spokenLanguages;
} }
public void setTagline(String tagline) { public void setTagline(String tagline) {
this.tagline = tagline; this.tagline = tagline;
} }
public void setVoteAverage(float voteAverage) { public void setVoteAverage(float voteAverage) {
this.voteAverage = voteAverage; this.voteAverage = voteAverage;
} }
public void setVoteCount(int voteCount) { public void setVoteCount(int voteCount) {
this.voteCount = voteCount; this.voteCount = voteCount;
} }
public void setStatus(String status) { public void setStatus(String status) {
this.status = status; this.status = status;
} }
// </editor-fold> // </editor-fold>
/** //
* Handle unknown properties and print a message /**
* * Handle unknown properties and print a message
* @param key *
* @param value * @param key
*/ * @param value
@JsonAnySetter */
public void handleUnknown(String key, Object value) { @JsonAnySetter
StringBuilder sb = new StringBuilder(); public void handleUnknown(String key, Object value) {
sb.append("Unknown property: '").append(key); StringBuilder sb = new StringBuilder();
sb.append("' value: '").append(value).append("'"); sb.append("Unknown property: '").append(key);
LOG.trace(sb.toString()); sb.append("' value: '").append(value).append("'");
} LOG.trace(sb.toString());
}
//<editor-fold defaultstate="collapsed" desc="Equals and HashCode">
@Override //<editor-fold defaultstate="collapsed" desc="Equals and HashCode">
public boolean equals(Object obj) { @Override
if (obj == null) { public boolean equals(Object obj) {
return false; if (obj == null) {
} return false;
if (getClass() != obj.getClass()) { }
return false; if (getClass() != obj.getClass()) {
} return false;
final MovieDb other = (MovieDb) obj; }
if (this.id != other.id) { final MovieDb other = (MovieDb) obj;
return false; if (this.id != other.id) {
} return false;
if ((this.imdbID == null) ? (other.imdbID != null) : !this.imdbID.equals(other.imdbID)) { }
return false; if ((this.imdbID == null) ? (other.imdbID != null) : !this.imdbID.equals(other.imdbID)) {
} return false;
if (this.runtime != other.runtime) { }
return false; if (this.runtime != other.runtime) {
} return false;
return true; }
} return true;
}
@Override
public int hashCode() { @Override
int hash = 5; public int hashCode() {
hash = 89 * hash + this.id; int hash = 5;
hash = 89 * hash + (this.imdbID != null ? this.imdbID.hashCode() : 0); hash = 89 * hash + this.id;
hash = 89 * hash + this.runtime; hash = 89 * hash + (this.imdbID != null ? this.imdbID.hashCode() : 0);
return hash; hash = 89 * hash + this.runtime;
} return hash;
//</editor-fold> }
//</editor-fold>
@Override
public String toString() { @Override
StringBuilder sb = new StringBuilder("[MovieDB="); public String toString() {
sb.append("[backdropPath=").append(backdropPath); StringBuilder sb = new StringBuilder("[MovieDB=");
sb.append("],[id=").append(id); sb.append("[backdropPath=").append(backdropPath);
sb.append("],[originalTitle=").append(originalTitle); sb.append("],[id=").append(id);
sb.append("],[popularity=").append(popularity); sb.append("],[originalTitle=").append(originalTitle);
sb.append("],[posterPath=").append(posterPath); sb.append("],[popularity=").append(popularity);
sb.append("],[releaseDate=").append(releaseDate); sb.append("],[posterPath=").append(posterPath);
sb.append("],[title=").append(title); sb.append("],[releaseDate=").append(releaseDate);
sb.append("],[adult=").append(adult); sb.append("],[title=").append(title);
sb.append("],[belongsToCollection=").append(belongsToCollection); sb.append("],[adult=").append(adult);
sb.append("],[budget=").append(budget); sb.append("],[belongsToCollection=").append(belongsToCollection);
sb.append("],[genres=").append(genres); sb.append("],[budget=").append(budget);
sb.append("],[homepage=").append(homepage); sb.append("],[genres=").append(genres);
sb.append("],[imdbID=").append(imdbID); sb.append("],[homepage=").append(homepage);
sb.append("],[overview=").append(overview); sb.append("],[imdbID=").append(imdbID);
sb.append("],[productionCompanies=").append(productionCompanies); sb.append("],[overview=").append(overview);
sb.append("],[productionCountries=").append(productionCountries); sb.append("],[productionCompanies=").append(productionCompanies);
sb.append("],[revenue=").append(revenue); sb.append("],[productionCountries=").append(productionCountries);
sb.append("],[runtime=").append(runtime); sb.append("],[revenue=").append(revenue);
sb.append("],[spokenLanguages=").append(spokenLanguages); sb.append("],[runtime=").append(runtime);
sb.append("],[tagline=").append(tagline); sb.append("],[spokenLanguages=").append(spokenLanguages);
sb.append("],[voteAverage=").append(voteAverage); sb.append("],[tagline=").append(tagline);
sb.append("],[voteCount=").append(voteCount); sb.append("],[voteAverage=").append(voteAverage);
sb.append("],[status=").append(status); sb.append("],[voteCount=").append(voteCount);
sb.append("]]"); sb.append("],[status=").append(status);
return sb.toString(); sb.append("]]");
} return sb.toString();
} }
}

@ -1,213 +1,224 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.tools; package com.omertron.themoviedbapi.tools;
import com.omertron.themoviedbapi.TheMovieDbApi; import java.io.UnsupportedEncodingException;
import java.io.UnsupportedEncodingException; import java.net.MalformedURLException;
import java.net.MalformedURLException; import java.net.URL;
import java.net.URL; import java.net.URLEncoder;
import java.net.URLEncoder; import java.util.HashMap;
import java.util.HashMap; import java.util.Map;
import java.util.Map; import org.slf4j.Logger;
import org.slf4j.Logger; import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
/**
/** * The API URL that is used to construct the API call
* The API URL that is used to construct the API call *
* * @author Stuart
* @author Stuart */
*/ public class ApiUrl {
public class ApiUrl {
/*
/* * Logger
* Logger */
*/ private static final Logger LOG = LoggerFactory.getLogger(ApiUrl.class);
private static final Logger LOG = LoggerFactory.getLogger(ApiUrl.class); /*
/* * TheMovieDbApi API Base URL
* TheMovieDbApi API Base URL */
*/ private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/";
private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; /*
/* * Parameter configuration
* Parameter configuration */
*/ private static final String DELIMITER_FIRST = "?";
private static final String DELIMITER_FIRST = "?"; private static final String DELIMITER_SUBSEQUENT = "&";
private static final String DELIMITER_SUBSEQUENT = "&"; private static final String DEFAULT_STRING = "";
private static final String DEFAULT_STRING = ""; /*
/* * Properties
* Properties */
*/ private String apiKey;
private TheMovieDbApi tmdb; private String method;
private String method; private String submethod;
private String submethod; private Map<String, String> arguments = new HashMap<String, String>();
private Map<String, String> arguments = new HashMap<String, String>(); /*
/* * API Parameters
* API Parameters */
*/ public static final String PARAM_ADULT = "include_adult=";
public static final String PARAM_ADULT = "include_adult="; public static final String PARAM_API_KEY = "api_key=";
public static final String PARAM_API_KEY = "api_key="; public static final String PARAM_COUNTRY = "country=";
public static final String PARAM_COUNTRY = "country="; public static final String PARAM_FAVORITE = "favorite=";
public static final String PARAM_FAVORITE = "favorite="; public static final String PARAM_ID = "id=";
public static final String PARAM_ID = "id="; public static final String PARAM_LANGUAGE = "language=";
public static final String PARAM_LANGUAGE = "language="; public static final String PARAM_INCLUDE_ALL_MOVIES = "include_all_movies=";
public static final String PARAM_INCLUDE_ALL_MOVIES = "include_all_movies="; // public static final String PARAM_MOVIE_ID = "movie_id=";
// public static final String PARAM_MOVIE_ID = "movie_id="; public static final String PARAM_MOVIE_WATCHLIST = "movie_watchlist=";
public static final String PARAM_MOVIE_WATCHLIST = "movie_watchlist="; public static final String PARAM_PAGE = "page=";
public static final String PARAM_PAGE = "page="; public static final String PARAM_QUERY = "query=";
public static final String PARAM_QUERY = "query="; public static final String PARAM_SESSION = "session_id=";
public static final String PARAM_SESSION = "session_id="; public static final String PARAM_TOKEN = "request_token=";
public static final String PARAM_TOKEN = "request_token="; public static final String PARAM_VALUE = "value=";
public static final String PARAM_VALUE = "value="; public static final String PARAM_YEAR = "year=";
public static final String PARAM_YEAR = "year="; private static final String APPEND_TO_RESPONSE = "append_to_response=";
//<editor-fold defaultstate="collapsed" desc="Constructor Methods"> //<editor-fold defaultstate="collapsed" desc="Constructor Methods">
/** /**
* Constructor for the simple API URL method without a sub-method * Constructor for the simple API URL method without a sub-method
* *
* @param method * @param method
*/ */
public ApiUrl(TheMovieDbApi tmdb, String method) { public ApiUrl(String apiKey, String method) {
this.tmdb = tmdb; this.apiKey = apiKey;
this.method = method; this.method = method;
this.submethod = DEFAULT_STRING; this.submethod = DEFAULT_STRING;
} }
/** /**
* Constructor for the API URL with a sub-method * Constructor for the API URL with a sub-method
* *
* @param method * @param method
* @param submethod * @param submethod
*/ */
public ApiUrl(TheMovieDbApi tmdb, String method, String submethod) { public ApiUrl(String apiKey, String method, String submethod) {
this.tmdb = tmdb; this.apiKey = apiKey;
this.method = method; this.method = method;
this.submethod = submethod; this.submethod = submethod;
} }
//</editor-fold> //</editor-fold>
/** /**
* Build the URL from the pre-created arguments. * Build the URL from the pre-created arguments.
*/ */
public URL buildUrl() { public URL buildUrl() {
StringBuilder urlString = new StringBuilder(TMDB_API_BASE); StringBuilder urlString = new StringBuilder(TMDB_API_BASE);
// Get the start of the URL // Get the start of the URL
urlString.append(method); urlString.append(method);
// We have either a queury, or a direct request // We have either a queury, or a direct request
if (arguments.containsKey(PARAM_QUERY)) { if (arguments.containsKey(PARAM_QUERY)) {
// Append the suffix of the API URL // Append the suffix of the API URL
urlString.append(submethod); urlString.append(submethod);
// Append the key information // Append the key information
urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY); urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY);
urlString.append(tmdb.getApiKey()); urlString.append(apiKey);
// Append the search term // Append the search term
urlString.append(DELIMITER_SUBSEQUENT); urlString.append(DELIMITER_SUBSEQUENT);
urlString.append(PARAM_QUERY); urlString.append(PARAM_QUERY);
String query = arguments.get(PARAM_QUERY); String query = arguments.get(PARAM_QUERY);
try { try {
urlString.append(URLEncoder.encode(query, "UTF-8")); urlString.append(URLEncoder.encode(query, "UTF-8"));
} catch (UnsupportedEncodingException ex) { } catch (UnsupportedEncodingException ex) {
LOG.trace("Unable to encode query: '" + query + "' trying raw."); LOG.trace("Unable to encode query: '{}' trying raw.", query);
// If we can't encode it, try it raw // If we can't encode it, try it raw
urlString.append(query); urlString.append(query);
} }
arguments.remove(PARAM_QUERY); arguments.remove(PARAM_QUERY);
} else { } else {
// Append the ID if provided // Append the ID if provided
if (arguments.containsKey(PARAM_ID)) { if (arguments.containsKey(PARAM_ID)) {
urlString.append(arguments.get(PARAM_ID)); urlString.append(arguments.get(PARAM_ID));
arguments.remove(PARAM_ID); arguments.remove(PARAM_ID);
} }
// Append the suffix of the API URL // Append the suffix of the API URL
urlString.append(submethod); urlString.append(submethod);
// Append the key information // Append the key information
urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY); urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY);
urlString.append(tmdb.getApiKey()); urlString.append(apiKey);
} }
for (Map.Entry<String, String> argEntry : arguments.entrySet()) { for (Map.Entry<String, String> argEntry : arguments.entrySet()) {
urlString.append(DELIMITER_SUBSEQUENT).append(argEntry.getKey()); urlString.append(DELIMITER_SUBSEQUENT).append(argEntry.getKey());
urlString.append(argEntry.getValue()); urlString.append(argEntry.getValue());
} }
try { try {
LOG.trace("URL: {}", urlString.toString()); LOG.trace("URL: {}", urlString.toString());
return new URL(urlString.toString()); return new URL(urlString.toString());
} catch (MalformedURLException ex) { } catch (MalformedURLException ex) {
LOG.warn("Failed to create URL {} - {}", urlString.toString(), ex.toString()); LOG.warn("Failed to create URL {} - {}", urlString.toString(), ex.toString());
return null; return null;
} finally { } finally {
arguments.clear(); arguments.clear();
} }
} }
/** /**
* Add arguments individually * Add arguments individually
* *
* @param key * @param key
* @param value * @param value
*/ */
public void addArgument(String key, String value) { public void addArgument(String key, String value) {
arguments.put(key, value); arguments.put(key, value);
} }
/** /**
* Add arguments individually * Add arguments individually
* *
* @param key * @param key
* @param value * @param value
*/ */
public void addArgument(String key, int value) { public void addArgument(String key, int value) {
arguments.put(key, Integer.toString(value)); arguments.put(key, Integer.toString(value));
} }
/** /**
* Add arguments individually * Add arguments individually
* *
* @param key * @param key
* @param value * @param value
*/ */
public void addArgument(String key, boolean value) { public void addArgument(String key, boolean value) {
arguments.put(key, Boolean.toString(value)); arguments.put(key, Boolean.toString(value));
} }
/** /**
* Clear the arguments * Clear the arguments
*/ */
public void clearArguments() { public void clearArguments() {
arguments.clear(); arguments.clear();
} }
/** /**
* Set the arguments directly * Set the arguments directly
* *
* @param args * @param args
*/ */
public void setArguments(Map<String, String> args) { public void setArguments(Map<String, String> args) {
arguments.putAll(args); arguments.putAll(args);
} }
}
/**
* Append any optional parameters to the URL
*
* @param appendToResponse
*/
public void appendToResponse(String[] appendToResponse) {
if (appendToResponse.length > 0) {
addArgument(APPEND_TO_RESPONSE, appendToResponse[0]);
}
}
}

Loading…
Cancel
Save