tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 1 | // Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University |
| 2 | // Copyright (c) 2011, 2012 Open Networking Foundation |
| 3 | // Copyright (c) 2012, 2013 Big Switch Networks, Inc. |
| 4 | // This library was generated by the LoxiGen Compiler. |
| 5 | // See the file LICENSE.txt which should have been included in the source distribution |
| 6 | |
| 7 | // Automatically generated by LOXI from template const_serializer.java |
| 8 | // Do not modify |
| 9 | |
| 10 | package org.projectfloodlight.openflow.protocol.ver13; |
| 11 | |
| 12 | import org.projectfloodlight.openflow.protocol.*; |
| 13 | import org.projectfloodlight.openflow.protocol.action.*; |
| 14 | import org.projectfloodlight.openflow.protocol.actionid.*; |
| 15 | import org.projectfloodlight.openflow.protocol.bsntlv.*; |
| 16 | import org.projectfloodlight.openflow.protocol.errormsg.*; |
| 17 | import org.projectfloodlight.openflow.protocol.meterband.*; |
| 18 | import org.projectfloodlight.openflow.protocol.instruction.*; |
| 19 | import org.projectfloodlight.openflow.protocol.instructionid.*; |
| 20 | import org.projectfloodlight.openflow.protocol.match.*; |
| 21 | import org.projectfloodlight.openflow.protocol.oxm.*; |
| 22 | import org.projectfloodlight.openflow.protocol.queueprop.*; |
| 23 | import org.projectfloodlight.openflow.types.*; |
| 24 | import org.projectfloodlight.openflow.util.*; |
| 25 | import org.projectfloodlight.openflow.exceptions.*; |
| 26 | import org.projectfloodlight.openflow.protocol.OFBsnLoglevel; |
| 27 | import org.jboss.netty.buffer.ChannelBuffer; |
| 28 | import com.google.common.hash.PrimitiveSink; |
| 29 | |
| 30 | public class OFBsnLoglevelSerializerVer13 { |
| 31 | |
| 32 | public final static byte BSN_LOGLEVEL_MSG_VAL = (byte) 0x0; |
| 33 | public final static byte BSN_LOGLEVEL_ERROR_VAL = (byte) 0x1; |
| 34 | public final static byte BSN_LOGLEVEL_WARN_VAL = (byte) 0x2; |
| 35 | public final static byte BSN_LOGLEVEL_INFO_VAL = (byte) 0x3; |
| 36 | public final static byte BSN_LOGLEVEL_VERBOSE_VAL = (byte) 0x4; |
| 37 | public final static byte BSN_LOGLEVEL_TRACE_VAL = (byte) 0x5; |
| 38 | |
| 39 | public static OFBsnLoglevel readFrom(ChannelBuffer bb) throws OFParseError { |
| 40 | try { |
| 41 | return ofWireValue(bb.readByte()); |
| 42 | } catch (IllegalArgumentException e) { |
| 43 | throw new OFParseError(e); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | public static void writeTo(ChannelBuffer bb, OFBsnLoglevel e) { |
| 48 | bb.writeByte(toWireValue(e)); |
| 49 | } |
| 50 | |
| 51 | public static void putTo(OFBsnLoglevel e, PrimitiveSink sink) { |
| 52 | sink.putByte(toWireValue(e)); |
| 53 | } |
| 54 | |
| 55 | public static OFBsnLoglevel ofWireValue(byte val) { |
| 56 | switch(val) { |
| 57 | case BSN_LOGLEVEL_MSG_VAL: |
| 58 | return OFBsnLoglevel.BSN_LOGLEVEL_MSG; |
| 59 | case BSN_LOGLEVEL_ERROR_VAL: |
| 60 | return OFBsnLoglevel.BSN_LOGLEVEL_ERROR; |
| 61 | case BSN_LOGLEVEL_WARN_VAL: |
| 62 | return OFBsnLoglevel.BSN_LOGLEVEL_WARN; |
| 63 | case BSN_LOGLEVEL_INFO_VAL: |
| 64 | return OFBsnLoglevel.BSN_LOGLEVEL_INFO; |
| 65 | case BSN_LOGLEVEL_VERBOSE_VAL: |
| 66 | return OFBsnLoglevel.BSN_LOGLEVEL_VERBOSE; |
| 67 | case BSN_LOGLEVEL_TRACE_VAL: |
| 68 | return OFBsnLoglevel.BSN_LOGLEVEL_TRACE; |
| 69 | default: |
| 70 | throw new IllegalArgumentException("Illegal wire value for type OFBsnLoglevel in version 1.3: " + val); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | |
| 75 | public static byte toWireValue(OFBsnLoglevel e) { |
| 76 | switch(e) { |
| 77 | case BSN_LOGLEVEL_MSG: |
| 78 | return BSN_LOGLEVEL_MSG_VAL; |
| 79 | case BSN_LOGLEVEL_ERROR: |
| 80 | return BSN_LOGLEVEL_ERROR_VAL; |
| 81 | case BSN_LOGLEVEL_WARN: |
| 82 | return BSN_LOGLEVEL_WARN_VAL; |
| 83 | case BSN_LOGLEVEL_INFO: |
| 84 | return BSN_LOGLEVEL_INFO_VAL; |
| 85 | case BSN_LOGLEVEL_VERBOSE: |
| 86 | return BSN_LOGLEVEL_VERBOSE_VAL; |
| 87 | case BSN_LOGLEVEL_TRACE: |
| 88 | return BSN_LOGLEVEL_TRACE_VAL; |
| 89 | default: |
| 90 | throw new IllegalArgumentException("Illegal enum value for type OFBsnLoglevel in version 1.3: " + e); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | } |