01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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.harmony.x.imageio.plugins;
18:
19: import java.io.IOException;
20: import java.io.InputStream;
21:
22: import javax.imageio.stream.ImageInputStream;
23:
24: public class PluginUtils {
25:
26: public static final String VENDOR_NAME = "Apache Harmony"; //$NON-NLS-1$
27: public static final String DEFAULT_VERSION = "1.0"; //$NON-NLS-1$
28:
29: /**
30: * Wrap the specified ImageInputStream object in an InputStream.
31: */
32: public static InputStream wrapIIS(final ImageInputStream iis) {
33: return new IisWrapper(iis);
34: }
35:
36: private static class IisWrapper extends InputStream {
37:
38: private final ImageInputStream input;
39:
40: IisWrapper(final ImageInputStream input) {
41: this .input = input;
42: }
43:
44: @Override
45: public int read() throws IOException {
46: return input.read();
47: }
48:
49: @Override
50: public int read(final byte[] b) throws IOException {
51: return input.read(b);
52: }
53:
54: @Override
55: public int read(final byte[] b, final int off, final int len)
56: throws IOException {
57: return input.read(b, off, len);
58: }
59:
60: @Override
61: public long skip(final long n) throws IOException {
62: return input.skipBytes(n);
63: }
64:
65: @Override
66: public boolean markSupported() {
67: return true;
68: }
69:
70: @Override
71: public void mark(final int readlimit) {
72: input.mark();
73: }
74:
75: @Override
76: public void reset() throws IOException {
77: input.reset();
78: }
79:
80: @Override
81: public void close() throws IOException {
82: input.close();
83: }
84: }
85: }
|