1 // 2 // ======================================================================== 3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. 4 // ------------------------------------------------------------------------ 5 // All rights reserved. This program and the accompanying materials 6 // are made available under the terms of the Eclipse Public License v1.0 7 // and Apache License v2.0 which accompanies this distribution. 8 // 9 // The Eclipse Public License is available at 10 // http://www.eclipse.org/legal/epl-v10.html 11 // 12 // The Apache License v2.0 is available at 13 // http://www.opensource.org/licenses/apache2.0.php 14 // 15 // You may elect to redistribute this code under either of these licenses. 16 // ======================================================================== 17 // 18 19 package org.eclipse.jetty.websocket.common.frames; 20 21 import org.eclipse.jetty.websocket.api.extensions.Frame; 22 import org.eclipse.jetty.websocket.common.OpCode; 23 import org.eclipse.jetty.websocket.common.WebSocketFrame; 24 25 /** 26 * A Data Frame 27 */ 28 public class DataFrame extends WebSocketFrame 29 { 30 protected DataFrame(byte opcode) 31 { 32 super(opcode); 33 } 34 35 /** 36 * Construct new DataFrame based on headers of provided frame. 37 * <p> 38 * Useful for when working in extensions and a new frame needs to be created. 39 */ 40 public DataFrame(Frame basedOn) 41 { 42 this(basedOn,false); 43 } 44 45 /** 46 * Construct new DataFrame based on headers of provided frame, overriding for continuations if needed. 47 * <p> 48 * Useful for when working in extensions and a new frame needs to be created. 49 */ 50 public DataFrame(Frame basedOn, boolean continuation) 51 { 52 super(basedOn.getOpCode()); 53 copyHeaders(basedOn); 54 if (continuation) 55 { 56 setOpCode(OpCode.CONTINUATION); 57 } 58 } 59 60 @Override 61 public void assertValid() 62 { 63 /* no extra validation for data frames (yet) here */ 64 } 65 66 @Override 67 public boolean isControlFrame() 68 { 69 return false; 70 } 71 72 @Override 73 public boolean isDataFrame() 74 { 75 return true; 76 } 77 78 /** 79 * Set the data frame to continuation mode 80 */ 81 public void setIsContinuation() 82 { 83 setOpCode(OpCode.CONTINUATION); 84 } 85 }