View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 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.jsr356.metadata;
20  
21  import javax.websocket.Decoder;
22  
23  import org.eclipse.jetty.websocket.jsr356.MessageType;
24  
25  /**
26   * The immutable base metadata for a coder ({@link Decoder} or {@link Encoder}
27   * 
28   * @param <T>
29   *            the specific type of coder ({@link Decoder} or {@link Encoder}
30   */
31  public abstract class CoderMetadata<T>
32  {
33      /** The class for the Coder */
34      private final Class<? extends T> coderClass;
35      /** The Class that the Decoder declares it decodes */
36      private final Class<?> objType;
37      /** The Basic type of message the decoder handles */
38      private final MessageType messageType;
39      /** Flag indicating if Decoder is for streaming (or not) */
40      private final boolean streamed;
41  
42      public CoderMetadata(Class<? extends T> coderClass, Class<?> objType, MessageType messageType, boolean streamed)
43      {
44          this.objType = objType;
45          this.coderClass = coderClass;
46          this.messageType = messageType;
47          this.streamed = streamed;
48      }
49  
50      public Class<? extends T> getCoderClass()
51      {
52          return this.coderClass;
53      }
54  
55      public MessageType getMessageType()
56      {
57          return messageType;
58      }
59  
60      public Class<?> getObjectType()
61      {
62          return objType;
63      }
64  
65      public boolean isStreamed()
66      {
67          return streamed;
68      }
69  }