KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)RAFImageOutputStreamSpi.java 1.7 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.io.RandomAccessFile JavaDoc;
12 import java.util.Locale JavaDoc;
13 import javax.imageio.spi.ImageOutputStreamSpi JavaDoc;
14 import javax.imageio.stream.ImageOutputStream JavaDoc;
15 import javax.imageio.stream.FileImageOutputStream JavaDoc;
16
17 public class RAFImageOutputStreamSpi extends ImageOutputStreamSpi JavaDoc {
18
19     private static final String JavaDoc vendorName = "Sun Microsystems, Inc.";
20
21     private static final String JavaDoc version = "1.0";
22
23     private static final Class JavaDoc outputClass = RandomAccessFile JavaDoc.class;
24
25     public RAFImageOutputStreamSpi() {
26         super(vendorName, version, outputClass);
27     }
28
29     public String JavaDoc getDescription(Locale JavaDoc locale) {
30         return "Service provider that instantiates a FileImageOutputStream from a RandomAccessFile";
31     }
32
33     public ImageOutputStream JavaDoc createOutputStreamInstance(Object JavaDoc output,
34                                                         boolean useCache,
35                                                         File JavaDoc cacheDir) {
36         if (output instanceof RandomAccessFile JavaDoc) {
37             try {
38                 return new FileImageOutputStream JavaDoc((RandomAccessFile JavaDoc)output);
39             } catch (Exception JavaDoc e) {
40                 e.printStackTrace();
41                 return null;
42             }
43         } else {
44             throw new IllegalArgumentException JavaDoc
45                 ("input not a RandomAccessFile!");
46         }
47     }
48 }
49
Popular Tags