本文整理汇总了Java中javax.imageio.spi.ServiceRegistry.Filter方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceRegistry.Filter方法的具体用法?Java ServiceRegistry.Filter怎么用?Java ServiceRegistry.Filter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.imageio.spi.ServiceRegistry
的用法示例。
在下文中一共展示了ServiceRegistry.Filter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getImageTranscoders
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
/**
* Returns an <code>Iterator</code> containing all currently
* registered <code>ImageTranscoder</code>s that claim to be
* able to transcode between the metadata of the given
* <code>ImageReader</code> and <code>ImageWriter</code>.
*
* @param reader an <code>ImageReader</code>.
* @param writer an <code>ImageWriter</code>.
*
* @return an <code>Iterator</code> containing
* <code>ImageTranscoder</code>s.
*
* @exception IllegalArgumentException if <code>reader</code> or
* <code>writer</code> is <code>null</code>.
*/
public static Iterator<ImageTranscoder>
getImageTranscoders(ImageReader reader, ImageWriter writer)
{
if (reader == null) {
throw new IllegalArgumentException("reader == null!");
}
if (writer == null) {
throw new IllegalArgumentException("writer == null!");
}
ImageReaderSpi readerSpi = reader.getOriginatingProvider();
ImageWriterSpi writerSpi = writer.getOriginatingProvider();
ServiceRegistry.Filter filter =
new TranscoderFilter(readerSpi, writerSpi);
Iterator iter;
// Ensure category is present
try {
iter = theRegistry.getServiceProviders(ImageTranscoderSpi.class,
filter, true);
} catch (IllegalArgumentException e) {
return Collections.emptyIterator();
}
return new ImageTranscoderIterator(iter);
}
示例2: getImageTranscoders
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
/**
* Returns an {@code Iterator} containing all currently
* registered {@code ImageTranscoder}s that claim to be
* able to transcode between the metadata of the given
* {@code ImageReader} and {@code ImageWriter}.
*
* @param reader an {@code ImageReader}.
* @param writer an {@code ImageWriter}.
*
* @return an {@code Iterator} containing
* {@code ImageTranscoder}s.
*
* @exception IllegalArgumentException if {@code reader} or
* {@code writer} is {@code null}.
*/
public static Iterator<ImageTranscoder>
getImageTranscoders(ImageReader reader, ImageWriter writer)
{
if (reader == null) {
throw new IllegalArgumentException("reader == null!");
}
if (writer == null) {
throw new IllegalArgumentException("writer == null!");
}
ImageReaderSpi readerSpi = reader.getOriginatingProvider();
ImageWriterSpi writerSpi = writer.getOriginatingProvider();
ServiceRegistry.Filter filter =
new TranscoderFilter(readerSpi, writerSpi);
Iterator<ImageTranscoderSpi> iter;
// Ensure category is present
try {
iter = theRegistry.getServiceProviders(ImageTranscoderSpi.class,
filter, true);
} catch (IllegalArgumentException e) {
return Collections.emptyIterator();
}
return new ImageTranscoderIterator(iter);
}
示例3: getImageTranscoders
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
/**
* Returns an <code>Iterator</code> containing all currently registered <code>ImageTranscoder</code>s that
* claim to be able to transcode between the metadata of the given <code>ImageReader</code> and
* <code>ImageWriter</code>.
*
* @param reader
* an <code>ImageReader</code>.
* @param writer
* an <code>ImageWriter</code>.
*
* @return an <code>Iterator</code> containing <code>ImageTranscoder</code>s.
*
* @exception IllegalArgumentException
* if <code>reader</code> or <code>writer</code> is <code>null</code>.
*/
public static Iterator<ImageTranscoder> getImageTranscoders(ImageReader reader, ImageWriter writer) {
if (reader == null) {
throw new IllegalArgumentException("reader == null!");
}
if (writer == null) {
throw new IllegalArgumentException("writer == null!");
}
ImageReaderSpi readerSpi = reader.getOriginatingProvider();
ImageWriterSpi writerSpi = writer.getOriginatingProvider();
ServiceRegistry.Filter filter = new TranscoderFilter(readerSpi, writerSpi);
Iterator iter;
// Ensure category is present
try {
iter = theRegistry.getServiceProviders(ImageTranscoderSpi.class, filter, true);
} catch (IllegalArgumentException e) {
return new HashSet().iterator();
}
return new ImageTranscoderIterator(iter);
}
示例4: clearImageIORegistry
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
protected void clearImageIORegistry() {
IIORegistry registry = IIORegistry.getDefaultInstance();
Iterator<Class<?>> categories = registry.getCategories();
final ClassLoader webClassLoader = getWebApplicationClassLoader();
ServiceRegistry.Filter classLoaderFilter = provider -> {
//remove all service provider loaded by the current ClassLoader
return webClassLoader.equals(provider.getClass().getClassLoader());
};
while (categories.hasNext()) {
@SuppressWarnings("unchecked")
Class<IIOServiceProvider> category = (Class<IIOServiceProvider>) categories.next();
Iterator<IIOServiceProvider> serviceProviders = registry.getServiceProviders(category,
classLoaderFilter, true);
if (serviceProviders.hasNext()) {
info("removing service provider of category: " + category.getSimpleName());
//copy to list
LinkedList<IIOServiceProvider> serviceProviderList = new LinkedList<>();
while (serviceProviders.hasNext()) {
serviceProviderList.add(serviceProviders.next());
}
for (IIOServiceProvider serviceProvider : serviceProviderList) {
info(" - removing: " + serviceProvider.getDescription(Locale.ROOT));
registry.deregisterServiceProvider(serviceProvider);
}
}
}
}
示例5: getReadersByFilter
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
private static Iterator<ImageReader> getReadersByFilter(Class<ImageReaderSpi> type,
ServiceRegistry.Filter filter,
Object readerExtension)
{
try
{
Iterator<ImageReaderSpi> it
= getRegistry().getServiceProviders(type, filter, true);
return new ImageReaderIterator(it, readerExtension);
}
catch (IllegalArgumentException e)
{
return Collections.EMPTY_SET.iterator();
}
}
示例6: getWritersByFilter
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
private static Iterator<ImageWriter> getWritersByFilter(Class<ImageWriterSpi> type,
ServiceRegistry.Filter filter,
Object writerExtension)
{
try
{
Iterator<ImageWriterSpi> it
= getRegistry().getServiceProviders(type, filter, true);
return new ImageWriterIterator(it, writerExtension);
}
catch (IllegalArgumentException e)
{
return Collections.EMPTY_SET.iterator();
}
}