alshabib | 86ac11c | 2014-08-14 16:14:41 -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.ver11; |
| 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.OFFlowModCommand; |
| 27 | import org.jboss.netty.buffer.ChannelBuffer; |
| 28 | import com.google.common.hash.PrimitiveSink; |
| 29 | |
| 30 | public class OFFlowModCommandSerializerVer11 { |
| 31 | |
| 32 | public final static byte ADD_VAL = (byte) 0x0; |
| 33 | public final static byte MODIFY_VAL = (byte) 0x1; |
| 34 | public final static byte MODIFY_STRICT_VAL = (byte) 0x2; |
| 35 | public final static byte DELETE_VAL = (byte) 0x3; |
| 36 | public final static byte DELETE_STRICT_VAL = (byte) 0x4; |
| 37 | |
| 38 | public static OFFlowModCommand readFrom(ChannelBuffer bb) throws OFParseError { |
| 39 | try { |
| 40 | return ofWireValue(bb.readByte()); |
| 41 | } catch (IllegalArgumentException e) { |
| 42 | throw new OFParseError(e); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | public static void writeTo(ChannelBuffer bb, OFFlowModCommand e) { |
| 47 | bb.writeByte(toWireValue(e)); |
| 48 | } |
| 49 | |
| 50 | public static void putTo(OFFlowModCommand e, PrimitiveSink sink) { |
| 51 | sink.putByte(toWireValue(e)); |
| 52 | } |
| 53 | |
| 54 | public static OFFlowModCommand ofWireValue(byte val) { |
| 55 | switch(val) { |
| 56 | case ADD_VAL: |
| 57 | return OFFlowModCommand.ADD; |
| 58 | case MODIFY_VAL: |
| 59 | return OFFlowModCommand.MODIFY; |
| 60 | case MODIFY_STRICT_VAL: |
| 61 | return OFFlowModCommand.MODIFY_STRICT; |
| 62 | case DELETE_VAL: |
| 63 | return OFFlowModCommand.DELETE; |
| 64 | case DELETE_STRICT_VAL: |
| 65 | return OFFlowModCommand.DELETE_STRICT; |
| 66 | default: |
| 67 | throw new IllegalArgumentException("Illegal wire value for type OFFlowModCommand in version 1.1: " + val); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | |
| 72 | public static byte toWireValue(OFFlowModCommand e) { |
| 73 | switch(e) { |
| 74 | case ADD: |
| 75 | return ADD_VAL; |
| 76 | case MODIFY: |
| 77 | return MODIFY_VAL; |
| 78 | case MODIFY_STRICT: |
| 79 | return MODIFY_STRICT_VAL; |
| 80 | case DELETE: |
| 81 | return DELETE_VAL; |
| 82 | case DELETE_STRICT: |
| 83 | return DELETE_STRICT_VAL; |
| 84 | default: |
| 85 | throw new IllegalArgumentException("Illegal enum value for type OFFlowModCommand in version 1.1: " + e); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | } |