Changed model versions to dependencies
[controller.git] / opendaylight / md-sal / sal-netconf-connector / src / main / java / org / opendaylight / controller / sal / connect / netconf / YangModelInputStreamAdapter.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sal.connect.netconf;
9
10 import java.io.IOException;
11 import java.io.InputStream;
12 import java.io.StringBufferInputStream;
13 import java.io.StringReader;
14
15 import org.opendaylight.yangtools.concepts.Delegator;
16 import org.opendaylight.yangtools.yang.common.QName;
17
18 /**
19  * 
20  *
21  */
22 public class YangModelInputStreamAdapter extends InputStream implements Delegator<InputStream> {
23
24     final String source;
25     final QName moduleIdentifier;
26     final InputStream delegate;
27     
28     
29     
30     private YangModelInputStreamAdapter(String source, QName moduleIdentifier, InputStream delegate) {
31         super();
32         this.source = source;
33         this.moduleIdentifier = moduleIdentifier;
34         this.delegate = delegate;
35     }
36
37     public int read() throws IOException {
38         return delegate.read();
39     }
40
41     public int hashCode() {
42         return delegate.hashCode();
43     }
44
45     public int read(byte[] b) throws IOException {
46         return delegate.read(b);
47     }
48
49     public boolean equals(Object obj) {
50         return delegate.equals(obj);
51     }
52
53     public int read(byte[] b, int off, int len) throws IOException {
54         return delegate.read(b, off, len);
55     }
56
57     public long skip(long n) throws IOException {
58         return delegate.skip(n);
59     }
60
61     public int available() throws IOException {
62         return delegate.available();
63     }
64
65     public void close() throws IOException {
66         delegate.close();
67     }
68
69     public void mark(int readlimit) {
70         delegate.mark(readlimit);
71     }
72
73     public void reset() throws IOException {
74         delegate.reset();
75     }
76
77     public boolean markSupported() {
78         return delegate.markSupported();
79     }
80
81     @Override
82     public InputStream getDelegate() {
83         return delegate;
84     }
85
86     @Override
87     public String toString() {
88         return "YangModelInputStreamAdapter [moduleIdentifier=" + moduleIdentifier + ", delegate=" + delegate + "]";
89     }
90
91     public static YangModelInputStreamAdapter create(QName name, String module) {
92         InputStream stringInput = new StringBufferInputStream(module);
93         return new YangModelInputStreamAdapter(null, name, stringInput );
94     }
95 }