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

📄 cmppsubmitmessage.java

📁 华为CNGP.CMPP.SGIP.CMPP源代码。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

		outStr = outStr + ",msg_Length=" + msg_Content.length;
		if (msg_Fmt == 0) {
			try {
				outStr = outStr + ",msg_Content="
						+ new String(msg_Content, "ASCII");
			} catch (UnsupportedEncodingException _) {
			}
		} else if (msg_Fmt == 8) {
			try {
				outStr = outStr + ",msg_Content="
						+ new String(msg_Content, "ISO-10646-UCS-2");
			} catch (UnsupportedEncodingException _) {
			}
		} else if (msg_Fmt == 15) {
			try {
				outStr = outStr + ",msg_Content="
						+ new String(msg_Content, "GB2312");
			} catch (UnsupportedEncodingException _) {
			}
		} else {
			outStr = outStr + ",msg_Content=" + msg_Content;
		}

		outStr = outStr + ",reserve=" + reserve;
	}

	private void validate(int pk_Total, int pk_Number, int registered_Delivery,
			int msg_Level, String service_Id, int fee_UserType,
			String fee_Terminal_Id, int tp_Pid, int tp_Udhi, int msg_Fmt,
			String msg_Src, String fee_Type, String fee_Code,
			String src_Terminal_Id, String[] dest_Terminal_Id,
			byte[] msg_Content, String reserve) {
		if (pk_Total < 1 || pk_Total > 255) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":" + CMPPConstant.PK_TOTAL_ERROR);
		}

		if (pk_Number < 1 || pk_Number > 255) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":" + CMPPConstant.PK_NUMBER_ERROR);
		}

		if (registered_Delivery < 0 || registered_Delivery > 2) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":" + CMPPConstant.REGISTERED_DELIVERY_ERROR);
		}

		if (msg_Level < 0 || msg_Level > 255) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":msg_Level" + CMPPConstant.INT_SCOPE_ERROR);
		}

		if (service_Id.length() > 10) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":service_Id" + CMPPConstant.STRING_LENGTH_GREAT + "10");
		}

		if (fee_UserType < 0 || fee_UserType > 3) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":" + CMPPConstant.FEE_USERTYPE_ERROR);
		}

		if (fee_Terminal_Id.length() > 21) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":fee_Terminal_Id" + CMPPConstant.STRING_LENGTH_GREAT
					+ "21");
		}

		if (tp_Pid < 0 || tp_Pid > 255) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":tp_Pid" + CMPPConstant.INT_SCOPE_ERROR);
		}

		if (tp_Udhi < 0 || tp_Udhi > 255) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":tp_Udhi" + CMPPConstant.INT_SCOPE_ERROR);
		}

		if (msg_Fmt < 0 || msg_Fmt > 255) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":msg_Fmt" + CMPPConstant.INT_SCOPE_ERROR);
		}

		if (msg_Src.length() > 6) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":msg_Src" + CMPPConstant.STRING_LENGTH_GREAT + "6");
		}

		if (fee_Type.length() > 2) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":fee_Type" + CMPPConstant.STRING_LENGTH_GREAT + "2");
		}

		if (fee_Code.length() > 6) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":fee_Code" + CMPPConstant.STRING_LENGTH_GREAT + "6");
		}

		if (src_Terminal_Id.length() > 21) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":src_Terminal_Id" + CMPPConstant.STRING_LENGTH_GREAT
					+ "21");
		}

		if (dest_Terminal_Id.length > 100) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":dest_Terminal_Id" + CMPPConstant.STRING_LENGTH_GREAT
					+ "100");
		}

		for (int i = 0; i < dest_Terminal_Id.length; i++) {
			if (dest_Terminal_Id[i].length() > 21) {
				throw new IllegalArgumentException(
						CMPPConstant.SUBMIT_INPUT_ERROR + ":dest_Terminal_Id"
								+ CMPPConstant.STRING_LENGTH_GREAT + "21");
			}
		}

		if (msg_Fmt == 0) {
			if (msg_Content.length > 160) {
				throw new IllegalArgumentException(
						CMPPConstant.SUBMIT_INPUT_ERROR + ":msg_Content"
								+ CMPPConstant.STRING_LENGTH_GREAT + "160");
			}
		} else if (msg_Content.length > 140) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":msg_Content" + CMPPConstant.STRING_LENGTH_GREAT + "140");
		}

		if (reserve.length() > 8) {
			throw new IllegalArgumentException(CMPPConstant.SUBMIT_INPUT_ERROR
					+ ":reserve" + CMPPConstant.STRING_LENGTH_GREAT + "8");
		}
	}

	public void setMessageId(long msg_Id) {
		TypeConvert.long2byte(msg_Id, buf, 12);
	}

	public long getMessageId() {
		return TypeConvert.getLong(buf, 12);
	}

	public byte getPkTotal() {
		return buf[21];
	}

	public byte getPkNumber() {
		return buf[22];
	}

	public byte getLevel() {
		return buf[23];
	}

	public byte[] getServiceId() {
		byte[] bytes = new byte[10];
		System.arraycopy(buf, 24, bytes, 0, bytes.length);
		return bytes;
	}

	public byte getFeeUserType() {
		return buf[34];
	}

	public byte[] getFeeTerminalId() {
		byte[] bytes = new byte[21];
		System.arraycopy(buf, 35, bytes, 0, bytes.length);
		return bytes;
	}

	public byte getTPPId() {
		return super.buf[56];
	}

	public byte getTPUdhi() {
		return super.buf[57];
	}

	public byte getMsgFmt() {
		return super.buf[58];
	}

	public byte[] getMsgSrc() {
		byte[] bytes = new byte[6];
		System.arraycopy(buf, 59, bytes, 0, bytes.length);
		return bytes;
	}

	public byte[] getFeeType() {
		byte[] bytes = new byte[2];
		System.arraycopy(buf, 65, bytes, 0, bytes.length);
		return bytes;
	}

	public byte[] getFeeCode() {
		byte[] bytes = new byte[6];
		System.arraycopy(buf, 67, bytes, 0, bytes.length);
		return bytes;
	}

	public byte[] getValidTime() {
		byte[] bytes = new byte[17];
		System.arraycopy(buf, 73, bytes, 0, bytes.length);
		return bytes;
	}

	public byte[] getAtTime() {
		byte[] bytes = new byte[17];
		System.arraycopy(buf, 90, bytes, 0, bytes.length);
		return bytes;
	}

	public byte[] getSrcId() {
		byte[] bytes = new byte[21];
		System.arraycopy(buf, 107, bytes, 0, bytes.length);
		return bytes;
	}

	/**
	 * 接收信息的用户数量(小于100个用户)
	 * 
	 * @return
	 */
	public byte getDestUsrTl() {
		return buf[128];
	}

	/**
	 * 接收短信的MSISDN号码
	 * 
	 * @return
	 */
	public String[] getDestTerminalId() {
		byte len = getDestUsrTl();
		String[] terminals = new String[len];
		for (int i = 0; i < len; ++i) {
			byte[] bytes = new byte[21];
			System.arraycopy(buf, 129 + i * 21, bytes, 0, bytes.length);
			terminals[i] = new String(bytes);
		}

		return terminals;
	}

	public byte getMsgLength() {
		int loc = 129 + getDestUsrTl() * 21;
		return buf[loc];
	}

	public byte[] getMsgContent() {
		int loc = 129 + getDestUsrTl() * 21;
		byte len = buf[loc];

		byte[] bytes = new byte[len];
		System.arraycopy(buf, loc + 1, bytes, 0, bytes.length);
		return bytes;
	}

	public String toString() {
		String tmpStr = "CMPP_Submit: ";
		tmpStr = tmpStr + "Sequence_Id=" + getSequenceId();
		tmpStr = tmpStr + outStr;
		return tmpStr;
	}

	public int getCommandId() {
		return CMPPConstant.Submit_Command_Id;
	}

}

⌨️ 快捷键说明

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