class NettyXMPPDecoder extends ByteToMessageDecoder {
    private static final Logger Log = LoggerFactory.getLogger(NettyXMPPDecoder.class);

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {<FILL_FUNCTION_BODY>}

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        final NettyConnection connection = ctx.channel().attr(CONNECTION).get();
        Log.warn("Error occurred while decoding XMPP stanza, closing connection: {}", connection, cause);
        connection.close(new StreamError(StreamError.Condition.internal_server_error, "An error occurred in XMPP Decoder"), cause instanceof IOException);
    }
}

        // Get the XML parser from the channel
        XMLLightweightParser parser = ctx.channel().attr(NettyConnectionHandler.XML_PARSER).get();

        // Check that the stanza constructed by the parser is not bigger than 1 Megabyte. For security reasons
        // we will abort parsing when 1 Mega of queued chars was found.
        if (parser.isMaxBufferSizeExceeded()) {
            // Clear out the buffer to prevent endless exceptions being thrown while the connection is closed.
            // De-allocation of the buffer from this channel will occur following the channel closure, so there is
            // no need to call in.release() as this will cause an IllegalReferenceCountException.
            in.clear();
            NettyConnection connection = ctx.channel().attr(CONNECTION).get();
            Log.warn("Maximum buffer size was exceeded, closing connection: " + connection);
            connection.close(new StreamError(StreamError.Condition.policy_violation, "Maximum stanza length exceeded"));
            return;
        }

        // Parse as many stanzas as possible from the received data
        char[] readChars = in.readCharSequence(in.readableBytes(), CharsetUtil.UTF_8).toString().toCharArray();
        parser.read(readChars);

        // Add any decoded messages to our outbound list to be processed by subsequent channelRead() events
        if (parser.areThereMsgs()) {
            out.addAll(Arrays.asList(parser.getMsgs()));
        }
    
<no_super_class>