2 * Copyright (c) 2013 Cisco Systems, Inc. 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.protocol.framework;
10 import java.util.List;
13 * Interface for factory for parsing and serializing protocol specific messages. Needs to be implemented by a protocol
14 * specific message factory. The methods put/parse should delegate parsing to specific message parsers, e.g.
15 * OpenMessageParser etc.
17 * @param <T> type of messages created by this factory
19 public interface ProtocolMessageFactory<T extends ProtocolMessage> {
22 * Parses message from byte array. Requires specific protocol message header object to parse the header.
24 * @param bytes byte array from which the message will be parsed
25 * @return List of specific protocol messages
26 * @throws DeserializerException if some parsing error occurs
27 * @throws DocumentedException if some documented error occurs
29 public List<T> parse(final byte[] bytes) throws DeserializerException, DocumentedException;
32 * Serializes protocol specific message to byte array.
34 * @param msg message to be serialized.
35 * @return byte array resulting message
37 public byte[] put(final T msg);