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.controller.sal.connect.netconf;
10 import java.io.IOException;
11 import java.io.InputStream;
12 import java.io.StringBufferInputStream;
13 import java.io.StringReader;
15 import org.opendaylight.yangtools.concepts.Delegator;
16 import org.opendaylight.yangtools.yang.common.QName;
22 public class YangModelInputStreamAdapter extends InputStream implements Delegator<InputStream> {
25 final QName moduleIdentifier;
26 final InputStream delegate;
30 private YangModelInputStreamAdapter(String source, QName moduleIdentifier, InputStream delegate) {
33 this.moduleIdentifier = moduleIdentifier;
34 this.delegate = delegate;
37 public int read() throws IOException {
38 return delegate.read();
41 public int hashCode() {
42 return delegate.hashCode();
45 public int read(byte[] b) throws IOException {
46 return delegate.read(b);
49 public boolean equals(Object obj) {
50 return delegate.equals(obj);
53 public int read(byte[] b, int off, int len) throws IOException {
54 return delegate.read(b, off, len);
57 public long skip(long n) throws IOException {
58 return delegate.skip(n);
61 public int available() throws IOException {
62 return delegate.available();
65 public void close() throws IOException {
69 public void mark(int readlimit) {
70 delegate.mark(readlimit);
73 public void reset() throws IOException {
77 public boolean markSupported() {
78 return delegate.markSupported();
82 public InputStream getDelegate() {
87 public String toString() {
88 return "YangModelInputStreamAdapter [moduleIdentifier=" + moduleIdentifier + ", delegate=" + delegate + "]";
91 public static YangModelInputStreamAdapter create(QName name, String module) {
92 InputStream stringInput = new StringBufferInputStream(module);
93 return new YangModelInputStreamAdapter(null, name, stringInput );