2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
11 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
14 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
15 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;
19 * Translates Experimenter messages
20 * @author michal.polkorab
21 * @author timotej.kubas
23 public class ExperimenterInputMessageFactory implements OFSerializer<ExperimenterInput>{
25 /** Code type of Experimenter message */
26 public static final byte MESSAGE_TYPE = 4;
27 private static final byte MESSAGE_LENGTH = 8;
28 private static ExperimenterInputMessageFactory instance;
30 private ExperimenterInputMessageFactory() {
31 // do nothing, just singleton
35 * @return singleton factory
37 public static synchronized ExperimenterInputMessageFactory getInstance() {
38 if (instance == null) {
39 instance = new ExperimenterInputMessageFactory();
45 public void messageToBuffer(short version, ByteBuf out,
46 ExperimenterInput message) {
47 ByteBufUtils.writeOFHeader(instance, message, out);
48 out.writeInt(message.getExperimenter().intValue());
49 out.writeInt(message.getExpType().intValue());
50 byte[] data = message.getData();
57 public int computeLength(ExperimenterInput message) {
58 int length = MESSAGE_LENGTH + 2 * (EncodeConstants.SIZE_OF_INT_IN_BYTES);
59 byte[] data = message.getData();
61 length += data.length;
67 public byte getMessageType() {