FileDocCategorySizeDatePackage
IIOMetadataUtils.javaAPI DocAndroid 1.5 API3568Wed May 06 22:41:54 BST 2009org.apache.harmony.x.imageio.metadata

IIOMetadataUtils

public class IIOMetadataUtils extends Object

Fields Summary
Constructors Summary
private IIOMetadataUtils()

Methods Summary
public static javax.imageio.metadata.IIOMetadataFormatinstantiateMetadataFormat(java.lang.String formatName, boolean standardFormatSupported, java.lang.String nativeMetadataFormatName, java.lang.String nativeMetadataFormatClassName, java.lang.String[] extraMetadataFormatNames, java.lang.String[] extraMetadataFormatClassNames)

        if (formatName == null) {
            throw new IllegalArgumentException("formatName == null!");
        }
        if (formatName.equals(IIOMetadataFormatImpl.standardMetadataFormatName)) {
            if (standardFormatSupported) {
                return IIOMetadataFormatImpl.getStandardFormatInstance();
            }
        }

        String className = null;

        if (formatName.equals(nativeMetadataFormatName)) {
            className = nativeMetadataFormatClassName;
        } else if (extraMetadataFormatNames != null) {
            for (int i = 0; i < extraMetadataFormatNames.length; i++) {
                if (formatName.equals(extraMetadataFormatNames[i])) {
                    className = extraMetadataFormatClassNames[i];
                    break;
                }
            }
        }

        if (className == null) {
            throw new IllegalArgumentException("Unsupported format name");
        }

        // Get the context class loader and try to use it first
        ClassLoader contextClassloader = AccessController.doPrivileged(
                new PrivilegedAction<ClassLoader>() {
                    public ClassLoader run() {
                        return Thread.currentThread().getContextClassLoader();
                    }
        });

        Class cls;

        try {
            cls = Class.forName(className, true, contextClassloader);
        } catch (ClassNotFoundException e) {
            try {
                // Use current class loader
                cls = Class.forName(className);
            } catch (ClassNotFoundException e1) {
                throw new IllegalStateException ("Can't obtain format");
            }
        }

        try {
            //???AWT:
            //Method getInstance = cls.getMethod("getInstance");
            //return (IIOMetadataFormat) getInstance.invoke(null);
            return null;
        } catch (Exception e) {
            IllegalStateException e1 = new IllegalStateException("Can't obtain format");
            e1.initCause(e); // Add some details to the message
            throw e1;
        }