Changed output directory for generated classes
[openflowjava.git] / openflow-protocol-ext / src / main / java / org / opendaylight / openflowjava / protocol / ext / serialization / OF13ExperimenterInstructionSerializer.java
1 /*\r
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 package org.opendaylight.openflowjava.protocol.ext.serialization;\r
10 \r
11 import io.netty.buffer.ByteBuf;\r
12 \r
13 import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer;\r
14 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;\r
15 import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants;\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction;\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
18 \r
19 /**\r
20  * \r
21  * @author michal.polkorab\r
22  */\r
23 public class OF13ExperimenterInstructionSerializer implements OFSerializer<Instruction>,\r
24         HeaderSerializer<Instruction>{\r
25 \r
26     @Override\r
27     public void serializeHeader(Instruction instruction, ByteBuf outBuffer) {\r
28         outBuffer.writeShort(ExtConstants.EXPERIMENTER_VALUE);\r
29         outBuffer.writeShort(ExtConstants.EXPERIMENTER_IDS_LENGTH);\r
30         outBuffer.writeInt(instruction\r
31                 .getAugmentation(ExperimenterInstruction.class).getExperimenter().intValue());\r
32     }\r
33 \r
34     @Override\r
35     public void serialize(Instruction instruction, ByteBuf outBuffer) {\r
36         int startIndex = outBuffer.writerIndex();\r
37         outBuffer.writeShort(ExtConstants.EXPERIMENTER_VALUE);\r
38         int lengthIndex = outBuffer.writerIndex();\r
39         outBuffer.writeShort(ExtConstants.EMPTY_LENGTH);\r
40         ExperimenterInstruction experimenter =\r
41                 instruction.getAugmentation(ExperimenterInstruction.class);\r
42         outBuffer.writeInt(experimenter.getExperimenter().intValue());\r
43         if (experimenter.getData() != null) {\r
44             outBuffer.writeBytes(experimenter.getData());\r
45         }\r
46         outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex);\r
47     }\r
48 \r
49 }\r