Eliminating BaseFrame copy constructors and methods, fixing PongFrame(PingFrame) constructor

This commit is contained in:
Joakim Erdfelt 2012-06-19 12:28:51 -07:00
parent 9178bce643
commit 17a7b12df1
6 changed files with 7 additions and 65 deletions

View File

@ -44,15 +44,6 @@ public class BaseFrame
reset();
}
/**
* Copy Constructor
* @param copy the copy
*/
public BaseFrame(BaseFrame copy) {
this();
copy(copy);
}
/**
* Construct form opcode
*/
@ -61,27 +52,6 @@ public class BaseFrame
this.opcode = opcode;
}
/**
* Copy the baseframe values
*
* @param copy
*/
public void copy(BaseFrame copy) {
this.fin = copy.fin;
this.rsv1 = copy.rsv1;
this.rsv2 = copy.rsv2;
this.rsv3 = copy.rsv3;
this.opcode = copy.opcode;
this.masked = copy.masked;
this.payloadLength = copy.payloadLength;
if (copy.mask != null)
{
int mlen = copy.mask.length;
this.mask = new byte[mlen];
System.arraycopy(copy.mask,0,this.mask,0,mlen);
}
}
public byte[] getMask()
{
if (!masked)

View File

@ -19,20 +19,6 @@ public class BinaryFrame extends DataFrame
super(OpCode.BINARY);
}
/**
* Copy Constructor
*
* @param base
* the base frame to work off of.
*/
public BinaryFrame(BaseFrame base)
{
super(base);
// TODO: limit this somehow?
// TODO: create a streaming binary frame?
data = ByteBuffer.allocate(base.getPayloadLength());
}
/**
* Get the data
*

View File

@ -13,11 +13,6 @@ public abstract class ControlFrame extends BaseFrame
super();
}
public ControlFrame(BaseFrame copy)
{
super(copy);
}
public ControlFrame(OpCode opcode)
{
super(opcode);

View File

@ -9,11 +9,6 @@ public abstract class DataFrame extends BaseFrame
super();
}
public DataFrame(BaseFrame copy)
{
super(copy);
}
public DataFrame(OpCode opcode)
{
super(opcode);

View File

@ -35,6 +35,13 @@ public class PongFrame extends ControlFrame
public PongFrame(PingFrame ping)
{
this();
if (ping.isMasked())
{
int mlen = ping.getMask().length;
byte maskCopy[] = new byte[mlen];
System.arraycopy(ping.getMask(),0,maskCopy,0,mlen);
this.setMask(maskCopy);
}
setPayload(ping.getPayload());
}

View File

@ -17,17 +17,6 @@ public class TextFrame extends DataFrame
super(OpCode.TEXT);
}
/**
* Copy Constructor
*
* @param base
* the base frame to work off of.
*/
public TextFrame(BaseFrame copy)
{
super(copy);
}
/**
* Get the data
*