@Test public void decompose_submit_sm() throws Exception { ByteArrayOutputStream data = new ByteArrayOutputStream(); data.write(new byte[]{ 0x00, 0x00, 0x00, 0x46 }); data.write(new byte[]{ 0x00, 0x00, 0x00, 0x04 }); data.write(new byte[]{ 0x00, 0x00, 0x00, 0x00 }); data.write(new byte[]{ 0x00, 0x00, 0x12, 0x34 }); data.write("CMT\000".getBytes(CHARSET_US_ASCII)); data.write(1); data.write(2); data.write("31600000000\000".getBytes(CHARSET_US_ASCII)); data.write(3); data.write(4); data.write("31612345678\000".getBytes(CHARSET_US_ASCII)); data.write(5); data.write(6); data.write(7); data.write(0); data.write(0); data.write(8); data.write(1); data.write(9); data.write(10); data.write(12); data.write("Hello World!".getBytes(CHARSET_US_ASCII)); SubmitSm submitSm = decomposer.submitSm(data.toByteArray()); assertEquals(submitSm.getCommandLength(), data.size()); assertEquals(submitSm.getCommandLength(), 70); assertEquals(submitSm.getCommandId(), 4); assertEquals(submitSm.getCommandStatus(), 0); assertEquals(submitSm.getSequenceNumber(), 0x1234); assertEquals(submitSm.getServiceType(), "CMT"); assertEquals(submitSm.getSourceAddrTon(), (byte) 0x01); assertEquals(submitSm.getSourceAddrNpi(), (byte) 0x02); assertEquals(submitSm.getSourceAddr(), "31600000000"); assertEquals(submitSm.getDestAddrTon(), (byte) 0x03); assertEquals(submitSm.getDestAddrNpi(), (byte) 0x04); assertEquals(submitSm.getDestAddress(), "31612345678"); assertEquals(submitSm.getEsmClass(), (byte) 0x05); assertEquals(submitSm.getProtocolId(), (byte) 0x06); assertEquals(submitSm.getPriorityFlag(), (byte) 0x07); assertNull(submitSm.getScheduleDeliveryTime()); assertNull(submitSm.getValidityPeriod()); assertEquals(submitSm.getRegisteredDelivery(), (byte) 0x08); assertEquals(submitSm.getReplaceIfPresent(), (byte) 0x01); assertEquals(submitSm.getDataCoding(), (byte) 0x09); assertEquals(submitSm.getSmDefaultMsgId(), (byte) 0x0a); assertEquals(new String(submitSm.getShortMessage(), CHARSET_US_ASCII), "Hello World!"); }
public SubmitSm submitSm(byte[] b) throws PDUStringException { SubmitSm req = new SubmitSm(); SequentialBytesReader reader = new SequentialBytesReader(b); assignHeader(req, reader); req.setServiceType(reader.readCString()); StringValidator.validateString(req.getServiceType(), StringParameter.SERVICE_TYPE); req.setSourceAddrTon(reader.readByte()); req.setSourceAddrNpi(reader.readByte()); req.setSourceAddr(reader.readCString()); StringValidator.validateString(req.getSourceAddr(), StringParameter.SOURCE_ADDR); req.setDestAddrTon(reader.readByte()); req.setDestAddrNpi(reader.readByte()); req.setDestAddress(reader.readCString()); StringValidator.validateString(req.getDestAddress(), StringParameter.DESTINATION_ADDR); req.setEsmClass(reader.readByte()); req.setProtocolId(reader.readByte()); req.setPriorityFlag(reader.readByte()); req.setScheduleDeliveryTime(reader.readCString()); StringValidator.validateString(req.getScheduleDeliveryTime(), StringParameter.SCHEDULE_DELIVERY_TIME); req.setValidityPeriod(reader.readCString()); StringValidator.validateString(req.getValidityPeriod(), StringParameter.VALIDITY_PERIOD); req.setRegisteredDelivery(reader.readByte()); req.setReplaceIfPresent(reader.readByte()); req.setDataCoding(reader.readByte()); req.setSmDefaultMsgId(reader.readByte()); byte smLength = reader.readByte(); req.setShortMessage(reader.readBytes(smLength)); StringValidator.validateString(req.getShortMessage(), StringParameter.SHORT_MESSAGE); req.setOptionalParameters(readOptionalParameters(reader)); return req; }
DefaultDecomposer implements PDUDecomposer { public SubmitSm submitSm(byte[] b) throws PDUStringException { SubmitSm req = new SubmitSm(); SequentialBytesReader reader = new SequentialBytesReader(b); assignHeader(req, reader); req.setServiceType(reader.readCString()); StringValidator.validateString(req.getServiceType(), StringParameter.SERVICE_TYPE); req.setSourceAddrTon(reader.readByte()); req.setSourceAddrNpi(reader.readByte()); req.setSourceAddr(reader.readCString()); StringValidator.validateString(req.getSourceAddr(), StringParameter.SOURCE_ADDR); req.setDestAddrTon(reader.readByte()); req.setDestAddrNpi(reader.readByte()); req.setDestAddress(reader.readCString()); StringValidator.validateString(req.getDestAddress(), StringParameter.DESTINATION_ADDR); req.setEsmClass(reader.readByte()); req.setProtocolId(reader.readByte()); req.setPriorityFlag(reader.readByte()); req.setScheduleDeliveryTime(reader.readCString()); StringValidator.validateString(req.getScheduleDeliveryTime(), StringParameter.SCHEDULE_DELIVERY_TIME); req.setValidityPeriod(reader.readCString()); StringValidator.validateString(req.getValidityPeriod(), StringParameter.VALIDITY_PERIOD); req.setRegisteredDelivery(reader.readByte()); req.setReplaceIfPresent(reader.readByte()); req.setDataCoding(reader.readByte()); req.setSmDefaultMsgId(reader.readByte()); byte smLength = reader.readByte(); req.setShortMessage(reader.readBytes(smLength)); StringValidator.validateString(req.getShortMessage(), StringParameter.SHORT_MESSAGE); req.setOptionalParameters(readOptionalParameters(reader)); return req; } }
DefaultDecomposer implements PDUDecomposer { public SubmitSm submitSm(byte[] b) throws PDUStringException { SubmitSm req = new SubmitSm(); SequentialBytesReader reader = new SequentialBytesReader(b); assignHeader(req, reader); req.setServiceType(reader.readCString()); StringValidator.validateString(req.getServiceType(), StringParameter.SERVICE_TYPE); req.setSourceAddrTon(reader.readByte()); req.setSourceAddrNpi(reader.readByte()); req.setSourceAddr(reader.readCString()); StringValidator.validateString(req.getSourceAddr(), StringParameter.SOURCE_ADDR); req.setDestAddrTon(reader.readByte()); req.setDestAddrNpi(reader.readByte()); req.setDestAddress(reader.readCString()); StringValidator.validateString(req.getDestAddress(), StringParameter.DESTINATION_ADDR); req.setEsmClass(reader.readByte()); req.setProtocolId(reader.readByte()); req.setPriorityFlag(reader.readByte()); req.setScheduleDeliveryTime(reader.readCString()); StringValidator.validateString(req.getScheduleDeliveryTime(), StringParameter.SCHEDULE_DELIVERY_TIME); req.setValidityPeriod(reader.readCString()); StringValidator.validateString(req.getValidityPeriod(), StringParameter.VALIDITY_PERIOD); req.setRegisteredDelivery(reader.readByte()); req.setReplaceIfPresent(reader.readByte()); req.setDataCoding(reader.readByte()); req.setSmDefaultMsgId(reader.readByte()); byte smLength = reader.readByte(); req.setShortMessage(reader.readBytes(smLength)); StringValidator.validateString(req.getShortMessage(), StringParameter.SHORT_MESSAGE); req.setOptionalParameters(readOptionalParameters(reader)); return req; } DefaultDecomposer(); }
DefaultDecomposer implements PDUDecomposer { public SubmitSm submitSm(byte[] b) throws PDUStringException { SubmitSm req = new SubmitSm(); SequentialBytesReader reader = new SequentialBytesReader(b); assignHeader(req, reader); req.setServiceType(reader.readCString()); StringValidator.validateString(req.getServiceType(), StringParameter.SERVICE_TYPE); req.setSourceAddrTon(reader.readByte()); req.setSourceAddrNpi(reader.readByte()); req.setSourceAddr(reader.readCString()); StringValidator.validateString(req.getSourceAddr(), StringParameter.SOURCE_ADDR); req.setDestAddrTon(reader.readByte()); req.setDestAddrNpi(reader.readByte()); req.setDestAddress(reader.readCString()); StringValidator.validateString(req.getDestAddress(), StringParameter.DESTINATION_ADDR); req.setEsmClass(reader.readByte()); req.setProtocolId(reader.readByte()); req.setPriorityFlag(reader.readByte()); req.setScheduleDeliveryTime(reader.readCString()); StringValidator.validateString(req.getScheduleDeliveryTime(), StringParameter.SCHEDULE_DELIVERY_TIME); req.setValidityPeriod(reader.readCString()); StringValidator.validateString(req.getValidityPeriod(), StringParameter.VALIDITY_PERIOD); req.setRegisteredDelivery(reader.readByte()); req.setReplaceIfPresent(reader.readByte()); req.setDataCoding(reader.readByte()); req.setSmDefaultMsgId(reader.readByte()); byte smLength = reader.readByte(); req.setShortMessage(reader.readBytes(smLength)); StringValidator.validateString(req.getShortMessage(), StringParameter.SHORT_MESSAGE); req.setOptionalParameters(readOptionalParameters(reader)); return req; } DefaultDecomposer(); static final PDUDecomposer getInstance(); Command header(byte[] b); Bind bind(byte[] b); BindResp bindResp(byte[] b); Unbind unbind(byte[] b); UnbindResp unbindResp(byte[] b); Outbind outbind(byte[] b); EnquireLink enquireLink(byte[] b); EnquireLinkResp enquireLinkResp(byte[] b); GenericNack genericNack(byte[] b); SubmitSm submitSm(byte[] b); SubmitSmResp submitSmResp(byte[] b); QuerySm querySm(byte[] b); QuerySmResp querySmResp(byte[] b); DeliverSm deliverSm(byte[] b); DeliverSmResp deliverSmResp(byte[] b); DeliveryReceipt deliveryReceipt(String data); DeliveryReceipt deliveryReceipt(byte[] data); DataSm dataSm(byte[] data); DataSmResp dataSmResp(byte[] data); CancelSm cancelSm(byte[] data); CancelSmResp cancelSmResp(byte[] data); SubmitMulti submitMulti(byte[] data); SubmitMultiResp submitMultiResp(byte[] data); ReplaceSm replaceSm(byte[] data); ReplaceSmResp replaceSmResp(byte[] data); AlertNotification alertNotification(byte[] data); }
DefaultDecomposer implements PDUDecomposer { public SubmitSm submitSm(byte[] b) throws PDUStringException { SubmitSm req = new SubmitSm(); SequentialBytesReader reader = new SequentialBytesReader(b); assignHeader(req, reader); req.setServiceType(reader.readCString()); StringValidator.validateString(req.getServiceType(), StringParameter.SERVICE_TYPE); req.setSourceAddrTon(reader.readByte()); req.setSourceAddrNpi(reader.readByte()); req.setSourceAddr(reader.readCString()); StringValidator.validateString(req.getSourceAddr(), StringParameter.SOURCE_ADDR); req.setDestAddrTon(reader.readByte()); req.setDestAddrNpi(reader.readByte()); req.setDestAddress(reader.readCString()); StringValidator.validateString(req.getDestAddress(), StringParameter.DESTINATION_ADDR); req.setEsmClass(reader.readByte()); req.setProtocolId(reader.readByte()); req.setPriorityFlag(reader.readByte()); req.setScheduleDeliveryTime(reader.readCString()); StringValidator.validateString(req.getScheduleDeliveryTime(), StringParameter.SCHEDULE_DELIVERY_TIME); req.setValidityPeriod(reader.readCString()); StringValidator.validateString(req.getValidityPeriod(), StringParameter.VALIDITY_PERIOD); req.setRegisteredDelivery(reader.readByte()); req.setReplaceIfPresent(reader.readByte()); req.setDataCoding(reader.readByte()); req.setSmDefaultMsgId(reader.readByte()); byte smLength = reader.readByte(); req.setShortMessage(reader.readBytes(smLength)); StringValidator.validateString(req.getShortMessage(), StringParameter.SHORT_MESSAGE); req.setOptionalParameters(readOptionalParameters(reader)); return req; } DefaultDecomposer(); static final PDUDecomposer getInstance(); Command header(byte[] b); Bind bind(byte[] b); BindResp bindResp(byte[] b); Unbind unbind(byte[] b); UnbindResp unbindResp(byte[] b); Outbind outbind(byte[] b); EnquireLink enquireLink(byte[] b); EnquireLinkResp enquireLinkResp(byte[] b); GenericNack genericNack(byte[] b); SubmitSm submitSm(byte[] b); SubmitSmResp submitSmResp(byte[] b); QuerySm querySm(byte[] b); QuerySmResp querySmResp(byte[] b); DeliverSm deliverSm(byte[] b); DeliverSmResp deliverSmResp(byte[] b); DeliveryReceipt deliveryReceipt(String data); DeliveryReceipt deliveryReceipt(byte[] data); DataSm dataSm(byte[] data); DataSmResp dataSmResp(byte[] data); CancelSm cancelSm(byte[] data); CancelSmResp cancelSmResp(byte[] data); SubmitMulti submitMulti(byte[] data); SubmitMultiResp submitMultiResp(byte[] data); ReplaceSm replaceSm(byte[] data); ReplaceSmResp replaceSmResp(byte[] data); AlertNotification alertNotification(byte[] data);  }