0N/A/*
2362N/A * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.imageio.spi;
0N/A
0N/Aimport java.util.Locale;
0N/Aimport javax.imageio.spi.RegisterableService;
0N/Aimport javax.imageio.spi.ServiceRegistry;
0N/A
0N/A/**
0N/A * A superinterface for functionality common to all Image I/O service
0N/A * provider interfaces (SPIs). For more information on service
0N/A * provider classes, see the class comment for the
0N/A * <code>IIORegistry</code> class.
0N/A *
0N/A * @see IIORegistry
0N/A * @see javax.imageio.spi.ImageReaderSpi
0N/A * @see javax.imageio.spi.ImageWriterSpi
0N/A * @see javax.imageio.spi.ImageTranscoderSpi
0N/A * @see javax.imageio.spi.ImageInputStreamSpi
0N/A *
0N/A */
0N/Apublic abstract class IIOServiceProvider implements RegisterableService {
0N/A
0N/A /**
0N/A * A <code>String</code> to be returned from
0N/A * <code>getVendorName</code>, initially <code>null</code>.
0N/A * Constructors should set this to a non-<code>null</code> value.
0N/A */
0N/A protected String vendorName;
0N/A
0N/A /**
0N/A * A <code>String</code> to be returned from
0N/A * <code>getVersion</code>, initially null. Constructors should
0N/A * set this to a non-<code>null</code> value.
0N/A */
0N/A protected String version;
0N/A
0N/A /**
0N/A * Constructs an <code>IIOServiceProvider</code> with a given
0N/A * vendor name and version identifier.
0N/A *
0N/A * @param vendorName the vendor name.
0N/A * @param version a version identifier.
0N/A *
0N/A * @exception IllegalArgumentException if <code>vendorName</code>
0N/A * is <code>null</code>.
0N/A * @exception IllegalArgumentException if <code>version</code>
0N/A * is <code>null</code>.
0N/A */
0N/A public IIOServiceProvider(String vendorName,
0N/A String version) {
0N/A if (vendorName == null) {
0N/A throw new IllegalArgumentException("vendorName == null!");
0N/A }
0N/A if (version == null) {
0N/A throw new IllegalArgumentException("version == null!");
0N/A }
0N/A this.vendorName = vendorName;
0N/A this.version = version;
0N/A }
0N/A
0N/A /**
0N/A * Constructs a blank <code>IIOServiceProvider</code>. It is up
0N/A * to the subclass to initialize instance variables and/or
0N/A * override method implementations in order to ensure that the
0N/A * <code>getVendorName</code> and <code>getVersion</code> methods
0N/A * will return non-<code>null</code> values.
0N/A */
0N/A public IIOServiceProvider() {
0N/A }
0N/A
0N/A /**
0N/A * A callback that will be called exactly once after the Spi class
0N/A * has been instantiated and registered in a
0N/A * <code>ServiceRegistry</code>. This may be used to verify that
0N/A * the environment is suitable for this service, for example that
0N/A * native libraries can be loaded. If the service cannot function
0N/A * in the environment where it finds itself, it should deregister
0N/A * itself from the registry.
0N/A *
0N/A * <p> Only the registry should call this method.
0N/A *
0N/A * <p> The default implementation does nothing.
0N/A *
0N/A * @see ServiceRegistry#registerServiceProvider(Object provider)
0N/A */
0N/A public void onRegistration(ServiceRegistry registry,
0N/A Class<?> category) {}
0N/A
0N/A /**
0N/A * A callback that will be whenever the Spi class has been
0N/A * deregistered from a <code>ServiceRegistry</code>.
0N/A *
0N/A * <p> Only the registry should call this method.
0N/A *
0N/A * <p> The default implementation does nothing.
0N/A *
0N/A * @see ServiceRegistry#deregisterServiceProvider(Object provider)
0N/A */
0N/A public void onDeregistration(ServiceRegistry registry,
0N/A Class<?> category) {}
0N/A
0N/A /**
0N/A * Returns the name of the vendor responsible for creating this
0N/A * service provider and its associated implementation. Because
0N/A * the vendor name may be used to select a service provider,
0N/A * it is not localized.
0N/A *
0N/A * <p> The default implementation returns the value of the
0N/A * <code>vendorName</code> instance variable.
0N/A *
0N/A * @return a non-<code>null</code> <code>String</code> containing
0N/A * the name of the vendor.
0N/A */
0N/A public String getVendorName() {
0N/A return vendorName;
0N/A }
0N/A
0N/A /**
0N/A * Returns a string describing the version
0N/A * number of this service provider and its associated
0N/A * implementation. Because the version may be used by transcoders
0N/A * to identify the service providers they understand, this method
0N/A * is not localized.
0N/A *
0N/A * <p> The default implementation returns the value of the
0N/A * <code>version</code> instance variable.
0N/A *
0N/A * @return a non-<code>null</code> <code>String</code> containing
0N/A * the version of this service provider.
0N/A */
0N/A public String getVersion() {
0N/A return version;
0N/A }
0N/A
0N/A /**
0N/A * Returns a brief, human-readable description of this service
0N/A * provider and its associated implementation. The resulting
0N/A * string should be localized for the supplied
0N/A * <code>Locale</code>, if possible.
0N/A *
0N/A * @param locale a <code>Locale</code> for which the return value
0N/A * should be localized.
0N/A *
0N/A * @return a <code>String</code> containing a description of this
0N/A * service provider.
0N/A */
0N/A public abstract String getDescription(Locale locale);
0N/A}