⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sendwappush.java

📁 Vodafone betvine java api source code, latest stable release.
💻 JAVA
字号:
package com.bv.api.send;import java.io.IOException;import java.net.MalformedURLException;import java.util.Iterator;import java.util.Vector;import com.bv.api.Error;import com.bv.api.InvalidParameterException;import com.bv.api.ParamCall;import com.bv.api.ParamNotPresentException;import com.bv.api.response.SendWapPushResponse;/** * An API wrapper class that allows you to send a WAP Push to one or more destinations. * @author C. Oattes, Kris Nobes */public class SendWapPush extends ParamCall {		/**	 * The message to be sent	 */	private String message = null;		/**	 * The URL to send	 */	private String linkUrl = null;		/**	 * A list of destinations	 */	private Vector<String> destinations;		/**	 * Create a SendWapPush object	 */	public SendWapPush() {		super();		destinations = new Vector<String>();		url = "/api/send/wappush";	}		/***	 * Create a SendWapPush object	 * @param message The message to send	 * @param linkURL The link to send	 * @param destinations A list of destinations	 */	public SendWapPush(String message, String linkURL, Vector<String> destinations) {		this();		this.message = message;		this.linkUrl = linkURL;		this.destinations = destinations;	}		/***	 * Create a SendWapPush object	 * @param message The message to send	 * @param linkURL The link to send	 * @param destination A single destination	 */	public SendWapPush(String message, String linkURL, String destination) {		this();		this.message = message;		this.linkUrl = linkURL;		this.destinations.add(destination);	}	/**	 * Set the text of the message	 * @param message The message to be sent	 */	public void setMessage(String message) {		this.message = message;	}		/**	 * Get the message to be sent	 * @return The message to be sent	 */	public String getMessage() {		return message;	}		/**	 * Add a destinations to the list	 * @param number The destination to be added	 */	public void addDestination(String number) {		destinations.add(number);	}		/**	 * Set the destination list	 * @param numbers The list of numbers to send the message to	 */	public void setDestinations(Vector<String> numbers) {		this.destinations = numbers;	}		/**	 * Get the destination list	 * @return The list of numbers to send the message to	 */	public Vector<String> getDestinations() {		return destinations;	}		/**	 * Set the URL to send	 * @param url The URL to send	 */	public void setLinkURL(String url) {		this.linkUrl = url;	}		/**	 * Get the URL to be sent	 * @return The URL to be sent	 */	public String getLinkURL() {		return linkUrl;	}		protected boolean checkParams(String uaid) throws ParamNotPresentException, InvalidParameterException {		Vector<String> unsetParams = new Vector<String>();		if (destinations.size() == 0) {			unsetParams.add("destinations");		} 		if (uaid == null || uaid.equals("")) {			unsetParams.add("uaid");		} else if (uaid.length() != 32) {			throw new InvalidParameterException("UAID");		}		if (message == null || message.equals("")) {			unsetParams.add("message");		}		 		if (url == null || linkUrl.equals("")) {			unsetParams.add("url");		}				if (unsetParams.size() > 0) {			throw new ParamNotPresentException(unsetParams);		} else {			return true;		}	}		protected String constructParameterString(String uaid) throws InvalidParameterException{		Iterator<String> destinationsIterator;		String parameters = "";		parameters += getEncodedParams("uaid", uaid);		parameters += "&";		parameters += getEncodedParams("message", message);		parameters += "&";		parameters += getEncodedParams("url", linkUrl);		parameters += "&";		destinationsIterator = destinations.iterator();		while (destinationsIterator.hasNext()) {			String number = destinationsIterator.next();			if (number.equals("")) {				throw new InvalidParameterException("destinations");			} else {				parameters += getEncodedParams("dest", number);			}			if (destinationsIterator.hasNext()) {				parameters += "&";			}		}		return parameters;	}		/**	 * Process the response from the server and return an {@link SendWapPushResponse} object	 * @param uaid The user uaid	 * @param serverURL The server to connect to	 * @return SendWapPushResponse, with "success" set to <code>true</code> if the request was successful, <code>false</code> otherwise.	 */	public SendWapPushResponse execute(String uaid, String serverURL) throws ParamNotPresentException, InvalidParameterException {		try {			String response = connect(uaid, serverURL);			SendWapPushResponse wpResponse = new SendWapPushResponse();			return wpResponse.processResponse(response);		} catch (MalformedURLException mue) {			return new SendWapPushResponse(Error.ConnectionError, "Invalid server URL");		} catch (IOException ioe) {			return new SendWapPushResponse(Error.ConnectionError);		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -