@Test public void decompose_replace_sm() throws Exception { ByteArrayOutputStream data = new ByteArrayOutputStream(); data.write(new byte[]{ 0x00, 0x00, 0x00, 0x54 }); data.write(new byte[]{ 0x00, 0x00, 0x00, 0x07 }); data.write(new byte[]{ 0x00, 0x00, 0x00, 0x00 }); data.write(new byte[]{ 0x00, 0x00, 0x12, 0x34 }); data.write("32f53129-6a87-422c-8954-145f603582ed\000".getBytes(CHARSET_US_ASCII)); data.write(1); data.write(2); data.write("31612345678\000".getBytes(CHARSET_US_ASCII)); data.write(0); data.write(0); data.write(4); data.write(5); data.write(12); data.write("Hello World!".getBytes(CHARSET_US_ASCII)); ReplaceSm replaceSm = decomposer.replaceSm(data.toByteArray()); assertEquals(replaceSm.getCommandLength(), 84); assertEquals(replaceSm.getCommandId(), 7); assertEquals(replaceSm.getCommandStatus(), 0); assertEquals(replaceSm.getSequenceNumber(), 0x1234); assertEquals(replaceSm.getMessageId(), "32f53129-6a87-422c-8954-145f603582ed"); assertEquals(replaceSm.getSourceAddrTon(), (byte) 0x01); assertEquals(replaceSm.getSourceAddrNpi(), (byte) 0x02); assertEquals(replaceSm.getSourceAddr(), "31612345678"); assertNull(replaceSm.getScheduleDeliveryTime()); assertNull(replaceSm.getValidityPeriod()); assertEquals(replaceSm.getRegisteredDelivery(), (byte) 0x04); assertEquals(replaceSm.getSmDefaultMsgId(), (byte) 0x05); assertEquals(new String(replaceSm.getShortMessage(), CHARSET_US_ASCII), "Hello World!"); }
public ReplaceSm replaceSm(byte[] data) throws PDUStringException { ReplaceSm req = new ReplaceSm(); SequentialBytesReader reader = new SequentialBytesReader(data); assignHeader(req, reader); req.setMessageId(reader.readCString()); StringValidator.validateString(req.getMessageId(), StringParameter.MESSAGE_ID); req.setSourceAddrTon(reader.readByte()); req.setSourceAddrNpi(reader.readByte()); req.setSourceAddr(reader.readCString()); StringValidator.validateString(req.getSourceAddr(), StringParameter.SOURCE_ADDR); 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.setSmDefaultMsgId(reader.readByte()); byte smLength = reader.readByte(); req.setShortMessage(reader.readBytes(smLength)); StringValidator.validateString(req.getShortMessage(), StringParameter.SHORT_MESSAGE); return req; }
DefaultDecomposer implements PDUDecomposer { public ReplaceSm replaceSm(byte[] data) throws PDUStringException { ReplaceSm req = new ReplaceSm(); SequentialBytesReader reader = new SequentialBytesReader(data); assignHeader(req, reader); req.setMessageId(reader.readCString()); StringValidator.validateString(req.getMessageId(), StringParameter.MESSAGE_ID); req.setSourceAddrTon(reader.readByte()); req.setSourceAddrNpi(reader.readByte()); req.setSourceAddr(reader.readCString()); StringValidator.validateString(req.getSourceAddr(), StringParameter.SOURCE_ADDR); 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.setSmDefaultMsgId(reader.readByte()); byte smLength = reader.readByte(); req.setShortMessage(reader.readBytes(smLength)); StringValidator.validateString(req.getShortMessage(), StringParameter.SHORT_MESSAGE); return req; } }
DefaultDecomposer implements PDUDecomposer { public ReplaceSm replaceSm(byte[] data) throws PDUStringException { ReplaceSm req = new ReplaceSm(); SequentialBytesReader reader = new SequentialBytesReader(data); assignHeader(req, reader); req.setMessageId(reader.readCString()); StringValidator.validateString(req.getMessageId(), StringParameter.MESSAGE_ID); req.setSourceAddrTon(reader.readByte()); req.setSourceAddrNpi(reader.readByte()); req.setSourceAddr(reader.readCString()); StringValidator.validateString(req.getSourceAddr(), StringParameter.SOURCE_ADDR); 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.setSmDefaultMsgId(reader.readByte()); byte smLength = reader.readByte(); req.setShortMessage(reader.readBytes(smLength)); StringValidator.validateString(req.getShortMessage(), StringParameter.SHORT_MESSAGE); return req; } DefaultDecomposer(); }
DefaultDecomposer implements PDUDecomposer { public ReplaceSm replaceSm(byte[] data) throws PDUStringException { ReplaceSm req = new ReplaceSm(); SequentialBytesReader reader = new SequentialBytesReader(data); assignHeader(req, reader); req.setMessageId(reader.readCString()); StringValidator.validateString(req.getMessageId(), StringParameter.MESSAGE_ID); req.setSourceAddrTon(reader.readByte()); req.setSourceAddrNpi(reader.readByte()); req.setSourceAddr(reader.readCString()); StringValidator.validateString(req.getSourceAddr(), StringParameter.SOURCE_ADDR); 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.setSmDefaultMsgId(reader.readByte()); byte smLength = reader.readByte(); req.setShortMessage(reader.readBytes(smLength)); StringValidator.validateString(req.getShortMessage(), StringParameter.SHORT_MESSAGE); 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 ReplaceSm replaceSm(byte[] data) throws PDUStringException { ReplaceSm req = new ReplaceSm(); SequentialBytesReader reader = new SequentialBytesReader(data); assignHeader(req, reader); req.setMessageId(reader.readCString()); StringValidator.validateString(req.getMessageId(), StringParameter.MESSAGE_ID); req.setSourceAddrTon(reader.readByte()); req.setSourceAddrNpi(reader.readByte()); req.setSourceAddr(reader.readCString()); StringValidator.validateString(req.getSourceAddr(), StringParameter.SOURCE_ADDR); 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.setSmDefaultMsgId(reader.readByte()); byte smLength = reader.readByte(); req.setShortMessage(reader.readBytes(smLength)); StringValidator.validateString(req.getShortMessage(), StringParameter.SHORT_MESSAGE); 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);  }