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

📄 sendapplicationtriggerresponse.java

📁 Vodafone betvine java api source code, latest stable release.
💻 JAVA
字号:
package com.bv.api.response;import java.util.Vector;import com.bv.api.Error;/** * A structure to hold the information returned by the server in response to a send Application Trigger call. * @author C. Oattes, Kris Nobes */public class SendApplicationTriggerResponse extends ApiResponse {	private String transactionId;	private Vector<String> messageId;		/**	 * Create a "successful" API response.	 */	public SendApplicationTriggerResponse() {		super();		transactionId = "";		messageId = new Vector<String>();	}		/**	 * Create a "successful" API response. 	 * @param response The response from the server.	 */	public SendApplicationTriggerResponse(String response) {		super(response);		transactionId = "";		messageId = new Vector<String>();	}		/**	 * Create a SendApplicationTriggerResponse when the API call failed.	 * @param error The error that occured.	 */	public SendApplicationTriggerResponse(Error error) {		super(error);		transactionId = "";		messageId = new Vector<String>();	}		/**	 * Create a SendApplicationTriggerResponse when the API call failed. <code>Response</code> is the response from the server.	 * @param error The error that occured.	 * @param response The response from the server.	 */	public SendApplicationTriggerResponse(Error error, String response) {		super(error, response);		transactionId = "";		messageId = new Vector<String>();	}		/**	 * Get the transaction ID of the message(s) sent	 * @return Transaction ID	 */	public String getTransactionId() {		return transactionId;	}	/**	 * Get the message IDs of the message(s) sent	 * 	 * @return A vector containing message IDs	 */	public Vector<String> getMessageIds() {		return messageId;	}		/**	 * Generate a SendApplicationTriggerResponse, with "response" set to whatever is returned by the server	 * @param serverResponse The response from the server	 * @return A SendApplicationTriggerResponse	 */	public SendApplicationTriggerResponse processResponse(String serverResponse) {				//In all cases, successful response should start with "OK"		if(serverResponse.startsWith("OK")) {			String[] lines = serverResponse.split("\n");			this.setResponse(lines[0]);						this.setVersion(lines[0].split(" ")[1]);			for(int i = 1; i < lines.length; i++) {				String line = lines[i];				if(line.startsWith("TRANSACTION")) {					//line.split(" ")[1] gets the second word in the line.					this.transactionId = line.split(" ")[1];				} else if(line.startsWith("MESSAGE")) {					this.messageId.add(line.split(" ")[1]);				}			}			return this;		} else if (serverResponse.startsWith("FAIL")) {			String[] lines = serverResponse.split("\n");			Error error;			this.setVersion(lines[0].split(" ")[1]);			//			for(int i = 1; i < lines.length; i++) {				String line = lines[i];				if(line.startsWith("ERROR")) {					//line.split(" ", 3) divides the line into at most 3 sections (ERROR) (ID) (ERROR CODE)					String[] splitString = line.split(" " , 3);					switch(splitString.length) {						case 3:							error = Error.getError(splitString[1]);							this.setResponse(splitString[2]);							break;						case 2:							error = Error.getError(splitString[1]);							break;						default:							error = Error.UnknownError;							break;					} //end switch					this.setError(error);				}//end if			}//end for			return this;		}		//Response from API unknown - return an error.		//shouldn't reach this point		this.setError(Error.UnknownError);		return this;	}}

⌨️ 快捷键说明

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