View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements. See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache license, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License. You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the license for the specific language governing permissions and
15   * limitations under the license.
16   */
17  package org.apache.log4j.config;
18  
19  import java.io.IOException;
20  import java.io.InputStream;
21  
22  class InputStreamWrapper extends InputStream {
23  
24      private final String description;
25      private final InputStream input;
26  
27      public InputStreamWrapper(final InputStream input, final String description) {
28          this.input = input;
29          this.description = description;
30      }
31  
32      @Override
33      public int available() throws IOException {
34          return input.available();
35      }
36  
37      @Override
38      public void close() throws IOException {
39          input.close();
40      }
41  
42      @Override
43      public boolean equals(final Object obj) {
44          return input.equals(obj);
45      }
46  
47      @Override
48      public int hashCode() {
49          return input.hashCode();
50      }
51  
52      @Override
53      public synchronized void mark(final int readlimit) {
54          input.mark(readlimit);
55      }
56  
57      @Override
58      public boolean markSupported() {
59          return input.markSupported();
60      }
61  
62      @Override
63      public int read() throws IOException {
64          return input.read();
65      }
66  
67      @Override
68      public int read(final byte[] b) throws IOException {
69          return input.read(b);
70      }
71  
72      @Override
73      public int read(final byte[] b, final int off, final int len) throws IOException {
74          return input.read(b, off, len);
75      }
76  
77      @Override
78      public synchronized void reset() throws IOException {
79          input.reset();
80      }
81  
82      @Override
83      public long skip(final long n) throws IOException {
84          return input.skip(n);
85      }
86  
87      @Override
88      public String toString() {
89          return getClass().getSimpleName() + " [description=" + description + ", input=" + input + "]";
90      }
91  
92  }