KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > imageio > spi > IIOServiceProvider


1 /*
2  * @(#)IIOServiceProvider.java 1.18 04/05/05
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.imageio.spi;
9
10 import java.util.Locale JavaDoc;
11 import javax.imageio.spi.RegisterableService JavaDoc;
12 import javax.imageio.spi.ServiceRegistry JavaDoc;
13
14 /**
15  * A superinterface for functionality common to all Image I/O service
16  * provider interfaces (SPIs). For more information on service
17  * provider classes, see the class comment for the
18  * <code>IIORegistry</code> class.
19  *
20  * @see IIORegistry
21  * @see javax.imageio.spi.ImageReaderSpi
22  * @see javax.imageio.spi.ImageWriterSpi
23  * @see javax.imageio.spi.ImageTranscoderSpi
24  * @see javax.imageio.spi.ImageInputStreamSpi
25  *
26  * @version 0.5
27  */

28 public abstract class IIOServiceProvider implements RegisterableService JavaDoc {
29
30     /**
31      * A <code>String</code> to be returned from
32      * <code>getVendorName</code>, initially <code>null</code>.
33      * Constructors should set this to a non-<code>null</code> value.
34      */

35     protected String JavaDoc vendorName;
36
37     /**
38      * A <code>String</code> to be returned from
39      * <code>getVersion</code>, initially null. Constructors should
40      * set this to a non-<code>null</code> value.
41      */

42     protected String JavaDoc version;
43
44     /**
45      * Constructs an <code>IIOServiceProvider</code> with a given
46      * vendor name and version identifier.
47      *
48      * @param vendorName the vendor name.
49      * @param version a version identifier.
50      *
51      * @exception IllegalArgumentException if <code>vendorName</code>
52      * is <code>null</code>.
53      * @exception IllegalArgumentException if <code>version</code>
54      * is <code>null</code>.
55      */

56     public IIOServiceProvider(String JavaDoc vendorName,
57                               String JavaDoc version) {
58         if (vendorName == null) {
59             throw new IllegalArgumentException JavaDoc("vendorName == null!");
60         }
61         if (version == null) {
62             throw new IllegalArgumentException JavaDoc("version == null!");
63         }
64         this.vendorName = vendorName;
65         this.version = version;
66     }
67
68     /**
69      * Constructs a blank <code>IIOServiceProvider</code>. It is up
70      * to the subclass to initialize instance variables and/or
71      * override method implementations in order to ensure that the
72      * <code>getVendorName</code> and <code>getVersion</code> methods
73      * will return non-<code>null</code> values.
74      */

75     public IIOServiceProvider() {
76     }
77
78     /**
79      * A callback that will be called exactly once after the Spi class
80      * has been instantiated and registered in a
81      * <code>ServiceRegistry</code>. This may be used to verify that
82      * the environment is suitable for this service, for example that
83      * native libraries can be loaded. If the service cannot function
84      * in the environment where it finds itself, it should deregister
85      * itself from the registry.
86      *
87      * <p> Only the registry should call this method.
88      *
89      * <p> The default implementation does nothing.
90      *
91      * @see ServiceRegistry#registerServiceProvider(Object provider)
92      */

93     public void onRegistration(ServiceRegistry JavaDoc registry,
94                                Class JavaDoc<?> category) {}
95
96     /**
97      * A callback that will be whenever the Spi class has been
98      * deregistered from a <code>ServiceRegistry</code>.
99      *
100      * <p> Only the registry should call this method.
101      *
102      * <p> The default implementation does nothing.
103      *
104      * @see ServiceRegistry#deregisterServiceProvider(Object provider)
105      */

106     public void onDeregistration(ServiceRegistry JavaDoc registry,
107                                  Class JavaDoc<?> category) {}
108
109     /**
110      * Returns the name of the vendor responsible for creating this
111      * service provider and its associated implementation. Because
112      * the vendor name may be used to select a service provider,
113      * it is not localized.
114      *
115      * <p> The default implementation returns the value of the
116      * <code>vendorName</code> instance variable.
117      *
118      * @return a non-<code>null</code> <code>String</code> containing
119      * the name of the vendor.
120      */

121     public String JavaDoc getVendorName() {
122         return vendorName;
123     }
124
125     /**
126      * Returns a string describing the version
127      * number of this service provider and its associated
128      * implementation. Because the version may be used by transcoders
129      * to identify the service providers they understand, this method
130      * is not localized.
131      *
132      * <p> The default implementation returns the value of the
133      * <code>version</code> instance variable.
134      *
135      * @return a non-<code>null</code> <code>String</code> containing
136      * the version of this service provider.
137      */

138     public String JavaDoc getVersion() {
139         return version;
140     }
141
142     /**
143      * Returns a brief, human-readable description of this service
144      * provider and its associated implementation. The resulting
145      * string should be localized for the supplied
146      * <code>Locale</code>, if possible.
147      *
148      * @param locale a <code>Locale</code> for which the return value
149      * should be localized.
150      *
151      * @return a <code>String</code> containing a description of this
152      * service provider.
153      */

154     public abstract String JavaDoc getDescription(Locale JavaDoc locale);
155 }
156
Popular Tags