com.sun.grizzly.websockets
Class DataFrame

java.lang.Object
  extended by com.sun.grizzly.websockets.DataFrame
Direct Known Subclasses:
ClosingFrame

public class DataFrame
extends Object

In memory representation of a websocket frame.

See Also:
Frame Definition

Constructor Summary
DataFrame()
           
DataFrame(byte[] data)
           
DataFrame(FrameType type)
           
DataFrame(FrameType type, byte[] bytes)
           
DataFrame(String data)
           
 
Method Summary
static long convert(byte[] bytes)
          Convert a byte[] to a long.
static long convert(byte[] bytes, int start, int end)
           
 byte[] convert(long length)
          Converts the length given to the appropriate framing data: 0-125 one element that is the payload length.
 byte[] frame()
           
 byte[] getBinaryPayload()
           
 String getTextPayload()
           
 FrameType getType()
           
 boolean isLast()
           
 void respond(WebSocket socket)
           
 void setLast(boolean last)
           
 void setPayload(byte[] bytes)
           
 void setPayload(String payload)
           
 void setType(FrameType type)
           
static byte[] toArray(long length)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataFrame

public DataFrame()

DataFrame

public DataFrame(FrameType type)

DataFrame

public DataFrame(String data)

DataFrame

public DataFrame(byte[] data)

DataFrame

public DataFrame(FrameType type,
                 byte[] bytes)
Method Detail

getType

public FrameType getType()

setType

public void setType(FrameType type)

getTextPayload

public String getTextPayload()

setPayload

public void setPayload(String payload)

setPayload

public void setPayload(byte[] bytes)

getBinaryPayload

public byte[] getBinaryPayload()

frame

public byte[] frame()

convert

public byte[] convert(long length)
Converts the length given to the appropriate framing data:
  1. 0-125 one element that is the payload length.
  2. up to 0xFFFF, 3 element array starting with 126 with the following 2 bytes interpreted as a 16 bit unsigned integer showing the payload length.
  3. else 9 element array starting with 127 with the following 8 bytes interpreted as a 64-bit unsigned integer (the high bit must be 0) showing the payload length.

Parameters:
length - the payload size
Returns:
the array

toArray

public static byte[] toArray(long length)

convert

public static long convert(byte[] bytes,
                           int start,
                           int end)

convert

public static long convert(byte[] bytes)
Convert a byte[] to a long. Used for rebuilding payload length.


respond

public void respond(WebSocket socket)

toString

public String toString()
Overrides:
toString in class Object

isLast

public boolean isLast()

setLast

public void setLast(boolean last)


Copyright © 2012 Oracle Corporation. All Rights Reserved.