IIOServiceProvider.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /* IIOServiceProvider.java -- General service provider for image I/O.
  2. Copyright (C) 2004, 2005 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package javax.imageio.spi;
  32. import java.util.Locale;
  33. /**
  34. * An abstract superclass for service providers that perform image I/O.
  35. *
  36. * @since 1.4
  37. *
  38. * @author Sascha Brawer (brawer@dandelis.ch)
  39. */
  40. public abstract class IIOServiceProvider
  41. implements RegisterableService
  42. {
  43. /**
  44. * The vendor of this service provider, or <code>null</code> if the
  45. * subclass constructor did not set this field.
  46. *
  47. * @see #getVendorName()
  48. */
  49. protected String vendorName;
  50. /**
  51. * The version of this service provider, or <code>null</code> if the
  52. * subclass constructor did not set this field.
  53. *
  54. * @see #getVersion()
  55. */
  56. protected String version;
  57. /**
  58. * Constructs a general <code>IIOServiceProvider</code>, given the
  59. * vendor name and a version string.
  60. *
  61. * @throws IllegalArgumentException if <code>vendorName</code>
  62. * or <code>version</code> is <code>null</code>.
  63. */
  64. public IIOServiceProvider(String vendorName, String version)
  65. {
  66. if (vendorName == null || version == null)
  67. throw new IllegalArgumentException();
  68. this.vendorName = vendorName;
  69. this.version = version;
  70. }
  71. /**
  72. * Constructs a general <code>IIOServiceProvider</code> without
  73. * specifying a vendor name and a version string. The subclass
  74. * constructor should set the {@link #vendorName} and {@link
  75. * #version} to non-null values.
  76. */
  77. public IIOServiceProvider()
  78. {
  79. }
  80. /**
  81. * Informs this service provider that it has been registered in a
  82. * {@link ServiceRegistry}. If this provider gets registered as an
  83. * implementor for several service categories, its
  84. * <code>onRegistration</code> method will be called multiple times.
  85. * The default implementation does nothing.
  86. *
  87. * @param registry the registry to which this service provider has
  88. * been added.
  89. *
  90. * @param category the service category for which this provider has
  91. * been registered as an implementor.
  92. */
  93. public void onRegistration(ServiceRegistry registry, Class<?> category)
  94. {
  95. }
  96. /**
  97. * Informs this service provider that it has been de-registered from
  98. * a {@link ServiceRegistry}. If this provider had been registered
  99. * as an implementor for several service categories, its
  100. * <code>onDeregistration</code> method will be called multiple
  101. * times. The default implementation does nothing.
  102. *
  103. * @param registry the registry from which this service provider has
  104. * been removed.
  105. *
  106. * @param category the service category for which this provider has
  107. * been registered as an implementor.
  108. */
  109. public void onDeregistration(ServiceRegistry registry, Class<?> category)
  110. {
  111. }
  112. /**
  113. * Returns the name of the vendor of this service provider.
  114. */
  115. public String getVendorName()
  116. {
  117. return vendorName;
  118. }
  119. /**
  120. * Returns an identifier string for the version of this service
  121. * provider.
  122. */
  123. public String getVersion()
  124. {
  125. return version;
  126. }
  127. /**
  128. * Returns a short description of this service provider that can be
  129. * presented to a human user.
  130. *
  131. * @param locale the locale for which the description string should
  132. * be localized.
  133. */
  134. public abstract String getDescription(Locale locale);
  135. }