概述
*/public void setFrom(String myFrom){this.from = myFrom;}/** * Returns the message status. * * @return The message status. * @see MessageStatuses */public MessageStatuses getMessageStatus(){return this.messageStatus;}public void setMessageStatus(MessageStatuses myMessageStatus){this.messageStatus = myMessageStatus;}public FailureCauses getFailureCause(){return this.failureCause;}/** * Mark message as failed and set cause of failure. * * @param myFailureCause * Cause of failure */public void setFailureCause(FailureCauses myFailureCause){if (myFailureCause != FailureCauses.NO_ERROR) this.messageStatus = MessageStatuses.FAILED;this.failureCause = myFailureCause;}/** * Return value of internal sending retry counter. * * @return Number of sending message retries */public int getRetryCount(){return this.retryCount;}void incrementRetryCount(){this.retryCount++;}/** * Returns the priority of the message. * * @return The priority of the message. */public int getPriority(){return this.priority;}/** * Sets the priority of the message. * * @param myPriority * The new priority. */public void setPriority(int myPriority){this.priority = myPriority;}/** * Returns the message Reference Number. The Reference Number comes into * existence when the message is sent. Its format depends on the gateway: * For modems, its a number. For bulk sms operators, this is a hex string. * If the message has not been sent yet, the Reference number is blank. * * @return The message reference number. */public String getRefNo(){return this.refNo;}public void setRefNo(String myRefNo){this.refNo = myRefNo;}@Overridepublic String toString(){String str = "";str += "===============================================================================";str += "n";str += ">";str += "n";str += "-------------------------------------------------------------------------------";str += "n";str += " Gateway Id: " + getGatewayId();str += "n";str += " Encoding: " + (getEncoding() == MessageEncodings.ENC7BIT ? "7-bit" : (getEncoding() == MessageEncodings.ENC8BIT ? "8-bit" : "UCS2 (Unicode)"));str += "n";str += " Date: " + getDate();str += "n";str += " SMSC Ref No: " + getRefNo();str += "n";str += " Recipient: " + getRecipient();str += "n";str += " Dispatch Date: " + getDispatchDate();str += "n";str += " Message Status: " + getMessageStatus();str += "n";str += " Validity Period (Hours): " + getValidityPeriod();str += "n";str += " Status Report: " + getStatusReport();str += "n";str += " Source / Destination Ports: " + getSrcPort() + " / " + getDstPort();str += "n";str += " Flash SMS: " + getFlashSms();str += "n";if (this instanceof OutboundBinaryMessage){OutboundBinaryMessage binaryMessage = (OutboundBinaryMessage) this;if (binaryMessage.getDataBytes() != null){String binaryString = PduUtils.bytesToPdu((binaryMessage).getDataBytes());str += " Binary: " + binaryString;str += "n";}else{str += " Binary: null";str += "n";}}else{str += " Text: " + getText();str += "n";try{str += " PDU data: " + getPduUserData();str += "n";}catch (Exception e){str += " PDU data: ";str += "n";}}str += "===============================================================================";str += "n";return str;}public List getPdus(String smscNumber, int mpRefNo){PduGenerator pduGenerator = new PduGenerator();SmsSubmitPdu pdu = createPduObject();initPduObject(pdu, smscNumber);return pduGenerator.generatePduList(pdu, mpRefNo);}protected SmsSubmitPdu createPduObject(){// if you want to be able to change some other parts of the first octet// do it hereSmsSubmitPdu pdu;if (this.statusReport){pdu = PduFactory.newSmsSubmitPdu(PduUtils.TP_SRR_REPORT | PduUtils.TP_VPF_INTEGER);}else{pdu = PduFactory.newSmsSubmitPdu();}return pdu;}protected void initPduObject(SmsSubmitPdu pdu, String smscNumber){if ((getDstPort() > -1) && (getSrcPort() > -1)){// port infopdu.addInformationElement(InformationElementFactory.generatePortInfo(getDstPort(), getSrcPort()));}// smscInfo// address type field + #octets for smscNumberpdu.setSmscInfoLength(1 + (smscNumber.length() / 2));pdu.setSmscAddress(smscNumber);// message reference// just use 0 since this is not tracked by the ModemGatewaypdu.setMessageReference(0);// destination address infopdu.setAddress(getRecipient());// protocol idpdu.setProtocolIdentifier(0);// data coding schemeif (!pdu.isBinary()){int dcs = 0;if (getEncoding() == MessageEncodings.ENC7BIT){dcs = PduUtils.DCS_ENCODING_7BIT;}else if (getEncoding() == MessageEncodings.ENC8BIT){dcs = PduUtils.DCS_ENCODING_8BIT;}else if (getEncoding() == MessageEncodings.ENCUCS2){dcs = PduUtils.DCS_ENCODING_UCS2;}else if (getEncoding() == MessageEncodings.ENCCUSTOM){// just use thisdcs = PduUtils.DCS_ENCODING_7BIT;}if (this.flashSms){// add flash indicatordcs = dcs | PduUtils.DCS_MESSAGE_CLASS_FLASH;}pdu.setDataCodingScheme(dcs);}// validity periodpdu.setValidityPeriod(this.validityPeriod);// add payloadsetPduPayload(pdu);}protected void setPduPayload(SmsSubmitPdu pdu){pdu.setDecodedText(getText());}@Overridepublic String getPduUserData(){// generatePduGenerator pduGenerator = new PduGenerator();SmsSubmitPdu pdu = createPduObject();initPduObject(pdu, "");// NOTE: - the mpRefNo is arbitrarily set to 1// - this won't matter since we aren't looking at the UDH in this method// - this method is not allowed for 7-bit messages with UDH// since it is probable that the returned value will not be// correct due to the encoding's dependence on the UDH// - if the user wishes to extract the UD per part, he would need to get all pduStrings// using getPdus(String smscNumber, int mpRefNo), use a// PduParser on each pduString in the returned list, then access the UD via the Pdu objectList pdus = pduGenerator.generatePduList(pdu, 1);// my this point, pdu will be updated with concat info (in udhi), if presentif ((pdu.hasTpUdhi()) && (getEncoding() == MessageEncodings.ENC7BIT)) { throw new RuntimeException("getPduUserData() not supported for 7-bit messages with UDH"); }// sum up the ud partsStringBuffer ud = new StringBuffer();for (String pduString : pdus){Pdu newPdu = new PduParser().parsePdu(pduString);ud.append(PduUtils.bytesToPdu(newPdu.getUserDataAsBytes()));}return ud.toString();}@Overridepublic String getPduUserDataHeader(){// generatePduGenerator pduGenerator = new PduGenerator();SmsSubmitPdu pdu = createPduObject();initPduObject(pdu, "");// NOTE: - the mpRefNo is arbitrarily set to 1// - if the user wishes to extract the UDH per part, he would need to get all pduStrings// using getPdus(String smscNumber, int mpRefNo), use a// PduParser on each pduString in the returned list, then access the UDH via the Pdu objectList pdus = pduGenerator.generatePduList(pdu, 1);Pdu newPdu = new PduParser().parsePdu(pdus.get(0));byte[] udh = newPdu.getUDHData();if (udh != null) return PduUtils.bytesToPdu(udh);return null;}@Overridepublic void setEncoding(MessageEncodings encoding){if (encoding == MessageEncodings.ENC8BIT){if (this instanceof OutboundBinaryMessage) super.setEncoding(encoding);else throw new RuntimeException("Cannot use 8-bit encoding with OutgoingMessage, use OutgoingBinaryMessage instead");}else{// 7-bit / ucs2super.setEncoding(encoding);}}}
最后
以上就是贪玩小白菜为你收集整理的java message包_outboundmessage.java 源代码在线查看 - java平台 smslib 短 信 开 发 包 资源下载 虫虫电子下载站...的全部内容,希望文章能够帮你解决java message包_outboundmessage.java 源代码在线查看 - java平台 smslib 短 信 开 发 包 资源下载 虫虫电子下载站...所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复