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 // *********************************************************
23 // TODO: Check this exif library flag before releasing!
24 /** Flag to specify internal or external library */
25 private static final boolean USE_INTERNAL_LIBRARY = true;
26 // *********************************************************
28 /** Library object to call */
29 private static ExifLibrary _exifLibrary = null;
30 /** Flag to set whether failure warning has already been shown */
31 private static boolean _exifFailWarned = false;
33 /** Static block to initialise library */
36 String libraryClass = USE_INTERNAL_LIBRARY?"InternalExifLibrary":"ExternalExifLibrary";
39 _exifLibrary = (ExifLibrary) Class.forName("tim.prune.jpeg." + libraryClass).newInstance();
41 catch (Throwable nolib) {_exifLibrary = null;}
46 * Get the Jpeg data from the given file
47 * @param inFile file to read
48 * @return jpeg data, or null if none found
50 public static JpegData getJpegData(File inFile)
54 // Call library (if found)
55 if (_exifLibrary != null) {
56 JpegData data = _exifLibrary.getJpegData(inFile);
60 catch (LinkageError nolib) {}
61 // Not successful - warn if necessary
64 JOptionPane.showMessageDialog(null, I18nManager.getText("error.jpegload.exifreadfailed"),
65 I18nManager.getText("error.jpegload.dialogtitle"), JOptionPane.WARNING_MESSAGE);
66 _exifFailWarned = true;
72 * @return key to use to describe library, matching key for about dialog
74 public static String getDescriptionKey()
76 String key = USE_INTERNAL_LIBRARY?"internal":"external";
77 if (_exifLibrary == null || !_exifLibrary.looksOK()) {key = key + ".failed";}