Merge "creating a default subnet"
[controller.git] / opendaylight / netconf / netconf-impl / src / main / java / org / opendaylight / controller / netconf / impl / mapping / ExiDecoderHandler.java
1 /*\r
2  * Copyright (c) 2013 Cisco Systems, Inc. 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 package org.opendaylight.controller.netconf.impl.mapping;\r
9 \r
10 import io.netty.buffer.ByteBuf;\r
11 import io.netty.channel.ChannelHandlerContext;\r
12 import io.netty.handler.codec.ByteToMessageDecoder;\r
13 \r
14 import java.util.List;\r
15 \r
16 import org.opendaylight.controller.netconf.util.xml.ExiParameters;\r
17 import org.opendaylight.controller.netconf.util.xml.ExiUtil;\r
18 import org.slf4j.Logger;\r
19 import org.slf4j.LoggerFactory;\r
20 \r
21 public class ExiDecoderHandler extends ByteToMessageDecoder {\r
22 \r
23     public static final String HANDLER_NAME;\r
24 \r
25     static {\r
26         HANDLER_NAME = "exiDecoder";\r
27     }\r
28 \r
29     private final static Logger logger = LoggerFactory\r
30             .getLogger(ExiDecoderHandler.class);\r
31 \r
32     private ExiParameters parameters;\r
33 \r
34     public ExiDecoderHandler(ExiParameters parameters) {\r
35         this.parameters = parameters;\r
36     }\r
37 \r
38     @Override\r
39     protected void decode(ChannelHandlerContext ctx, ByteBuf in,\r
40             List<Object> out) {\r
41         try {\r
42             ExiUtil.decode(in, out, this.parameters);\r
43         } catch (Exception e) {\r
44             throw new IllegalStateException("Unable to decode exi message.");\r
45         }\r
46     }\r
47 \r
48 }\r