KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > imageio > spi > FileImageInputStreamSpi


1 /*
2  * @(#)FileImageInputStreamSpi.java 1.15 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.imageio.spi;
9
10 import java.io.File JavaDoc;
11 import java.util.Locale JavaDoc;
12 import javax.imageio.spi.ImageInputStreamSpi JavaDoc;
13 import javax.imageio.stream.ImageInputStream JavaDoc;
14 import javax.imageio.stream.FileImageInputStream JavaDoc;
15
16 public class FileImageInputStreamSpi extends ImageInputStreamSpi JavaDoc {
17
18     private static final String JavaDoc vendorName = "Sun Microsystems, Inc.";
19
20     private static final String JavaDoc version = "1.0";
21
22     private static final Class JavaDoc inputClass = File JavaDoc.class;
23
24     public FileImageInputStreamSpi() {
25         super(vendorName, version, inputClass);
26     }
27
28     public String JavaDoc getDescription(Locale JavaDoc locale) {
29         return "Service provider that instantiates a FileImageInputStream from a File";
30     }
31
32     public ImageInputStream JavaDoc createInputStreamInstance(Object JavaDoc input,
33                                                       boolean useCache,
34                                                       File JavaDoc cacheDir) {
35         if (input instanceof File JavaDoc) {
36             try {
37                 return new FileImageInputStream JavaDoc((File JavaDoc)input);
38             } catch (Exception JavaDoc e) {
39                 return null;
40             }
41         } else {
42             throw new IllegalArgumentException JavaDoc();
43         }
44     }
45 }
46
Popular Tags