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.ByteArrayInputStream;
11 import java.io.IOException;
12 import java.io.InputStream;
14 import org.opendaylight.yangtools.concepts.Delegator;
15 import org.opendaylight.yangtools.yang.common.QName;
17 import com.google.common.base.Charsets;
23 public class YangModelInputStreamAdapter extends InputStream implements Delegator<InputStream> {
26 final QName moduleIdentifier;
27 final InputStream delegate;
29 private YangModelInputStreamAdapter(String source, QName moduleIdentifier, InputStream delegate) {
32 this.moduleIdentifier = moduleIdentifier;
33 this.delegate = delegate;
37 public int read() throws IOException {
38 return delegate.read();
42 public int hashCode() {
43 return delegate.hashCode();
47 public int read(byte[] b) throws IOException {
48 return delegate.read(b);
52 public boolean equals(Object obj) {
53 return delegate.equals(obj);
57 public int read(byte[] b, int off, int len) throws IOException {
58 return delegate.read(b, off, len);
62 public long skip(long n) throws IOException {
63 return delegate.skip(n);
67 public int available() throws IOException {
68 return delegate.available();
72 public void close() throws IOException {
77 public void mark(int readlimit) {
78 delegate.mark(readlimit);
82 public void reset() throws IOException {
87 public boolean markSupported() {
88 return delegate.markSupported();
92 public InputStream getDelegate() {
97 public String toString() {
98 return "YangModelInputStreamAdapter [moduleIdentifier=" + moduleIdentifier + ", delegate=" + delegate + "]";
101 public static YangModelInputStreamAdapter create(QName name, String module) {
102 return new YangModelInputStreamAdapter(null, name, new ByteArrayInputStream(module.getBytes(Charsets.UTF_8)));