View Javadoc

1   /*
2    * Copyright 2012 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package org.jboss.netty.handler.codec.http.websocket;
17  
18  import org.jboss.netty.buffer.ChannelBuffer;
19  import org.jboss.netty.buffer.ChannelBuffers;
20  
21  /**
22   * @deprecated Use <tt>org.jboss.netty.handler.codec.http.websocketx</tt> instead.
23   *
24   * A Web Socket frame that represents either text or binary data.
25   */
26  @Deprecated
27  public interface WebSocketFrame {
28  
29      /**
30       * Closing handshake message (<tt>0xFF, 0x00</tt>)
31       */
32      WebSocketFrame CLOSING_HANDSHAKE = new DefaultWebSocketFrame(0xFF, ChannelBuffers.EMPTY_BUFFER);
33  
34      /**
35       * Returns the type of this frame.
36       * <tt>0x00-0x7F</tt> means a text frame encoded in UTF-8, and
37       * <tt>0x80-0xFF</tt> means a binary frame.  Currently, {@code 0} is the
38       * only allowed type according to the specification.
39       */
40      int getType();
41  
42      /**
43       * Returns {@code true} if and only if the content of this frame is a string
44       * encoded in UTF-8.
45       */
46      boolean isText();
47  
48      /**
49       * Returns {@code true} if and only if the content of this frame is an
50       * arbitrary binary data.
51       */
52      boolean isBinary();
53  
54      /**
55       * Returns the content of this frame as-is, with no UTF-8 decoding.
56       */
57      ChannelBuffer getBinaryData();
58  
59      /**
60       * Converts the content of this frame into a UTF-8 string and returns the
61       * converted string.
62       */
63      String getTextData();
64  
65      /**
66       * Sets the type and the content of this frame.
67       *
68       * @param type
69       *        the type of the frame. {@code 0} is the only allowed type currently.
70       * @param binaryData
71       *        the content of the frame.  If <tt>(type &amp; 0x80 == 0)</tt>,
72       *        it must be encoded in UTF-8.
73       *
74       * @throws IllegalArgumentException
75       *         if If <tt>(type &amp; 0x80 == 0)</tt> and the data is not encoded
76       *         in UTF-8
77       */
78      void setData(int type, ChannelBuffer binaryData);
79  
80      /**
81       * Returns the string representation of this frame.  Please note that this
82       * method is not identical to {@link #getTextData()}.
83       */
84      String toString();
85  }