1 package tim.prune.jpeg;
5 import javax.swing.JOptionPane;
7 import tim.prune.I18nManager;
10 * Skeleton gateway to the Exif functions.
11 * This is required by Debian to divert Exif handling
12 * to the external libmetadata-extractor-java library
13 * instead of the included modified routines.
15 * To use the internal routines, set the USE_INTERNAL_LIBRARY flag to true
16 * and include the internal classes in the compiled jar.
17 * To use the external library, set the USE_INTERNAL_LIBRARY flag to false
18 * and do not export the internal classes.
20 public abstract class ExifGateway
22 /** Library object to call */
23 private static ExifLibrary _exifLibrary = null;
24 /** Flag to set whether failure warning has already been shown */
25 private static boolean _exifFailWarned = false;
27 /** Static block to initialise library */
30 String libraryClass = ExifLibrarySwitch.USE_INTERNAL_LIBRARY?"InternalExifLibrary":"ExternalExifLibrary";
33 _exifLibrary = (ExifLibrary) Class.forName("tim.prune.jpeg." + libraryClass).newInstance();
35 catch (Throwable nolib) {_exifLibrary = null;}
40 * Get the Jpeg data from the given file
41 * @param inFile file to read
42 * @return jpeg data, or null if none found
44 public static JpegData getJpegData(File inFile)
48 // Call library (if found)
49 if (_exifLibrary != null) {
50 JpegData data = _exifLibrary.getJpegData(inFile);
54 catch (LinkageError nolib) {}
55 // Not successful - warn if necessary
58 JOptionPane.showMessageDialog(null, I18nManager.getText("error.jpegload.exifreadfailed"),
59 I18nManager.getText("error.jpegload.dialogtitle"), JOptionPane.WARNING_MESSAGE);
60 _exifFailWarned = true;
66 * @return key to use to describe library, matching key for about dialog
68 public static String getDescriptionKey()
70 String key = ExifLibrarySwitch.USE_INTERNAL_LIBRARY?"internal":"external";
71 if (_exifLibrary == null || !_exifLibrary.looksOK()) {key = key + ".failed";}