public class DefaultWebSocketFrame extends java.lang.Object implements WebSocketFrame
WebSocketFrame
implementation.WebSocketFrame.FrameType
Constructor and Description |
---|
DefaultWebSocketFrame()
Creates a new empty text frame.
|
DefaultWebSocketFrame(java.lang.String textData)
Creates a new text frame from with the specified string.
|
DefaultWebSocketFrame(WebSocketFrame.FrameType frameType) |
DefaultWebSocketFrame(WebSocketFrame.FrameType type,
org.jboss.netty.buffer.ChannelBuffer binaryData)
Creates a new frame with the specified frame type and the specified data.
|
Modifier and Type | Method and Description |
---|---|
org.jboss.netty.buffer.ChannelBuffer |
getBinaryData()
Returns the content of this frame as-is, with no UTF-8 decoding.
|
java.lang.String |
getTextData()
Converts the content of this frame into a UTF-8 string and returns the
converted string.
|
WebSocketFrame.FrameType |
getType() |
boolean |
isBinary()
Returns
true if and only if the content of this frame is an
arbitrary binary data. |
boolean |
isText()
Returns
true if and only if the content of this frame is a string
encoded in UTF-8. |
void |
setBinaryData(org.jboss.netty.buffer.ChannelBuffer binaryData)
Sets the type and the content of this frame.
|
void |
setTextData(java.lang.String textData) |
java.lang.String |
toString()
Returns the string representation of this frame.
|
public DefaultWebSocketFrame()
public DefaultWebSocketFrame(WebSocketFrame.FrameType frameType)
public DefaultWebSocketFrame(java.lang.String textData)
public DefaultWebSocketFrame(WebSocketFrame.FrameType type, org.jboss.netty.buffer.ChannelBuffer binaryData)
type
- the type of the frame. 0
is the only allowed type currently.binaryData
- the content of the frame. If (type & 0x80 == 0),
it must be encoded in UTF-8.java.lang.IllegalArgumentException
- if If (type & 0x80 == 0) and the data is not encoded
in UTF-8public WebSocketFrame.FrameType getType()
getType
in interface WebSocketFrame
public boolean isText()
WebSocketFrame
true
if and only if the content of this frame is a string
encoded in UTF-8.isText
in interface WebSocketFrame
public boolean isBinary()
WebSocketFrame
true
if and only if the content of this frame is an
arbitrary binary data.isBinary
in interface WebSocketFrame
public org.jboss.netty.buffer.ChannelBuffer getBinaryData()
WebSocketFrame
getBinaryData
in interface WebSocketFrame
public java.lang.String getTextData()
WebSocketFrame
getTextData
in interface WebSocketFrame
public void setBinaryData(org.jboss.netty.buffer.ChannelBuffer binaryData)
WebSocketFrame
setBinaryData
in interface WebSocketFrame
binaryData
- the content of the frame. If (type & 0x80 == 0),
it must be encoded in UTF-8.public void setTextData(java.lang.String textData)
setTextData
in interface WebSocketFrame
public java.lang.String toString()
WebSocketFrame
WebSocketFrame.getTextData()
.toString
in interface WebSocketFrame
toString
in class java.lang.Object