/** * Sets the user name that will be used in the request URL. * * @param user user name to use * @throws IllegalArgumentException if the user is empty * @throws NullPointerException if the user is null */ public void setUser(String user) { StringValidator.throwIfEmptyOrNull("user", user); this.user = user; }
/** * Sets the response handler for this request. This method <b>must</b> be * called before calling {@link #send()}. * * @param callback the response handler to be notified when the request fails * or completes * * @throws NullPointerException if <code>callback</code> is <code>null</code> */ public void setCallback(RequestCallback callback) { StringValidator.throwIfNull("callback", callback); this.callback = callback; }
/** * Throws if <code>value</code> is <code>null</code> or empty. This method * ignores leading and trailing whitespace. * * @param name the name of the value, used in error messages * @param value the string value that needs to be validated * * @throws IllegalArgumentException if the string is empty, or all whitespace * @throws NullPointerException if the string is <code>null</code> */ public static void throwIfEmptyOrNull(String name, String value) { assert (name != null); assert (name.trim().length() != 0); throwIfNull(name, value); if (0 == value.trim().length()) { throw new IllegalArgumentException(name + " cannot be empty"); } }
/** * Sets the password to use in the request URL. This is ignored if there is no * user specified. * * @param password password to use in the request URL * * @throws IllegalArgumentException if the password is empty * @throws NullPointerException if the password is null */ public void setPassword(String password) { StringValidator.throwIfEmptyOrNull("password", password); this.password = password; }
/** * Returns a string where all URL escape sequences have been converted back to * their original character representations. * * @param encodedURL string containing encoded URL encoded sequences * @return string with no encoded URL encoded sequences * * @throws NullPointerException if encodedURL is <code>null</code> */ public static String decode(String encodedURL) { StringValidator.throwIfNull("encodedURL", encodedURL); return decodeImpl(encodedURL); }
/** * Creates a builder using the parameters values for configuration. * * @param httpMethod HTTP method to use for the request * @param url URL that has already has already been URL encoded. Please see * {@link com.google.gwt.http.client.URL#encode(String)} and * {@link com.google.gwt.http.client.URL#encodePathSegment(String)} and * {@link com.google.gwt.http.client.URL#encodeQueryString(String)} for * how to do this. * @throws IllegalArgumentException if the httpMethod or URL are empty * @throws NullPointerException if the httpMethod or the URL are null */ protected RequestBuilder(String httpMethod, String url) { StringValidator.throwIfEmptyOrNull("httpMethod", httpMethod); StringValidator.throwIfEmptyOrNull("url", url); this.httpMethod = httpMethod; this.url = url; }
/** * Sends an HTTP request based on the current builder configuration. If no * request headers have been set, the header "Content-Type" will be used with * a value of "text/plain; charset=utf-8". You must call * {@link #setRequestData(String)} and {@link #setCallback(RequestCallback)} * before calling this method. * * @return a {@link Request} object that can be used to track the request * @throws RequestException if the call fails to initiate * @throws NullPointerException if a request callback has not been set */ public Request send() throws RequestException { StringValidator.throwIfNull("callback", callback); return doSend(requestData, callback); }
/** * Sets a request header with the given name and value. If a header with the * specified name has already been set then the new value overwrites the * current value. * * @param header the name of the header * @param value the value of the header * * @throws NullPointerException if header or value are null * @throws IllegalArgumentException if header or value are the empty string */ public void setHeader(String header, String value) { StringValidator.throwIfEmptyOrNull("header", header); StringValidator.throwIfEmptyOrNull("value", value); if (headers == null) { headers = new HashMap<String, String>(); } headers.put(header, value); }
/** * Returns a string where all URL component escape sequences have been * converted back to their original character representations. * * @param encodedURLComponent string containing encoded URL component * sequences * @return string with no encoded URL component encoded sequences * * @throws NullPointerException if encodedURLComponent is <code>null</code> */ public static String decodePathSegment(String encodedURLComponent) { StringValidator.throwIfNull("encodedURLComponent", encodedURLComponent); return decodePathSegmentImpl(encodedURLComponent); }
@Override public String getHeader(String header) { StringValidator.throwIfEmptyOrNull("header", header); return xmlHttpRequest.getResponseHeader(header); }
/** * Returns a string where all URL component escape sequences have been * converted back to their original character representations. * <p> * Note: this method will convert the space character escape short form, '+', * into a space. It should therefore only be used for query-string parts. * * @param encodedURLComponent string containing encoded URL component * sequences * @return string with no encoded URL component encoded sequences * * @throws NullPointerException if encodedURLComponent is <code>null</code> */ public static String decodeQueryString(String encodedURLComponent) { StringValidator.throwIfNull("encodedURLComponent", encodedURLComponent); return decodeQueryStringImpl(encodedURLComponent); }
/** * Sets the user name that will be used in the request URL. * * @param user user name to use * @throws IllegalArgumentException if the user is empty * @throws NullPointerException if the user is null */ public void setUser(String user) { StringValidator.throwIfEmptyOrNull("user", user); this.user = user; }
/** * Sends an HTTP request based on the current builder configuration with the * specified data and callback. If no request headers have been set, the * header "Content-Type" will be used with a value of "text/plain; * charset=utf-8". This method does not cache <code>requestData</code> or * <code>callback</code>. * * @param requestData the data to send as part of the request * @param callback the response handler to be notified when the request fails * or completes * @return a {@link Request} object that can be used to track the request * @throws NullPointerException if <code>callback</code> <code>null</code> */ public Request sendRequest(String requestData, RequestCallback callback) throws RequestException { StringValidator.throwIfNull("callback", callback); return doSend(requestData, callback); }
/** * Sets the user name that will be used in the request URL. * * @param user user name to use * @throws IllegalArgumentException if the user is empty * @throws NullPointerException if the user is null */ public void setUser(String user) { StringValidator.throwIfEmptyOrNull("user", user); this.user = user; }
StringValidator.throwIfNull("decodedURLComponent", decodedURLComponent); return encodePathSegmentImpl(decodedURLComponent);
/** * Sets the password to use in the request URL. This is ignored if there is no * user specified. * * @param password password to use in the request URL * * @throws IllegalArgumentException if the password is empty * @throws NullPointerException if the password is null */ public void setPassword(String password) { StringValidator.throwIfEmptyOrNull("password", password); this.password = password; }
StringValidator.throwIfNull("decodedURL", decodedURL); return encodeImpl(decodedURL);
/** * Sets the password to use in the request URL. This is ignored if there is no * user specified. * * @param password password to use in the request URL * * @throws IllegalArgumentException if the password is empty * @throws NullPointerException if the password is null */ public void setPassword(String password) { StringValidator.throwIfEmptyOrNull("password", password); this.password = password; }
StringValidator.throwIfNull("decodedURLComponent", decodedURLComponent); return encodeQueryStringImpl(decodedURLComponent);
/** * Creates a builder using the parameters values for configuration. * * @param httpMethod HTTP method to use for the request * @param url URL that has already has already been URL encoded. Please see * {@link com.google.gwt.http.client.URL#encode(String)} and * {@link com.google.gwt.http.client.URL#encodePathSegment(String)} and * {@link com.google.gwt.http.client.URL#encodeQueryString(String)} for * how to do this. * @throws IllegalArgumentException if the httpMethod or URL are empty * @throws NullPointerException if the httpMethod or the URL are null */ protected RequestBuilder(String httpMethod, String url) { StringValidator.throwIfEmptyOrNull("httpMethod", httpMethod); StringValidator.throwIfEmptyOrNull("url", url); this.httpMethod = httpMethod; this.url = url; }