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 final byte MESSAGE_LENGTH = 8;
\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 ByteBufUtils.writeOFHeader(instance, message, out);
\r
39 out.writeInt(message.getExperimenter().intValue());
\r
40 out.writeInt(message.getExpType().intValue());
\r
41 byte[] data = message.getData();
\r
43 out.writeBytes(data);
\r
48 public int computeLength(ExperimenterInput message) {
\r
49 int length = MESSAGE_LENGTH + 2 * (Integer.SIZE / Byte.SIZE);
\r
50 byte[] data = message.getData();
\r
52 length += data.length;
\r
58 public byte getMessageType() {
\r
59 return MESSAGE_TYPE;
\r