2 * Copyright (c) 2018 Inocybe Technologies and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.nettyutil.handler;
10 import java.nio.ByteBuffer;
11 import java.nio.CharBuffer;
12 import java.nio.charset.CharacterCodingException;
13 import java.nio.charset.CodingErrorAction;
14 import java.nio.charset.StandardCharsets;
15 import org.opendaylight.netconf.util.messages.NetconfMessageConstants;
18 * netconf message part constants as bytes.
20 * @author Thomas Pantelis
22 final class MessageParts {
23 static final byte[] END_OF_MESSAGE = asciiBytes(NetconfMessageConstants.END_OF_MESSAGE);
24 static final byte[] START_OF_CHUNK = asciiBytes(NetconfMessageConstants.START_OF_CHUNK);
25 static final byte[] END_OF_CHUNK = asciiBytes(NetconfMessageConstants.END_OF_CHUNK);
27 private MessageParts() {
31 private static byte[] asciiBytes(final String str) {
34 buf = StandardCharsets.US_ASCII.newEncoder()
35 .onMalformedInput(CodingErrorAction.REPORT)
36 .onUnmappableCharacter(CodingErrorAction.REPORT)
37 .encode(CharBuffer.wrap(str));
38 } catch (CharacterCodingException e) {
39 throw new ExceptionInInitializerError(e);
42 final byte[] ret = new byte[buf.remaining()];