1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
\r
2 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
\r
4 import io.netty.buffer.ByteBuf;
\r
6 import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
\r
7 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
\r
8 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
\r
11 * @author michal.polkorab
\r
14 public class ExperimenterInputMessageFactory implements OFSerializer<ExperimenterInput>{
\r
16 /** Code type of Experimenter message */
\r
17 public static final byte MESSAGE_TYPE = 4;
\r
18 private static int dataLength;
\r
19 private static ExperimenterInputMessageFactory instance;
\r
21 private ExperimenterInputMessageFactory() {
\r
22 // do nothing, just singleton
\r
26 * @return singleton factory
\r
28 public static synchronized ExperimenterInputMessageFactory getInstance() {
\r
29 if (instance == null) {
\r
30 instance = new ExperimenterInputMessageFactory();
\r
36 public void messageToBuffer(short version, ByteBuf out,
\r
37 ExperimenterInput message) {
\r
38 dataLength = message.getData().length;
\r
39 ByteBufUtils.writeOFHeader(instance, message, out);
\r
40 out.writeInt(message.getExperimenter().intValue());
\r
41 out.writeInt(message.getExpType().intValue());
\r
42 out.writeBytes(message.getData());
\r
46 public int computeLength() {
\r
47 int ofHeaderLength = 8; //OFHeaderLength
\r
48 int messageLength = 8; //experimenterHeaderLength
\r
49 return messageLength + ofHeaderLength + dataLength;
\r
53 public byte getMessageType() {
\r
54 return MESSAGE_TYPE;
\r