Copyright update
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / TableModInputMessageFactory.java
index 1255b15909c9cbf60982cc2d5e0dccff771deab9..9c4e3b24f984c259822819fd9e8c34f3632e60f3 100644 (file)
@@ -1,67 +1,74 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;\r
-\r
-/**\r
- * Translates TableMod messages\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class TableModInputMessageFactory implements OFSerializer<TableModInput> {\r
-    private static final byte MESSAGE_TYPE = 17;\r
-    private static final byte PADDING_IN_TABLE_MOD_MESSAGE = 3;\r
-    private static final int MESSAGE_LENGTH = 16;\r
-    private static TableModInputMessageFactory instance;\r
-    \r
-    private TableModInputMessageFactory() {\r
-        // just singleton\r
-    }\r
-    \r
-    /**\r
-     * @return singleton factory\r
-     */\r
-    public static synchronized TableModInputMessageFactory getInstance() {\r
-        if(instance == null){\r
-            instance = new TableModInputMessageFactory();\r
-        }\r
-        return instance;\r
-    }\r
-    \r
-    @Override\r
-    public void messageToBuffer(short version, ByteBuf out, TableModInput message) {\r
-        ByteBufUtils.writeOFHeader(instance, message, out);\r
-        out.writeByte(message.getTableId().getValue().byteValue());\r
-        ByteBufUtils.padBuffer(PADDING_IN_TABLE_MOD_MESSAGE, out);\r
-        out.writeInt(createConfigBitmask(message.getConfig()));\r
-    }\r
-\r
-    @Override\r
-    public int computeLength(TableModInput message) {\r
-        return MESSAGE_LENGTH;\r
-    }\r
-\r
-    @Override\r
-    public byte getMessageType() {\r
-        return MESSAGE_TYPE;\r
-    }\r
-    \r
-    /**\r
-     * @param tableConfig\r
-     * @return port config bitmask \r
-     */\r
-    private static int createConfigBitmask(TableConfig tableConfig) {\r
-        Map<Integer, Boolean> portConfigMap = new HashMap<>();\r
-        portConfigMap.put(3, tableConfig.isOFPTCDEPRECATEDMASK());\r
-        int configBitmask = ByteBufUtils.fillBitMaskFromMap(portConfigMap);\r
-        return configBitmask;\r
-    }\r
-}\r
+/*
+ * 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.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
+
+/**
+ * Translates TableMod messages
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class TableModInputMessageFactory implements OFSerializer<TableModInput> {
+    private static final byte MESSAGE_TYPE = 17;
+    private static final byte PADDING_IN_TABLE_MOD_MESSAGE = 3;
+    private static final int MESSAGE_LENGTH = 16;
+    private static TableModInputMessageFactory instance;
+    
+    private TableModInputMessageFactory() {
+        // just singleton
+    }
+    
+    /**
+     * @return singleton factory
+     */
+    public static synchronized TableModInputMessageFactory getInstance() {
+        if(instance == null){
+            instance = new TableModInputMessageFactory();
+        }
+        return instance;
+    }
+    
+    @Override
+    public void messageToBuffer(short version, ByteBuf out, TableModInput message) {
+        ByteBufUtils.writeOFHeader(instance, message, out);
+        out.writeByte(message.getTableId().getValue().byteValue());
+        ByteBufUtils.padBuffer(PADDING_IN_TABLE_MOD_MESSAGE, out);
+        out.writeInt(createConfigBitmask(message.getConfig()));
+    }
+
+    @Override
+    public int computeLength(TableModInput message) {
+        return MESSAGE_LENGTH;
+    }
+
+    @Override
+    public byte getMessageType() {
+        return MESSAGE_TYPE;
+    }
+    
+    /**
+     * @param tableConfig
+     * @return port config bitmask 
+     */
+    private static int createConfigBitmask(TableConfig tableConfig) {
+        Map<Integer, Boolean> portConfigMap = new HashMap<>();
+        portConfigMap.put(3, tableConfig.isOFPTCDEPRECATEDMASK());
+        int configBitmask = ByteBufUtils.fillBitMaskFromMap(portConfigMap);
+        return configBitmask;
+    }
+}