1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
\r
2 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
\r
4 import io.netty.buffer.ByteBuf;
\r
6 import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
\r
7 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
\r
8 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder;
\r
11 * Translates EchoReply messages
\r
12 * @author michal.polkorab
\r
13 * @author timotej.kubas
\r
15 public class EchoReplyMessageFactory implements OFDeserializer<EchoOutput> {
\r
17 private static EchoReplyMessageFactory instance;
\r
19 private EchoReplyMessageFactory() {
\r
20 // do nothing, just singleton
\r
24 * @return singleton factory
\r
26 public static synchronized EchoReplyMessageFactory getInstance() {
\r
27 if (instance == null) {
\r
28 instance = new EchoReplyMessageFactory();
\r
34 public EchoOutput bufferToMessage(ByteBuf rawMessage, short version) {
\r
35 EchoOutputBuilder builder = new EchoOutputBuilder();
\r
36 builder.setVersion(version);
\r
37 builder.setXid(rawMessage.readUnsignedInt());
\r
38 int remainingBytes = rawMessage.readableBytes();
\r
39 if (remainingBytes > 0) {
\r
40 builder.setData(rawMessage.readBytes(remainingBytes).array());
\r
42 return builder.build();
\r