/** * Creates a new empty text frame. */ public TextWebSocketFrame() { setBinaryData(ChannelBuffers.EMPTY_BUFFER); }
/** * Creates a new text frame with the specified binary data. The final fragment flag is set to true. * * @param binaryData * the content of the frame. Must be UTF-8 encoded */ public TextWebSocketFrame(ChannelBuffer binaryData) { setBinaryData(binaryData); }
/** * Creates a new text frame with the specified text string. The final fragment flag is set to true. * * @param text * String to put in the frame */ public TextWebSocketFrame(String text) { if (text == null || text.length() == 0) { setBinaryData(ChannelBuffers.EMPTY_BUFFER); } else { setBinaryData(ChannelBuffers.copiedBuffer(text, CharsetUtil.UTF_8)); } }
/** * Sets the string for this frame * * @param text * text to store */ public void setText(String text) { if (text == null) { throw new NullPointerException("text"); } setBinaryData(ChannelBuffers.copiedBuffer(text, CharsetUtil.UTF_8)); }
/** * Creates a new text frame with the specified text string. The final fragment flag is set to true. * * @param finalFragment * flag indicating if this frame is the final fragment * @param rsv * reserved bits used for protocol extensions * @param text * String to put in the frame */ public TextWebSocketFrame(boolean finalFragment, int rsv, String text) { setFinalFragment(finalFragment); setRsv(rsv); if (text == null || text.length() == 0) { setBinaryData(ChannelBuffers.EMPTY_BUFFER); } else { setBinaryData(ChannelBuffers.copiedBuffer(text, CharsetUtil.UTF_8)); } }
/** * Creates a new text frame with the specified binary data. The final fragment flag is set to true. * * @param finalFragment * flag indicating if this frame is the final fragment * @param rsv * reserved bits used for protocol extensions * @param binaryData * the content of the frame. Must be UTF-8 encoded */ public TextWebSocketFrame(boolean finalFragment, int rsv, ChannelBuffer binaryData) { setFinalFragment(finalFragment); setRsv(rsv); setBinaryData(binaryData); }