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 * Translates Experimenter messages
\r
12 * @author michal.polkorab
\r
13 * @author timotej.kubas
\r
15 public class ExperimenterInputMessageFactory implements OFSerializer<ExperimenterInput>{
\r
17 /** Code type of Experimenter message */
\r
18 public static final byte MESSAGE_TYPE = 4;
\r
19 private static final byte MESSAGE_LENGTH = 8;
\r
20 private static ExperimenterInputMessageFactory instance;
\r
22 private ExperimenterInputMessageFactory() {
\r
23 // do nothing, just singleton
\r
27 * @return singleton factory
\r
29 public static synchronized ExperimenterInputMessageFactory getInstance() {
\r
30 if (instance == null) {
\r
31 instance = new ExperimenterInputMessageFactory();
\r
37 public void messageToBuffer(short version, ByteBuf out,
\r
38 ExperimenterInput message) {
\r
39 ByteBufUtils.writeOFHeader(instance, message, out);
\r
40 out.writeInt(message.getExperimenter().intValue());
\r
41 out.writeInt(message.getExpType().intValue());
\r
42 byte[] data = message.getData();
\r
44 out.writeBytes(data);
\r
49 public int computeLength(ExperimenterInput message) {
\r
50 int length = MESSAGE_LENGTH + 2 * (Integer.SIZE / Byte.SIZE);
\r
51 byte[] data = message.getData();
\r
53 length += data.length;
\r
59 public byte getMessageType() {
\r
60 return MESSAGE_TYPE;
\r