2 * Copyright (c) 2014 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.netconf.cli.writer.impl;
10 import java.io.IOException;
11 import java.util.List;
12 import org.opendaylight.netconf.cli.io.ConsoleIO;
13 import org.opendaylight.netconf.cli.writer.WriteException;
14 import org.opendaylight.netconf.cli.writer.Writer;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
16 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
18 public abstract class AbstractWriter<T extends DataSchemaNode> implements Writer<T> {
20 protected ConsoleIO console;
22 public AbstractWriter(final ConsoleIO console) {
23 this.console = console;
27 public void write(final T dataSchemaNode, final List<NormalizedNode<?, ?>> dataNodes) throws WriteException {
29 writeInner(dataSchemaNode, dataNodes);
30 } catch (final IOException e) {
31 throw new WriteException("Unable to write data to output for " + dataSchemaNode.getQName(), e);
35 protected abstract void writeInner(final T dataSchemaNode, final List<NormalizedNode<?, ?>> dataNodes)
36 throws IOException, WriteException;