fde8713323fbfa251803ba1dac43e5b0dc086c0c
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / ExperimenterInputMessageFactory.java
1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
2 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
3 \r
4 import io.netty.buffer.ByteBuf;\r
5 \r
6 import org.opendaylight.openflowjava.protocol.impl.core.OFFrameDecoder;\r
7 import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
8 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;\r
9 \r
10 /**\r
11  * @author michal.polkorab\r
12  *\r
13  */\r
14 public class ExperimenterInputMessageFactory implements OFSerializer<ExperimenterInput>{\r
15 \r
16     /** Code type of Experimenter message */\r
17     public static final byte MESSAGE_TYPE = 4;\r
18     private static ExperimenterInputMessageFactory instance;\r
19     \r
20     private ExperimenterInputMessageFactory() {\r
21         // do nothing, just singleton\r
22     }\r
23     \r
24     /**\r
25      * @return singleton factory\r
26      */\r
27     public static ExperimenterInputMessageFactory getInstance() {\r
28         if (instance == null) {\r
29             instance = new ExperimenterInputMessageFactory();\r
30         }\r
31         return instance;\r
32     }\r
33     \r
34     @Override\r
35     public void messageToBuffer(short version, ByteBuf out,\r
36             ExperimenterInput message) {\r
37         out.writeByte(message.getVersion());\r
38         out.writeByte(MESSAGE_TYPE);\r
39         out.writeShort(OFFrameDecoder.LENGTH_OF_HEADER + (Integer.SIZE/Byte.SIZE)*2);\r
40         out.writeInt(message.getXid().intValue());\r
41         out.writeInt(message.getExperimenter().intValue());\r
42         out.writeInt(message.getExpType().intValue());\r
43     }\r
44 \r
45 }\r