本文整理汇总了Java中javax.imageio.metadata.IIOMetadataFormatImpl.getStandardFormatInstance方法的典型用法代码示例。如果您正苦于以下问题:Java IIOMetadataFormatImpl.getStandardFormatInstance方法的具体用法?Java IIOMetadataFormatImpl.getStandardFormatInstance怎么用?Java IIOMetadataFormatImpl.getStandardFormatInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.imageio.metadata.IIOMetadataFormatImpl
的用法示例。
在下文中一共展示了IIOMetadataFormatImpl.getStandardFormatInstance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMetadataFormat
import javax.imageio.metadata.IIOMetadataFormatImpl; //导入方法依赖的package包/类
private IIOMetadataFormat getMetadataFormat(String formatName,
boolean supportsStandard,
String nativeName,
String nativeClassName,
String [] extraNames,
String [] extraClassNames) {
if (formatName == null) {
throw new IllegalArgumentException("formatName == null!");
}
if (supportsStandard && formatName.equals
(IIOMetadataFormatImpl.standardMetadataFormatName)) {
return IIOMetadataFormatImpl.getStandardFormatInstance();
}
String formatClassName = null;
if (formatName.equals(nativeName)) {
formatClassName = nativeClassName;
} else if (extraNames != null) {
for (int i = 0; i < extraNames.length; i++) {
if (formatName.equals(extraNames[i])) {
formatClassName = extraClassNames[i];
break; // out of for
}
}
}
if (formatClassName == null) {
throw new IllegalArgumentException("Unsupported format name");
}
try {
Class cls = Class.forName(formatClassName, true,
ClassLoader.getSystemClassLoader());
Method meth = cls.getMethod("getInstance");
return (IIOMetadataFormat) meth.invoke(null);
} catch (Exception e) {
RuntimeException ex =
new IllegalStateException ("Can't obtain format");
ex.initCause(e);
throw ex;
}
}
示例2: getStreamMetadataFormat
import javax.imageio.metadata.IIOMetadataFormatImpl; //导入方法依赖的package包/类
/**
* Returns an IIOMetadataFormat object that represents the requested
* stream metadata format or null if the given format is supported
* but no IIOMetadataFormat can be created for it.
*
* @param formatName the requested stream metadata format name
*
* @return an IIOMetadataFormat object or null
*
* @throws IllegalArgumentException if formatName is null or is not
* one of the standard metadata format or this provider's native or
* extra stream metadata formats
*/
public IIOMetadataFormat getStreamMetadataFormat (String formatName)
{
if (formatName == null)
throw new IllegalArgumentException ("null stream metadata format name");
if (!formatName.equals (getNativeStreamMetadataFormatName())
&& !formatName.equals (IIOMetadataFormatImpl.standardMetadataFormatName))
{
String[] extraNames = getExtraStreamMetadataFormatNames ();
boolean foundName = false;
for (int i = 0; i < extraNames.length; i++)
{
if (formatName.equals(extraNames[i]))
{
foundName = true;
break;
}
}
if (!foundName)
throw new IllegalArgumentException ("unsupported stream metadata format name");
}
if (formatName.equals (IIOMetadataFormatImpl.standardMetadataFormatName))
return IIOMetadataFormatImpl.getStandardFormatInstance ();
else
// Default implementation returns null.
return null;
}
示例3: getImageMetadataFormat
import javax.imageio.metadata.IIOMetadataFormatImpl; //导入方法依赖的package包/类
/**
* Returns an IIOMetadataFormat object that represents the requested
* image metadata format or null if the given format is supported
* but no IIOMetadataFormat can be created for it.
*
* @param formatName the requested image metadata format name
*
* @return an IIOMetadataFormat object or null
*
* @throws IllegalArgumentException if formatName is null or is not
* one of the standard metadata format or this provider's native or
* extra image metadata formats
*/
public IIOMetadataFormat getImageMetadataFormat (String formatName)
{
if (formatName == null)
throw new IllegalArgumentException ("null image metadata format name");
if (!formatName.equals (getNativeImageMetadataFormatName())
&& !formatName.equals (IIOMetadataFormatImpl.standardMetadataFormatName))
{
String[] extraNames = getExtraImageMetadataFormatNames ();
boolean foundName = false;
for (int i = 0; i < extraNames.length; i++)
{
if (formatName.equals(extraNames[i]))
{
foundName = true;
break;
}
}
if (!foundName)
throw new IllegalArgumentException ("unsupported image metadata format name");
}
if (formatName.equals (IIOMetadataFormatImpl.standardMetadataFormatName))
return IIOMetadataFormatImpl.getStandardFormatInstance ();
else
// Default implementation returns null.
return null;
}
示例4: main
import javax.imageio.metadata.IIOMetadataFormatImpl; //导入方法依赖的package包/类
public static void main(String[] args) {
IIOMetadataFormat format = null;
if (args.length == 0 || args[0].equals("javax_imageio_1.0")) {
format = IIOMetadataFormatImpl.getStandardFormatInstance();
} else {
IIORegistry registry = IIORegistry.getDefaultInstance();
Iterator iter = registry.getServiceProviders(ImageReaderSpi.class,
false);
while (iter.hasNext()) {
ImageReaderSpi spi = (ImageReaderSpi)iter.next();
if (args[0].equals
(spi.getNativeStreamMetadataFormatName())) {
System.out.print(spi.getDescription(null));
System.out.println(": native stream format");
format = spi.getStreamMetadataFormat(args[0]);
break;
}
String[] extraStreamFormatNames =
spi.getExtraStreamMetadataFormatNames();
if (extraStreamFormatNames != null &&
Arrays.asList(extraStreamFormatNames).
contains(args[0])) {
System.out.print(spi.getDescription(null));
System.out.println(": extra stream format");
format = spi.getStreamMetadataFormat(args[0]);
break;
}
if (args[0].equals
(spi.getNativeImageMetadataFormatName())) {
System.out.print(spi.getDescription(null));
System.out.println(": native image format");
format = spi.getImageMetadataFormat(args[0]);
break;
}
String[] extraImageFormatNames =
spi.getExtraImageMetadataFormatNames();
if (extraImageFormatNames != null &&
Arrays.asList(extraImageFormatNames).contains(args[0])) {
System.out.print(spi.getDescription(null));
System.out.println(": extra image format");
format = spi.getImageMetadataFormat(args[0]);
break;
}
}
}
if (format == null) {
System.err.println("Unknown format: " + args[0]);
System.exit(0);
}
MetadataFormatPrinter printer = new MetadataFormatPrinter(System.out);
printer.print(format);
}
示例5: getMetadataFormat
import javax.imageio.metadata.IIOMetadataFormatImpl; //导入方法依赖的package包/类
private IIOMetadataFormat getMetadataFormat(String formatName,
boolean supportsStandard,
String nativeName,
String nativeClassName,
String [] extraNames,
String [] extraClassNames) {
if (formatName == null) {
throw new IllegalArgumentException("formatName == null!");
}
if (supportsStandard && formatName.equals
(IIOMetadataFormatImpl.standardMetadataFormatName)) {
return IIOMetadataFormatImpl.getStandardFormatInstance();
}
String formatClassName = null;
if (formatName.equals(nativeName)) {
formatClassName = nativeClassName;
} else if (extraNames != null) {
for (int i = 0; i < extraNames.length; i++) {
if (formatName.equals(extraNames[i])) {
formatClassName = extraClassNames[i];
break; // out of for
}
}
}
if (formatClassName == null) {
throw new IllegalArgumentException("Unsupported format name");
}
try {
// Try to load from the same location as the module of the SPI
final String className = formatClassName;
PrivilegedAction<Class<?>> pa = () -> { return getMetadataFormatClass(className); };
Class<?> cls = AccessController.doPrivileged(pa);
Method meth = cls.getMethod("getInstance");
return (IIOMetadataFormat) meth.invoke(null);
} catch (Exception e) {
RuntimeException ex =
new IllegalStateException ("Can't obtain format");
ex.initCause(e);
throw ex;
}
}