org.jboss.netty.handler.codec.http.websocket
Class DefaultWebSocketFrame

java.lang.Object
  extended by org.jboss.netty.handler.codec.http.websocket.DefaultWebSocketFrame
All Implemented Interfaces:
WebSocketFrame

public class DefaultWebSocketFrame
extends Object
implements WebSocketFrame

The default WebSocketFrame implementation.

Version:
$Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
Author:
The Netty Project, Trustin Lee

Field Summary
 
Fields inherited from interface org.jboss.netty.handler.codec.http.websocket.WebSocketFrame
CLOSING_HANDSHAKE
 
Constructor Summary
DefaultWebSocketFrame()
          Creates a new empty text frame.
DefaultWebSocketFrame(int type, ChannelBuffer binaryData)
          Creates a new frame with the specified frame type and the specified data.
DefaultWebSocketFrame(String textData)
          Creates a new text frame from with the specified string.
 
Method Summary
 ChannelBuffer getBinaryData()
          Returns the content of this frame as-is, with no UTF-8 decoding.
 String getTextData()
          Converts the content of this frame into a UTF-8 string and returns the converted string.
 int getType()
          Returns the type of this frame.
 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 setData(int type, ChannelBuffer binaryData)
          Sets the type and the content of this frame.
 String toString()
          Returns the string representation of this frame.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultWebSocketFrame

public DefaultWebSocketFrame()
Creates a new empty text frame.


DefaultWebSocketFrame

public DefaultWebSocketFrame(String textData)
Creates a new text frame from with the specified string.


DefaultWebSocketFrame

public DefaultWebSocketFrame(int type,
                             ChannelBuffer binaryData)
Creates a new frame with the specified frame type and the specified data.

Parameters:
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.
Throws:
IllegalArgumentException - if If (type & 0x80 == 0) and the data is not encoded in UTF-8
Method Detail

getType

public int getType()
Description copied from interface: WebSocketFrame
Returns the type of this frame. 0x00-0x7F means a text frame encoded in UTF-8, and 0x80-0xFF means a binary frame. Currently, 0 is the only allowed type according to the specification.

Specified by:
getType in interface WebSocketFrame

isText

public boolean isText()
Description copied from interface: WebSocketFrame
Returns true if and only if the content of this frame is a string encoded in UTF-8.

Specified by:
isText in interface WebSocketFrame

isBinary

public boolean isBinary()
Description copied from interface: WebSocketFrame
Returns true if and only if the content of this frame is an arbitrary binary data.

Specified by:
isBinary in interface WebSocketFrame

getBinaryData

public ChannelBuffer getBinaryData()
Description copied from interface: WebSocketFrame
Returns the content of this frame as-is, with no UTF-8 decoding.

Specified by:
getBinaryData in interface WebSocketFrame

getTextData

public String getTextData()
Description copied from interface: WebSocketFrame
Converts the content of this frame into a UTF-8 string and returns the converted string.

Specified by:
getTextData in interface WebSocketFrame

setData

public void setData(int type,
                    ChannelBuffer binaryData)
Description copied from interface: WebSocketFrame
Sets the type and the content of this frame.

Specified by:
setData in interface WebSocketFrame
Parameters:
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.

toString

public String toString()
Description copied from interface: WebSocketFrame
Returns the string representation of this frame. Please note that this method is not identical to WebSocketFrame.getTextData().

Specified by:
toString in interface WebSocketFrame
Overrides:
toString in class Object


Copyright © 2008-2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.