2 * Copyright (c) 2015 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.controller.cluster.datastore.node.utils.stream;
10 import com.google.common.annotations.Beta;
11 import java.io.DataInput;
12 import java.io.DataOutput;
13 import java.io.IOException;
14 import javax.annotation.Nonnull;
17 public final class NormalizedNodeInputOutput {
18 private NormalizedNodeInputOutput() {
19 throw new UnsupportedOperationException();
22 public static NormalizedNodeDataInput newDataInput(@Nonnull final DataInput input) throws IOException {
23 final byte marker = input.readByte();
24 if (marker != TokenTypes.SIGNATURE_MARKER) {
25 throw new InvalidNormalizedNodeStreamException(String.format("Invalid signature marker: %d", marker));
28 final short version = input.readShort();
30 case TokenTypes.LITHIUM_VERSION:
31 return new NormalizedNodeInputStreamReader(input, true);
33 throw new InvalidNormalizedNodeStreamException(String.format("Unhandled stream version %s", version));
37 public static NormalizedNodeDataOutput newDataOutput(@Nonnull final DataOutput output) throws IOException {
38 return new NormalizedNodeOutputStreamWriter(output);