2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
\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
9 package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;
\r
11 import io.netty.buffer.ByteBuf;
\r
13 import java.util.List;
\r
15 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
\r
16 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
\r
17 import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker;
\r
18 import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory;
\r
19 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
\r
20 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
\r
21 import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer;
\r
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction;
\r
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder;
\r
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
\r
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
\r
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
\r
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;
\r
30 * @author michal.polkorab
\r
33 public abstract class AbstractActionInstructionDeserializer extends AbstractInstructionDeserializer
\r
34 implements DeserializerRegistryInjector {
\r
36 private DeserializerRegistry registry;
\r
39 public Instruction deserialize(ByteBuf input) {
\r
40 InstructionBuilder builder = new InstructionBuilder();
\r
41 input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
\r
42 builder.setType(getType());
\r
43 int instructionLength = input.readUnsignedShort();
\r
44 input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
\r
45 ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder();
\r
46 int length = instructionLength - InstructionConstants.STANDARD_INSTRUCTION_LENGTH;
\r
47 CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
\r
48 List<Action> actions = ListDeserializer.deserializeList(
\r
49 EncodeConstants.OF13_VERSION_ID, length, input, keyMaker, getRegistry());
\r
50 actionsBuilder.setAction(actions);
\r
51 builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build());
\r
52 return builder.build();
\r
55 protected abstract Class<? extends InstructionBase> getType();
\r
57 protected DeserializerRegistry getRegistry() {
\r
62 public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
\r
63 this.registry = deserializerRegistry;
\r