add checks on ImageUtils instances
[nikiroo-utils.git] / src / be / nikiroo / utils / ImageUtils.java
index cacff8d5bb3717696f633d2befaef893dbfbca4b..e95f73e4216d1cb8cc66db89227aca94fdd9c3f7 100644 (file)
@@ -190,6 +190,14 @@ public abstract class ImageUtils {
                return set_flag;
        }
 
+       /**
+        * Check that the class can operate (for instance, that all the required
+        * libraries or frameworks are present).
+        * 
+        * @return TRUE if it works
+        */
+       abstract protected boolean check();
+
        /**
         * Create a new {@link ImageUtils}.
         * 
@@ -199,7 +207,10 @@ public abstract class ImageUtils {
                for (String clazz : new String[] { "be.nikiroo.utils.ui.ImageUtilsAwt",
                                "be.nikiroo.utils.android.ImageUtilsAndroid" }) {
                        try {
-                               return (ImageUtils) SerialUtils.createObject(clazz);
+                               ImageUtils obj = (ImageUtils) SerialUtils.createObject(clazz);
+                               if (obj.check()) {
+                                       return obj;
+                               }
                        } catch (Exception e) {
                        }
                }