/** * Make the message. No need to check whether mandatory fields are set, because the constructors * of outgoing pdus are taking care of this. * * @return OutputStream of maked message. Return null if the PDU is invalid. */ public byte[] make() { // Get Message-type. int type = mPdu.getMessageType(); /* make the message */ switch (type) { case PduHeaders.MESSAGE_TYPE_SEND_REQ: if (makeSendReqPdu() != PDU_COMPOSE_SUCCESS) { return null; } break; case PduHeaders.MESSAGE_TYPE_NOTIFYRESP_IND: if (makeNotifyResp() != PDU_COMPOSE_SUCCESS) { return null; } break; case PduHeaders.MESSAGE_TYPE_ACKNOWLEDGE_IND: if (makeAckInd() != PDU_COMPOSE_SUCCESS) { return null; } break; case PduHeaders.MESSAGE_TYPE_READ_REC_IND: if (makeReadRecInd() != PDU_COMPOSE_SUCCESS) { return null; } break; default: return null; } return mMessage.toByteArray(); }
/** * Constructor. * * @param context the context * @param pdu the pdu to be composed */ public PduComposer(Context context, GenericPdu pdu) { mPdu = pdu; mResolver = context.getContentResolver(); mPduHeader = pdu.getPduHeaders(); mStack = new BufferStack(); mMessage = new ByteArrayOutputStream(); mPosition = 0; }