X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=openflow-protocol-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fdeserialization%2Ffactories%2FRoleReplyMessageFactory.java;h=9f9fec9a02fb88c6e2b41884713e57e0fbf2db1c;hb=0d942e8fb70b2c21f97eea3ed8904336ab5c54a4;hp=d09aa7a19663ff0a0c5c392dd916856b8b6668d3;hpb=5b05fc8e7dd2b61a076dfd1864a205b0995c7722;p=openflowjava.git diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactory.java index d09aa7a1..9f9fec9a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactory.java @@ -1,49 +1,56 @@ -/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; - -import java.math.BigInteger; - -import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutputBuilder; - -/** - * Translates RoleReply messages - * @author timotej.kubas - * @author michal.polkorab - */ -public class RoleReplyMessageFactory implements OFDeserializer{ - private static RoleReplyMessageFactory instance; - private static final byte PADDING_IN_ROLE_REPLY_HEADER = 4; - - private RoleReplyMessageFactory() { - // singleton - } - - /** - * - * @return singleton factory - */ - public static synchronized RoleReplyMessageFactory getInstance(){ - if(instance == null){ - instance = new RoleReplyMessageFactory(); - } - return instance; - } - - @Override - public RoleRequestOutput bufferToMessage(ByteBuf rawMessage, short version) { - RoleRequestOutputBuilder builder = new RoleRequestOutputBuilder(); - builder.setVersion(version); - builder.setXid(rawMessage.readUnsignedInt()); - builder.setRole(ControllerRole.forValue((int) rawMessage.readUnsignedInt())); - rawMessage.skipBytes(PADDING_IN_ROLE_REPLY_HEADER); - byte[] generationID = new byte[8]; - rawMessage.readBytes(generationID); - builder.setGenerationId(new BigInteger(generationID)); - return builder.build(); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; + +import java.math.BigInteger; + +import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutputBuilder; + +/** + * Translates RoleReply messages + * @author timotej.kubas + * @author michal.polkorab + */ +public class RoleReplyMessageFactory implements OFDeserializer{ + private static RoleReplyMessageFactory instance; + private static final byte PADDING_IN_ROLE_REPLY_HEADER = 4; + + private RoleReplyMessageFactory() { + // singleton + } + + /** + * + * @return singleton factory + */ + public static synchronized RoleReplyMessageFactory getInstance(){ + if(instance == null){ + instance = new RoleReplyMessageFactory(); + } + return instance; + } + + @Override + public RoleRequestOutput bufferToMessage(ByteBuf rawMessage, short version) { + RoleRequestOutputBuilder builder = new RoleRequestOutputBuilder(); + builder.setVersion(version); + builder.setXid(rawMessage.readUnsignedInt()); + builder.setRole(ControllerRole.forValue((int) rawMessage.readUnsignedInt())); + rawMessage.skipBytes(PADDING_IN_ROLE_REPLY_HEADER); + byte[] generationID = new byte[8]; + rawMessage.readBytes(generationID); + builder.setGenerationId(new BigInteger(generationID)); + return builder.build(); + } +}