/** * Constructor. */ public Message() { initialize(); }
/** * Constructor. * @param stream A stream to provide the body of the new Message instance. */ public Message(ByteArrayInputStream stream) { initialize(); }
/** * Constructor. * @param body The body of the new Message instance. */ public Message(byte[] body) { // Codes_SRS_MESSAGE_11_025: [If the message body is null, the constructor shall throw an IllegalArgumentException.] if (body == null) { throw new IllegalArgumentException("Message body cannot be 'null'."); } initialize(); // Codes_SRS_MESSAGE_11_024: [The constructor shall save the message body.] this.body = body; }
/** * Constructor. * @param body The body of the new Message instance. It is internally serialized to a byte array using UTF-8 encoding. */ public Message(String body) { if (body == null) { throw new IllegalArgumentException("Message body cannot be 'null'."); } initialize(); this.body = body.getBytes(DEFAULT_IOTHUB_MESSAGE_CHARSET); this.setContentType(DEFAULT_IOTHUB_MESSAGE_CHARSET.name()); }