1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.mina.session;
20
21 /**
22 * Define the list of Trafic Class available. They are used to define the ToS (Type Of Service)
23 *
24 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
25 */
26 public enum TrafficClassEnum {
27 IPTOS_DEFAULT(0x00), IPTOS_LOWCOST(0x02), IPTOS_RELIABILITY(0x04), IPTOS_THROUGHPUT(0x08), IPTOS_LOWDELAY(0x10);
28
29 /** The internal value */
30 private int value;
31
32 /**
33 * The private constructor
34 * @param value The interned value
35 */
36 private TrafficClassEnum(int value) {
37 this.value = value;
38 }
39
40 /**
41 * @return Get back the internal value
42 */
43 public int getValue() {
44 return value;
45 }
46
47 /**
48 * Get back the Enum value fro the integer value
49 * @param value The interger value we are looking for
50 * @return The Enum value
51 */
52 public static TrafficClassEnum valueOf(int value) {
53 switch (value) {
54 case 0x02:
55 return IPTOS_LOWCOST;
56
57 case 0x04:
58 return IPTOS_RELIABILITY;
59
60 case 0x08:
61 return IPTOS_THROUGHPUT;
62
63 case 0x10:
64 return IPTOS_LOWDELAY;
65
66 default:
67 return IPTOS_DEFAULT;
68 }
69 }
70 }