Path: blob/master/src/java.desktop/share/classes/javax/imageio/spi/IIOServiceProvider.java
41155 views
/*1* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.imageio.spi;2627import java.util.Locale;28import javax.imageio.spi.RegisterableService;29import javax.imageio.spi.ServiceRegistry;3031/**32* A superinterface for functionality common to all Image I/O service33* provider interfaces (SPIs). For more information on service34* provider classes, see the class comment for the35* {@code IIORegistry} class.36*37* @see IIORegistry38* @see javax.imageio.spi.ImageReaderSpi39* @see javax.imageio.spi.ImageWriterSpi40* @see javax.imageio.spi.ImageTranscoderSpi41* @see javax.imageio.spi.ImageInputStreamSpi42* @see javax.imageio.spi.ImageOutputStreamSpi43*/44public abstract class IIOServiceProvider implements RegisterableService {4546/**47* A {@code String} to be returned from48* {@code getVendorName}, initially {@code null}.49* Constructors should set this to a non-{@code null} value.50*/51protected String vendorName;5253/**54* A {@code String} to be returned from55* {@code getVersion}, initially null. Constructors should56* set this to a non-{@code null} value.57*/58protected String version;5960/**61* Constructs an {@code IIOServiceProvider} with a given62* vendor name and version identifier.63*64* @param vendorName the vendor name.65* @param version a version identifier.66*67* @exception IllegalArgumentException if {@code vendorName}68* is {@code null}.69* @exception IllegalArgumentException if {@code version}70* is {@code null}.71*/72public IIOServiceProvider(String vendorName,73String version) {74if (vendorName == null) {75throw new IllegalArgumentException("vendorName == null!");76}77if (version == null) {78throw new IllegalArgumentException("version == null!");79}80this.vendorName = vendorName;81this.version = version;82}8384/**85* Constructs a blank {@code IIOServiceProvider}. It is up86* to the subclass to initialize instance variables and/or87* override method implementations in order to ensure that the88* {@code getVendorName} and {@code getVersion} methods89* will return non-{@code null} values.90*/91public IIOServiceProvider() {92}9394/**95* A callback that will be called exactly once after the Spi class96* has been instantiated and registered in a97* {@code ServiceRegistry}. This may be used to verify that98* the environment is suitable for this service, for example that99* native libraries can be loaded. If the service cannot function100* in the environment where it finds itself, it should deregister101* itself from the registry.102*103* <p> Only the registry should call this method.104*105* <p> The default implementation does nothing.106*107* @see ServiceRegistry#registerServiceProvider(Object provider)108*/109public void onRegistration(ServiceRegistry registry,110Class<?> category) {}111112/**113* A callback that will be whenever the Spi class has been114* deregistered from a {@code ServiceRegistry}.115*116* <p> Only the registry should call this method.117*118* <p> The default implementation does nothing.119*120* @see ServiceRegistry#deregisterServiceProvider(Object provider)121*/122public void onDeregistration(ServiceRegistry registry,123Class<?> category) {}124125/**126* Returns the name of the vendor responsible for creating this127* service provider and its associated implementation. Because128* the vendor name may be used to select a service provider,129* it is not localized.130*131* <p> The default implementation returns the value of the132* {@code vendorName} instance variable.133*134* @return a non-{@code null String} containing135* the name of the vendor.136*/137public String getVendorName() {138return vendorName;139}140141/**142* Returns a string describing the version143* number of this service provider and its associated144* implementation. Because the version may be used by transcoders145* to identify the service providers they understand, this method146* is not localized.147*148* <p> The default implementation returns the value of the149* {@code version} instance variable.150*151* @return a non-{@code null String} containing152* the version of this service provider.153*/154public String getVersion() {155return version;156}157158/**159* Returns a brief, human-readable description of this service160* provider and its associated implementation. The resulting161* string should be localized for the supplied162* {@code Locale}, if possible.163*164* @param locale a {@code Locale} for which the return value165* should be localized.166*167* @return a {@code String} containing a description of this168* service provider.169*/170public abstract String getDescription(Locale locale);171}172173174