diff --git a/jhove-apps/src/main/java/Jhove.java b/jhove-apps/src/main/java/Jhove.java index 72b289d9e..5de0a345b 100644 --- a/jhove-apps/src/main/java/Jhove.java +++ b/jhove-apps/src/main/java/Jhove.java @@ -1,295 +1,261 @@ -/********************************************************************** - * Jhove - JSTOR/Harvard Object Validation Environment - * Copyright 2004-2007 by the President and Fellows of Harvard College +/** + * ******************************************************************** Jhove - JSTOR/Harvard Object + * Validation Environment Copyright 2004-2007 by the President and Fellows of Harvard College * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - **********************************************************************/ - + *
This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + *
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + *
You should have received a copy of the GNU Lesser General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA ********************************************************************
+ */
import edu.harvard.hul.ois.jhove.App;
-import edu.harvard.hul.ois.jhove.ExitCode;
import edu.harvard.hul.ois.jhove.CoreMessageConstants;
+import edu.harvard.hul.ois.jhove.ExitCode;
import edu.harvard.hul.ois.jhove.JhoveBase;
import edu.harvard.hul.ois.jhove.Module;
import edu.harvard.hul.ois.jhove.OutputHandler;
-
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
-public class Jhove
-{
- /** Application name. */
- private static final String NAME = "Jhove";
- /** Logger for this class. */
- private static final Logger LOGGER = Logger.getLogger(Jhove.class.getCanonicalName());
-
- private Jhove()
- {
- throw new AssertionError("Should never enter private constructor");
- }
+public class Jhove {
+ /** Application name. */
+ private static final String NAME = "Jhove";
+ /** Logger for this class. */
+ private static final Logger LOGGER = Logger.getLogger(Jhove.class.getCanonicalName());
- private static final String C_CONFIG_OPTION = "-c";
- private static final String X_CONFIG_OPTION = "-x";
- private static final String NOT_FOUND = "' not found";
- private static final String HANDLER = "Handler '";
+ private Jhove() {
+ throw new AssertionError("Should never enter private constructor");
+ }
+ private static final String C_CONFIG_OPTION = "-c";
+ private static final String X_CONFIG_OPTION = "-x";
+ private static final String NOT_FOUND = "' not found";
+ private static final String HANDLER = "Handler '";
- /**
- * MAIN ENTRY POINT.
- */
- public static void main(String [] args)
- {
- // Make sure we have a satisfactory version of Java.
- String version = System.getProperty("java.vm.version");
- if (version.compareTo("1.8.0") < 0) {
- LOGGER.log(Level.SEVERE, CoreMessageConstants.EXC_JAVA_VER_INCMPT);
- System.exit(ExitCode.INCOMPATIBLE_VM.getReturnCode());
- }
+ /** MAIN ENTRY POINT. */
+ public static void main(String[] args) {
+ // Make sure we have a satisfactory version of Java.
+ String version = System.getProperty("java.vm.version");
+ if (version.compareTo("1.8.0") < 0) {
+ LOGGER.log(Level.SEVERE, CoreMessageConstants.EXC_JAVA_VER_INCMPT);
+ System.exit(ExitCode.INCOMPATIBLE_VM.getReturnCode());
+ }
- try {
+ try {
- // Initialize the application state object.
- App app = App.newAppWithName(NAME);
+ // Initialize the application state object.
+ App app = App.newAppWithName(NAME);
- // Retrieve configuration.
- String configFile = JhoveBase.getConfigFileFromProperties();
- String saxClass = JhoveBase.getSaxClassFromProperties();
+ // Retrieve configuration.
+ String configFile = JhoveBase.getConfigFileFromProperties();
+ String saxClass = JhoveBase.getSaxClassFromProperties();
- /* Pre-parse the command line for -c and -x config options.
- * With Windows, we have to deal with quote marks on our own.
- * With Unix, the shell takes care of quotes for us. */
- boolean quoted = false;
- for (int i = 0; i < args.length; i++) {
- if (quoted) {
- int len = args[i].length();
- if (args[i].charAt(len - 1) == '"') {
- quoted = false;
- }
- }
- else {
- if (C_CONFIG_OPTION.equals(args[i])) {
- if (i < args.length - 1) {
- configFile = args[++i];
- }
- }
- else if (X_CONFIG_OPTION.equals(args[i])) {
- if (i < args.length - 1) {
- saxClass = args[++i];
- }
- }
- else if (args[i].charAt(0) == '"') {
- quoted = true;
- }
- }
+ /* Pre-parse the command line for -c and -x config options.
+ * With Windows, we have to deal with quote marks on our own.
+ * With Unix, the shell takes care of quotes for us. */
+ boolean quoted = false;
+ for (int i = 0; i < args.length; i++) {
+ if (quoted) {
+ int len = args[i].length();
+ if (args[i].charAt(len - 1) == '"') {
+ quoted = false;
+ }
+ } else {
+ if (C_CONFIG_OPTION.equals(args[i])) {
+ if (i < args.length - 1) {
+ configFile = args[++i];
+ }
+ } else if (X_CONFIG_OPTION.equals(args[i])) {
+ if (i < args.length - 1) {
+ saxClass = args[++i];
}
+ } else if (args[i].charAt(0) == '"') {
+ quoted = true;
+ }
+ }
+ }
- // Initialize the JHOVE engine.
- String encoding = null;
- String tempDir = null;
- int bufferSize = -1;
- String moduleName = null;
- String handlerName = null;
- String aboutHandler = null;
- String logLevel = null;
- String outputFile = null;
- boolean checksum = false;
- boolean showRaw = false;
- boolean signature = false;
- List This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU Lesser General Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA ********************************************************************
+ */
import edu.harvard.hul.ois.jhove.App;
-import edu.harvard.hul.ois.jhove.ExitCode;
import edu.harvard.hul.ois.jhove.CoreMessageConstants;
+import edu.harvard.hul.ois.jhove.ExitCode;
import edu.harvard.hul.ois.jhove.JhoveBase;
import edu.harvard.hul.ois.jhove.JhoveException;
import edu.harvard.hul.ois.jhove.viewer.JhoveWindow;
-
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
import java.awt.Toolkit;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
-/**
- * JhoveView - JSTOR/Harvard Object Validation Environment.
- */
-public class JhoveView
-{
- private static final Logger LOGGER = Logger.getLogger(JhoveView.class.getCanonicalName());
-
- /** Application name. */
- private static final String NAME = "JhoveView"; //$NON-NLS-1$
- /** Application icon. */
- private static final String ICON_PATH = "org/openpreservation/jhove/icon.png"; //$NON-NLS-1$
+/** JhoveView - JSTOR/Harvard Object Validation Environment. */
+public class JhoveView {
+ private static final Logger LOGGER = Logger.getLogger(JhoveView.class.getCanonicalName());
- /** Stub constructor. */
- private JhoveView()
- {
- }
+ /** Application name. */
+ private static final String NAME = "JhoveView"; // $NON-NLS-1$
+ /** Application icon. */
+ private static final String ICON_PATH = "org/openpreservation/jhove/icon.png"; // $NON-NLS-1$
- /**
- * Application main entry point.
- *
- * @param args Command-line arguments
- */
- public static void main(String[] args)
- {
- // Make sure we have a satisfactory version of Java.
- String version = System.getProperty("java.vm.version"); //$NON-NLS-1$
- if (version.compareTo("1.8.0") < 0) { //$NON-NLS-1$
- LOGGER.log(Level.SEVERE, CoreMessageConstants.EXC_JAVA_VER_INCMPT);
- errorAlert(CoreMessageConstants.EXC_JAVA_VER_INCMPT);
- System.exit(ExitCode.INCOMPATIBLE_VM.getReturnCode());
- }
+ /** Stub constructor. */
+ private JhoveView() {}
- // If we're running on a Macintosh, put the menubar at the top
- // of the screen where it belongs.
- System.setProperty("apple.laf.useScreenMenuBar", "true"); //$NON-NLS-1$ //$NON-NLS-2$
+ /**
+ * Application main entry point.
+ *
+ * @param args Command-line arguments
+ */
+ public static void main(String[] args) {
+ // Make sure we have a satisfactory version of Java.
+ String version = System.getProperty("java.vm.version"); // $NON-NLS-1$
+ if (version.compareTo("1.8.0") < 0) { // $NON-NLS-1$
+ LOGGER.log(Level.SEVERE, CoreMessageConstants.EXC_JAVA_VER_INCMPT);
+ errorAlert(CoreMessageConstants.EXC_JAVA_VER_INCMPT);
+ System.exit(ExitCode.INCOMPATIBLE_VM.getReturnCode());
+ }
- App app = App.newAppWithName(NAME);
- try {
+ // If we're running on a Macintosh, put the menubar at the top
+ // of the screen where it belongs.
+ System.setProperty("apple.laf.useScreenMenuBar", "true"); // $NON-NLS-1$ //$NON-NLS-2$
- // Retrieve configuration.
- String configFile = JhoveBase.getConfigFileFromProperties();
- String saxClass = JhoveBase.getSaxClassFromProperties();
+ App app = App.newAppWithName(NAME);
+ try {
- // Pre-parse the command line for -c and -x config options.
- boolean quoted = false;
- for (int i = 0; i < args.length; i++) {
- if (quoted) {
- int len = args[i].length();
- if (args[i].charAt(len - 1) == '"') {
- quoted = false;
- }
- }
- else {
- if ("-c".equals(args[i])) {
- if (i < args.length - 1) {
- configFile = args[++i];
- }
- }
- else if ("-x".equals(args[i])) {
- if (i < args.length - 1) {
- saxClass = args[++i];
- }
- }
- else if (args[i].charAt(0) == '"') {
- quoted = true;
- }
- }
- }
+ // Retrieve configuration.
+ String configFile = JhoveBase.getConfigFileFromProperties();
+ String saxClass = JhoveBase.getSaxClassFromProperties();
- // Initialize the JHOVE engine.
- JhoveBase je = new JhoveBase();
- try {
- je.init(configFile, saxClass);
+ // Pre-parse the command line for -c and -x config options.
+ boolean quoted = false;
+ for (int i = 0; i < args.length; i++) {
+ if (quoted) {
+ int len = args[i].length();
+ if (args[i].charAt(len - 1) == '"') {
+ quoted = false;
+ }
+ } else {
+ if ("-c".equals(args[i])) {
+ if (i < args.length - 1) {
+ configFile = args[++i];
}
- catch (JhoveException e) {
- errorAlert(e.getMessage());
- // Keep going, so user can correct in editor
+ } else if ("-x".equals(args[i])) {
+ if (i < args.length - 1) {
+ saxClass = args[++i];
}
+ } else if (args[i].charAt(0) == '"') {
+ quoted = true;
+ }
+ }
+ }
- // Create the main window to select a file.
- JhoveWindow jwin = new JhoveWindow(app, je);
- URL url = ClassLoader.getSystemResource(ICON_PATH); //$NON-NLS-1$
- Toolkit kit = Toolkit.getDefaultToolkit();
- jwin.setIconImage(kit.createImage(url));
- jwin.setVisible (true);
+ // Initialize the JHOVE engine.
+ JhoveBase je = new JhoveBase();
+ try {
+ je.init(configFile, saxClass);
+ } catch (JhoveException e) {
+ errorAlert(e.getMessage());
+ // Keep going, so user can correct in editor
+ }
- }
- catch (Exception e) {
- e.printStackTrace(System.err);
- LOGGER.log(Level.SEVERE, e.getMessage());
- System.exit(ExitCode.ERROR.getReturnCode());
- }
- }
+ // Create the main window to select a file.
+ JhoveWindow jwin = new JhoveWindow(app, je);
+ URL url = ClassLoader.getSystemResource(ICON_PATH); // $NON-NLS-1$
+ Toolkit kit = Toolkit.getDefaultToolkit();
+ jwin.setIconImage(kit.createImage(url));
+ jwin.setVisible(true);
- /** Displays an error alert. */
- private static void errorAlert(String msg)
- {
- JFrame hiddenFrame = new JFrame();
- // Truncate long messages so the alert isn't wider than the screen
- String message = (msg.length() > 80) ? msg.substring(0, 79) + "..." : msg;
- LOGGER.log(Level.WARNING, msg);
- JOptionPane.showMessageDialog(hiddenFrame, message, "Jhove Error",
- JOptionPane.ERROR_MESSAGE);
+ } catch (Exception e) {
+ e.printStackTrace(System.err);
+ LOGGER.log(Level.SEVERE, e.getMessage());
+ System.exit(ExitCode.ERROR.getReturnCode());
}
+ }
+
+ /** Displays an error alert. */
+ private static void errorAlert(String msg) {
+ JFrame hiddenFrame = new JFrame();
+ // Truncate long messages so the alert isn't wider than the screen
+ String message = (msg.length() > 80) ? msg.substring(0, 79) + "..." : msg;
+ LOGGER.log(Level.WARNING, msg);
+ JOptionPane.showMessageDialog(hiddenFrame, message, "Jhove Error", JOptionPane.ERROR_MESSAGE);
+ }
}
diff --git a/jhove-apps/src/main/java/UserHome.java b/jhove-apps/src/main/java/UserHome.java
index 406d01d53..ae1df34aa 100644
--- a/jhove-apps/src/main/java/UserHome.java
+++ b/jhove-apps/src/main/java/UserHome.java
@@ -1,33 +1,23 @@
-/**********************************************************************
- * UserHome - JSTOR/Harvard Object Validation Environment
- * Copyright 2006 by the President and Fellows of Harvard College
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- **********************************************************************/
-
-
-
/**
- * Determine the default value of the Java user.home property.
+ * ******************************************************************** UserHome - JSTOR/Harvard
+ * Object Validation Environment Copyright 2006 by the President and Fellows of Harvard College
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU Lesser General Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA ********************************************************************
*/
-public class UserHome
-{
- public static void main (String [] args)
- {
- System.out.println ("Default user.home is \"" +
- System.getProperty ("user.home") + "\"");
- }
+
+/** Determine the default value of the Java user.home property. */
+public class UserHome {
+ public static void main(String[] args) {
+ System.out.println("Default user.home is \"" + System.getProperty("user.home") + "\"");
+ }
}
diff --git a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/ConfigWriter.java b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/ConfigWriter.java
index c936ad1c3..86a1059b4 100644
--- a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/ConfigWriter.java
+++ b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/ConfigWriter.java
@@ -1,215 +1,183 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003 by JSTOR and the President and Fellows of Harvard College
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003 by JSTOR and the President and Fellows of Harvard College
*
- **********************************************************************/
-
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
+import edu.harvard.hul.ois.jhove.viewer.ConfigWindow;
import java.io.*;
import java.util.*;
import javax.swing.*;
-import edu.harvard.hul.ois.jhove.viewer.ConfigWindow;
-
/**
- *
- * Class to write out configuration information to the configuration file.
- * To minimize the chance of getting into a bad state, it writes to a
- * temporary file, then replaces the old config file with that file,
- * rather than directly overwriting the existing file.
- *
- * @author Gary McGath
+ * Class to write out configuration information to the configuration file. To minimize the chance of
+ * getting into a bad state, it writes to a temporary file, then replaces the old config file with
+ * that file, rather than directly overwriting the existing file.
*
+ * @author Gary McGath
*/
public class ConfigWriter {
-
- private PrintWriter _confOut;
- private File _tempFile;
- private File _confFile;
- ConfigWindow _parent;
-
- private final static String CLASS_TAG_START = " If the temporary file can't be written, or the configuration file can't be replaced, a
+ * warning dialog is put up and the configuration file remains unchanged.
+ */
+ public void writeFile(
+ List This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU Lesser General Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA ********************************************************************
+ */
package edu.harvard.hul.ois.jhove.viewer;
+import edu.harvard.hul.ois.jhove.App;
+import edu.harvard.hul.ois.jhove.Callback;
+import edu.harvard.hul.ois.jhove.ConfigHandler;
+import edu.harvard.hul.ois.jhove.JhoveBase;
+import edu.harvard.hul.ois.jhove.MacStuff;
+import edu.harvard.hul.ois.jhove.Module;
import java.awt.Color;
import java.awt.Container;
import java.awt.Toolkit;
@@ -44,7 +47,6 @@
import java.util.List;
import java.util.Vector;
import java.util.logging.Logger;
-
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
@@ -59,800 +61,788 @@
import javax.swing.KeyStroke;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
-
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
-import edu.harvard.hul.ois.jhove.App;
-import edu.harvard.hul.ois.jhove.Callback;
-import edu.harvard.hul.ois.jhove.ConfigHandler;
-import edu.harvard.hul.ois.jhove.JhoveBase;
-import edu.harvard.hul.ois.jhove.MacStuff;
-import edu.harvard.hul.ois.jhove.Module;
-
-/**
- * Main window of JHoveViewer application.
- */
+/** Main window of JHoveViewer application. */
public class JhoveWindow extends JFrame implements Callback, DropTargetListener {
- private App _app;
- private JhoveBase _base;
- private AppInfoWindow _appInfoWin;
- private ModuleInfoWindow _moduleInfoWin;
- private JMenu _moduleSubmenu;
- private JMenuItem _openFileItem;
- private JMenuItem _openURLItem;
- private JMenuItem _closeAllItem;
- private ButtonGroup _moduleGroup;
- private String syncStr = ""; // object just for synchronizing
- private boolean _rawOutput;
- private boolean _doChecksum;
-
- private ProgressWindow _progWind;
- // private ConfigWindow _configWind;
- private PrefsWindow _prefsWindow;
-
- private File _lastDir;
- private String _selectedModule;
- private ActionListener _moduleMenuListener;
- private JPanel logo;
- private ViewHandler _viewHandler;
-
- // Initial position for view windows.
- // Stagger them by adding an increment each time.
- // private static int viewWinXPos = 24;
- // private static int viewWinYPos = 24;
- // Original positions for cycling back to.
- // private static final int viewWinOrigXPos = 24;
- // private static final int viewWinOrigYPos = 24;
- // private static final int viewWinXInc = 25;
- // private static final int viewWinYInc = 22;
- private static final int appInfoWinXPos = 50;
- private static final int appInfoWinYPos = 45;
- private static final int moduleInfoWinXPos = 100;
- private static final int moduleInfoWinYPos = 90;
-
- private static final String NEVER = "never";
- private static final String CONFIG_ERROR = "Config Error";
-
- /** Logger for a module class. */
- protected Logger _logger;
-
- /* Static instance of InvisibleFilenameFilter */
- private final InvisibleFilenameFilter invisibleFilter = new JhoveWindow.InvisibleFilenameFilter();
-
- public JhoveWindow(App app, JhoveBase base) {
- super("Jhove");
- _logger = Logger.getLogger("edu.harvard.hul.ois.jhove.viewer");
- _app = app;
- _base = base;
- _moduleMenuListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- _selectedModule = e.getActionCommand();
- }
- };
-
- _lastDir = null;
- _moduleGroup = new ButtonGroup();
- addMenus();
- Container rootPane = getContentPane();
- // rootPane.setLayout (new GridLayout (4, 2));
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-
- // Define a Comparator function for Modules
- Comparator ********************************************************************
+ */
package edu.harvard.hul.ois.jhove.viewer;
import java.awt.*;
/**
* Static methods for positioning windows on the main screen.
- *
- * @author Gary McGath
*
+ * @author Gary McGath
*/
public class MainScreen {
- /**
- * Private constructor to prevent instantiation
- */
- private MainScreen ()
- {
-
+ /** Private constructor to prevent instantiation */
+ private MainScreen() {}
+
+ /** Center the window on the main screen. */
+ public static void centerWindow(Window win) {
+ Rectangle devBounds = mainBounds();
+ Rectangle winBounds = win.getBounds();
+ int lmargin = (devBounds.width - winBounds.width) / 2;
+ int tmargin = (devBounds.height - winBounds.height) / 2;
+ // Don't go off the edge
+ if (lmargin < 0) {
+ lmargin = 0;
}
-
-
- /**
- * Center the window on the main screen.
- */
- public static void centerWindow (Window win)
- {
- Rectangle devBounds = mainBounds ();
- Rectangle winBounds = win.getBounds ();
- int lmargin = (devBounds.width - winBounds.width) / 2;
- int tmargin = (devBounds.height - winBounds.height) / 2;
- // Don't go off the edge
- if (lmargin < 0) {
- lmargin = 0;
- }
- if (tmargin < 0) {
- tmargin = 0;
- }
- win.setLocation (lmargin, tmargin);
+ if (tmargin < 0) {
+ tmargin = 0;
}
+ win.setLocation(lmargin, tmargin);
+ }
-
- /**
- * Center the window at the top of the main screen.
- */
- public static void centerTopWindow (Window win)
- {
- Rectangle devBounds = mainBounds ();
- Rectangle winBounds = win.getBounds ();
- int lmargin = (devBounds.width - winBounds.width) / 2;
- // Don't go off the edge
- if (lmargin < 0) {
- lmargin = 0;
- }
- win.setLocation (lmargin, 0);
- }
-
-
- /**
- * Returns the bounds of the main monitor device.
- */
- public static Rectangle mainBounds ()
- {
- GraphicsEnvironment ge = GraphicsEnvironment.
- getLocalGraphicsEnvironment();
- GraphicsDevice dev = ge.getDefaultScreenDevice();
- GraphicsConfiguration conf = dev.getDefaultConfiguration ();
- return conf.getBounds ();
+ /** Center the window at the top of the main screen. */
+ public static void centerTopWindow(Window win) {
+ Rectangle devBounds = mainBounds();
+ Rectangle winBounds = win.getBounds();
+ int lmargin = (devBounds.width - winBounds.width) / 2;
+ // Don't go off the edge
+ if (lmargin < 0) {
+ lmargin = 0;
}
+ win.setLocation(lmargin, 0);
+ }
+
+ /** Returns the bounds of the main monitor device. */
+ public static Rectangle mainBounds() {
+ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ GraphicsDevice dev = ge.getDefaultScreenDevice();
+ GraphicsConfiguration conf = dev.getDefaultConfiguration();
+ return conf.getBounds();
+ }
}
diff --git a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/ModuleInfoWindow.java b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/ModuleInfoWindow.java
index 47a86520c..2bba18c20 100644
--- a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/ModuleInfoWindow.java
+++ b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/ModuleInfoWindow.java
@@ -1,22 +1,10 @@
-/**********************************************************************
- * JhoveView - JSTOR/Harvard Object Validation Environment
- * Copyright 2003 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** JhoveView - JSTOR/Harvard
+ * Object Validation Environment Copyright 2003 by JSTOR and the President and Fellows of Harvard
+ * College ********************************************************************
+ */
package edu.harvard.hul.ois.jhove.viewer;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.PrintWriter;
-
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-
import edu.harvard.hul.ois.jhove.Agent;
import edu.harvard.hul.ois.jhove.App;
import edu.harvard.hul.ois.jhove.Document;
@@ -27,276 +15,276 @@
import edu.harvard.hul.ois.jhove.OutputHandler;
import edu.harvard.hul.ois.jhove.Signature;
import edu.harvard.hul.ois.jhove.SignatureType;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.PrintWriter;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
/**
- * This window is for presenting information about the selected module. If no
- * module is selected, a brief message is put into the window.
+ * This window is for presenting information about the selected module. If no module is selected, a
+ * brief message is put into the window.
*/
public class ModuleInfoWindow extends InfoWindow {
- private JTextArea texta;
- private int _level;
- private Module _module;
-
- private static final String DATE = "Date: ";
- private static final String NOTE = "Note: ";
- private static final String TYPE = "Type: ";
+ private JTextArea texta;
+ private int _level;
+ private Module _module;
- /**
- * Constructor.
- *
- * @param app
- * The associated App object.
- * @param base
- * The associated JhoveBase object.
- * @param module
- * The Module whose information is to be presented.
- */
- public ModuleInfoWindow(App app, JhoveBase base, Module module) {
- super("Module Info", app, base);
- _module = module;
- setSaveActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- saveInfo();
- }
- });
+ private static final String DATE = "Date: ";
+ private static final String NOTE = "Note: ";
+ private static final String TYPE = "Type: ";
- texta = new JTextArea();
- texta.setColumns(72);
- JScrollPane scrollpane = new JScrollPane(texta);
- texta.setFont(new Font("sansserif", Font.PLAIN, 10));
- texta.setLineWrap(true);
- texta.setWrapStyleWord(true);
- // Getting Swing to accept what you want for dimensions
- // apparently requires setting as many dimension restrictions
- // as possible, and hoping it will pay attention to some
- // of them.
- scrollpane.setMinimumSize(new Dimension(240, 240));
- scrollpane.setMaximumSize(new Dimension(600, 500));
- scrollpane.setPreferredSize(new Dimension(600, 500));
- getContentPane().add(scrollpane, "Center");
+ /**
+ * Constructor.
+ *
+ * @param app The associated App object.
+ * @param base The associated JhoveBase object.
+ * @param module The Module whose information is to be presented.
+ */
+ public ModuleInfoWindow(App app, JhoveBase base, Module module) {
+ super("Module Info", app, base);
+ _module = module;
+ setSaveActionListener(
+ new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ saveInfo();
+ }
+ });
- // Add a small panel at the bottom, since on some OS's there
- // may be stuff near the bottom of a window which will conflict
- // with the scroll bar.
- JPanel panel = new JPanel();
- panel.setMinimumSize(new Dimension(8, 8));
- getContentPane().add(panel, "South");
+ texta = new JTextArea();
+ texta.setColumns(72);
+ JScrollPane scrollpane = new JScrollPane(texta);
+ texta.setFont(new Font("sansserif", Font.PLAIN, 10));
+ texta.setLineWrap(true);
+ texta.setWrapStyleWord(true);
+ // Getting Swing to accept what you want for dimensions
+ // apparently requires setting as many dimension restrictions
+ // as possible, and hoping it will pay attention to some
+ // of them.
+ scrollpane.setMinimumSize(new Dimension(240, 240));
+ scrollpane.setMaximumSize(new Dimension(600, 500));
+ scrollpane.setPreferredSize(new Dimension(600, 500));
+ getContentPane().add(scrollpane, "Center");
- showModule(module);
- pack();
+ // Add a small panel at the bottom, since on some OS's there
+ // may be stuff near the bottom of a window which will conflict
+ // with the scroll bar.
+ JPanel panel = new JPanel();
+ panel.setMinimumSize(new Dimension(8, 8));
+ getContentPane().add(panel, "South");
- }
+ showModule(module);
+ pack();
+ }
- /**
- * Formats and presents the module information in the window.
- */
- public void showModule(Module module) {
- _module = module;
- if (module == null) {
- texta.setText("(No module selected)");
- } else {
- _level = 0;
- texta.setText("");
- String margin = getIndent(++_level);
- texta.append(margin + "Module: " + module.getName() + eol);
- texta.append(margin + "Release: " + module.getRelease() + eol);
- texta.append(margin + DATE + _dateFmt.format(module.getDate())
- + eol);
- String[] ss = module.getFormat();
- if (ss.length > 0) {
- texta.append(margin + "Format: " + ss[0]);
- for (int i = 1; i < ss.length; i++) {
- texta.append(", " + ss[i]);
- }
- texta.append(eol);
- }
+ /** Formats and presents the module information in the window. */
+ public void showModule(Module module) {
+ _module = module;
+ if (module == null) {
+ texta.setText("(No module selected)");
+ } else {
+ _level = 0;
+ texta.setText("");
+ String margin = getIndent(++_level);
+ texta.append(margin + "Module: " + module.getName() + eol);
+ texta.append(margin + "Release: " + module.getRelease() + eol);
+ texta.append(margin + DATE + _dateFmt.format(module.getDate()) + eol);
+ String[] ss = module.getFormat();
+ if (ss.length > 0) {
+ texta.append(margin + "Format: " + ss[0]);
+ for (int i = 1; i < ss.length; i++) {
+ texta.append(", " + ss[i]);
+ }
+ texta.append(eol);
+ }
- String s = module.getCoverage();
- if (s != null) {
- texta.append(margin + "Coverage: " + s + eol);
- }
- ss = module.getMimeType();
- if (ss.length > 0) {
- texta.append(margin + "MIMEtype: " + ss[0]);
- for (int i = 1; i < ss.length; i++) {
- texta.append(", " + ss[i]);
- }
- ;
- texta.append(eol);
- }
- for (Signature sig : module.getSignature()) {
- showSignature(sig);
- }
- for (Document spec : module.getSpecification()) {
- showDocument(spec, "Specification");
- }
- texta.append(margin + " Features:\n");
- for (String feature : module.getFeatures()) {
- texta.append(margin + " " + feature + "\n");
- }
- texta.append(margin + "Methodology:\n");
- if ((s = module.getWellFormedNote()) != null) {
- texta.append(margin + "Well-formed: " + s + eol);
- }
- if ((s = module.getValidityNote()) != null) {
- texta.append(margin + "Validity: " + s + eol);
- }
- if ((s = module.getRepInfoNote()) != null) {
- texta.append(margin + "RepresentationInformation: " + s + eol);
- }
- Agent vendor = module.getVendor();
- if (vendor != null) {
- showAgent(vendor, "Vendor");
- }
- if ((s = module.getNote()) != null) {
- texta.append(margin + NOTE + s + eol);
- }
- if ((s = module.getRights()) != null) {
- texta.append(margin + "Rights: " + s + eol);
- }
- }
- // Scroll to the top.
- texta.setEditable(false);
- texta.select(0, 0);
- Rectangle r = new Rectangle(0, 0, 1, 1);
- texta.scrollRectToVisible(r);
- }
+ String s = module.getCoverage();
+ if (s != null) {
+ texta.append(margin + "Coverage: " + s + eol);
+ }
+ ss = module.getMimeType();
+ if (ss.length > 0) {
+ texta.append(margin + "MIMEtype: " + ss[0]);
+ for (int i = 1; i < ss.length; i++) {
+ texta.append(", " + ss[i]);
+ }
+ ;
+ texta.append(eol);
+ }
+ for (Signature sig : module.getSignature()) {
+ showSignature(sig);
+ }
+ for (Document spec : module.getSpecification()) {
+ showDocument(spec, "Specification");
+ }
+ texta.append(margin + " Features:\n");
+ for (String feature : module.getFeatures()) {
+ texta.append(margin + " " + feature + "\n");
+ }
+ texta.append(margin + "Methodology:\n");
+ if ((s = module.getWellFormedNote()) != null) {
+ texta.append(margin + "Well-formed: " + s + eol);
+ }
+ if ((s = module.getValidityNote()) != null) {
+ texta.append(margin + "Validity: " + s + eol);
+ }
+ if ((s = module.getRepInfoNote()) != null) {
+ texta.append(margin + "RepresentationInformation: " + s + eol);
+ }
+ Agent vendor = module.getVendor();
+ if (vendor != null) {
+ showAgent(vendor, "Vendor");
+ }
+ if ((s = module.getNote()) != null) {
+ texta.append(margin + NOTE + s + eol);
+ }
+ if ((s = module.getRights()) != null) {
+ texta.append(margin + "Rights: " + s + eol);
+ }
+ }
+ // Scroll to the top.
+ texta.setEditable(false);
+ texta.select(0, 0);
+ Rectangle r = new Rectangle(0, 0, 1, 1);
+ texta.scrollRectToVisible(r);
+ }
- private void showSignature(Signature signature) {
- String margin = getIndent(++_level);
+ private void showSignature(Signature signature) {
+ String margin = getIndent(++_level);
- String sigValue;
- if (signature.isStringValue()) {
- sigValue = signature.getValueString();
- } else {
- sigValue = signature.getValueHexString();
- }
- texta.append(margin + signature.getType().toString() + ": " + sigValue
- + eol);
- if (signature.getType().equals(SignatureType.MAGIC)) {
- if (((InternalSignature) signature).hasFixedOffset()) {
- texta.append(margin + "Offset: "
- + ((InternalSignature) signature).getOffset() + eol);
- }
- }
- String note = signature.getNote();
- if (note != null) {
- texta.append(margin + NOTE + note + eol);
- }
- String use = signature.getUse().toString();
- if (use != null) {
- texta.append(margin + "Use: " + use + eol);
- }
- --_level;
- }
+ String sigValue;
+ if (signature.isStringValue()) {
+ sigValue = signature.getValueString();
+ } else {
+ sigValue = signature.getValueHexString();
+ }
+ texta.append(margin + signature.getType().toString() + ": " + sigValue + eol);
+ if (signature.getType().equals(SignatureType.MAGIC)) {
+ if (((InternalSignature) signature).hasFixedOffset()) {
+ texta.append(margin + "Offset: " + ((InternalSignature) signature).getOffset() + eol);
+ }
+ }
+ String note = signature.getNote();
+ if (note != null) {
+ texta.append(margin + NOTE + note + eol);
+ }
+ String use = signature.getUse().toString();
+ if (use != null) {
+ texta.append(margin + "Use: " + use + eol);
+ }
+ --_level;
+ }
- private void showDocument(Document document, String label) {
- String margin = getIndent(++_level);
+ private void showDocument(Document document, String label) {
+ String margin = getIndent(++_level);
- texta.append(margin + label + ": " + document.getTitle() + eol);
- texta.append(margin + TYPE + document.getType() + eol);
- for (Agent agent : document.getAuthor()) {
- showAgent(agent, "Author");
- }
- for (Agent publisher : document.getPublisher()) {
- showAgent(publisher, "Publisher");
- }
- String s = document.getEdition();
- if (s != null) {
- texta.append(margin + "Edition: " + s + eol);
- }
- if ((s = document.getDate()) != null) {
- texta.append(margin + DATE + s + eol);
- }
- if ((s = document.getEnumeration()) != null) {
- texta.append(margin + "Enumeration: " + s + eol);
- }
- if ((s = document.getPages()) != null) {
- texta.append(margin + "Pages: " + s + eol);
- }
- for (Identifier id : document.getIdentifier()) {
- showIdentifier(id);
- }
- if ((s = document.getNote()) != null) {
- texta.append(margin + NOTE + s + eol);
- }
- _level--;
- }
+ texta.append(margin + label + ": " + document.getTitle() + eol);
+ texta.append(margin + TYPE + document.getType() + eol);
+ for (Agent agent : document.getAuthor()) {
+ showAgent(agent, "Author");
+ }
+ for (Agent publisher : document.getPublisher()) {
+ showAgent(publisher, "Publisher");
+ }
+ String s = document.getEdition();
+ if (s != null) {
+ texta.append(margin + "Edition: " + s + eol);
+ }
+ if ((s = document.getDate()) != null) {
+ texta.append(margin + DATE + s + eol);
+ }
+ if ((s = document.getEnumeration()) != null) {
+ texta.append(margin + "Enumeration: " + s + eol);
+ }
+ if ((s = document.getPages()) != null) {
+ texta.append(margin + "Pages: " + s + eol);
+ }
+ for (Identifier id : document.getIdentifier()) {
+ showIdentifier(id);
+ }
+ if ((s = document.getNote()) != null) {
+ texta.append(margin + NOTE + s + eol);
+ }
+ _level--;
+ }
- private void showAgent(Agent agent, String label) {
- String margin = getIndent(++_level);
+ private void showAgent(Agent agent, String label) {
+ String margin = getIndent(++_level);
- texta.append(margin + label + ": " + agent.getName() + eol);
- texta.append(margin + TYPE + agent.getType().toString() + eol);
- String s = agent.getAddress();
- if (s != null) {
- texta.append(margin + "Address: " + s + eol);
- }
- if ((s = agent.getTelephone()) != null) {
- texta.append(margin + "Telephone: " + s + eol);
- }
- if ((s = agent.getFax()) != null) {
- texta.append(margin + "Fax: " + s + eol);
- }
- if ((s = agent.getEmail()) != null) {
- texta.append(margin + "Email: " + s + eol);
- }
- if ((s = agent.getWeb()) != null) {
- texta.append(margin + "Web: " + s + eol);
- }
- _level--;
- }
+ texta.append(margin + label + ": " + agent.getName() + eol);
+ texta.append(margin + TYPE + agent.getType().toString() + eol);
+ String s = agent.getAddress();
+ if (s != null) {
+ texta.append(margin + "Address: " + s + eol);
+ }
+ if ((s = agent.getTelephone()) != null) {
+ texta.append(margin + "Telephone: " + s + eol);
+ }
+ if ((s = agent.getFax()) != null) {
+ texta.append(margin + "Fax: " + s + eol);
+ }
+ if ((s = agent.getEmail()) != null) {
+ texta.append(margin + "Email: " + s + eol);
+ }
+ if ((s = agent.getWeb()) != null) {
+ texta.append(margin + "Web: " + s + eol);
+ }
+ _level--;
+ }
- private void showIdentifier(Identifier identifier) {
- String margin = getIndent(++_level);
+ private void showIdentifier(Identifier identifier) {
+ String margin = getIndent(++_level);
- texta.append(margin + "Identifier: " + identifier.getValue() + eol);
- texta.append(margin + TYPE + identifier.getType().toString() + eol);
- String note = identifier.getNote();
- if (note != null) {
- texta.append(margin + NOTE + note + eol);
- }
- _level--;
- }
+ texta.append(margin + "Identifier: " + identifier.getValue() + eol);
+ texta.append(margin + TYPE + identifier.getType().toString() + eol);
+ String note = identifier.getNote();
+ if (note != null) {
+ texta.append(margin + NOTE + note + eol);
+ }
+ _level--;
+ }
- private String getIndent(int lev) {
- switch (lev) {
- case 1:
- return " ";
- case 2:
- return " ";
- case 3:
- return " ";
- case 4:
- return " ";
- default:
- return "";
- }
- }
+ private String getIndent(int lev) {
+ switch (lev) {
+ case 1:
+ return " ";
+ case 2:
+ return " ";
+ case 3:
+ return " ";
+ case 4:
+ return " ";
+ default:
+ return "";
+ }
+ }
- /**
- * Saves the information to a file
- */
- private void saveInfo() {
- if (_module == null) {
- JOptionPane.showMessageDialog(this, "No module selected",
- "Can't save", JOptionPane.INFORMATION_MESSAGE);
- return;
- }
- PrintWriter wtr = doSaveDialog();
- if (wtr == null) {
- return;
- }
- OutputHandler handler = selectHandler();
- try {
- handler.setWriter(wtr);
- handler.show(_module);
- wtr.close();
- } catch (Exception e) {
- JOptionPane.showMessageDialog(this, e.getMessage(),
- "Error writing file", JOptionPane.ERROR_MESSAGE);
- }
- }
+ /** Saves the information to a file */
+ private void saveInfo() {
+ if (_module == null) {
+ JOptionPane.showMessageDialog(
+ this, "No module selected", "Can't save", JOptionPane.INFORMATION_MESSAGE);
+ return;
+ }
+ PrintWriter wtr = doSaveDialog();
+ if (wtr == null) {
+ return;
+ }
+ OutputHandler handler = selectHandler();
+ try {
+ handler.setWriter(wtr);
+ handler.show(_module);
+ wtr.close();
+ } catch (Exception e) {
+ JOptionPane.showMessageDialog(
+ this, e.getMessage(), "Error writing file", JOptionPane.ERROR_MESSAGE);
+ }
+ }
}
diff --git a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/NoConfAlert.java b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/NoConfAlert.java
index f290f2899..a515267f7 100644
--- a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/NoConfAlert.java
+++ b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/NoConfAlert.java
@@ -1,60 +1,55 @@
-/**********************************************************************
- * JhoveView - JSTOR/Harvard Object Validation Environment
- * Copyright 2003 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** JhoveView - JSTOR/Harvard
+ * Object Validation Environment Copyright 2003 by JSTOR and the President and Fellows of Harvard
+ * College ********************************************************************
+ */
package edu.harvard.hul.ois.jhove.viewer;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-/**
- * This class implements an alert which is posted when no
- * configuration file can be found.
- */
-public class NoConfAlert extends JDialog
-{
- public NoConfAlert (JFrame owner)
- {
- super (owner, "Fatal Error", true);
+/** This class implements an alert which is posted when no configuration file can be found. */
+public class NoConfAlert extends JDialog {
+ public NoConfAlert(JFrame owner) {
+ super(owner, "Fatal Error", true);
+
+ // Create a panel with an informative message.
+ JPanel mainPanel = new JPanel();
+ getContentPane().add(mainPanel, "Center");
+ String infoString =
+ new String(
+ "Jhove could not find "
+ + "a configuration file. You must have one of the "
+ + "following in jhove/conf under your home directory:\n\n"
+ + "(1) A properties file called jhove.properties "
+ + "with a property named edu.harvard.hul.ois.jhove.config "
+ + "having the path to your configuration file as its "
+ + "value; or\n\n"
+ + "(2) A configuration file named jhove.conf\n\n "
+ + "Note: Under Windows, your home directory is the directory "
+ + "with your username under Documents and Settings.\n");
- // Create a panel with an informative message.
- JPanel mainPanel = new JPanel ();
- getContentPane ().add (mainPanel, "Center");
- String infoString = new String ("Jhove could not find " +
- "a configuration file. You must have one of the " +
- "following in jhove/conf under your home directory:\n\n" +
- "(1) A properties file called jhove.properties " +
- "with a property named edu.harvard.hul.ois.jhove.config " +
- "having the path to your configuration file as its " +
- "value; or\n\n" +
- "(2) A configuration file named jhove.conf\n\n " +
- "Note: Under Windows, your home directory is the directory " +
- "with your username under Documents and Settings.\n");
+ JTextArea infoArea = new JTextArea(infoString);
+ infoArea.setLineWrap(true);
+ infoArea.setWrapStyleWord(true);
+ Dimension prefSize = new Dimension(250, 300);
+ infoArea.setMinimumSize(prefSize);
+ infoArea.setPreferredSize(prefSize);
+ mainPanel.add(infoArea);
- JTextArea infoArea = new JTextArea (infoString);
- infoArea.setLineWrap (true);
- infoArea.setWrapStyleWord (true);
- Dimension prefSize = new Dimension (250, 300);
- infoArea.setMinimumSize (prefSize);
- infoArea.setPreferredSize (prefSize);
- mainPanel.add (infoArea);
-
- // Create a panel with a button for quitting.
- JPanel bottomPanel = new JPanel ();
- getContentPane ().add (bottomPanel, "South");
- JButton exitButton = new JButton ("Quit");
- bottomPanel.add (exitButton);
- exitButton.addActionListener (
- new ActionListener () {
- @Override
- public void actionPerformed (ActionEvent e)
- {
- dispose ();
- }
- }
- );
- pack ();
- }
+ // Create a panel with a button for quitting.
+ JPanel bottomPanel = new JPanel();
+ getContentPane().add(bottomPanel, "South");
+ JButton exitButton = new JButton("Quit");
+ bottomPanel.add(exitButton);
+ exitButton.addActionListener(
+ new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ dispose();
+ }
+ });
+ pack();
+ }
}
diff --git a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/NumericField.java b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/NumericField.java
index 6670aa6e7..c285d3ee4 100644
--- a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/NumericField.java
+++ b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/NumericField.java
@@ -1,31 +1,27 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2004 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2004 by JSTOR and the President and Fellows of Harvard College
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove.viewer;
-import javax.swing.*;
import java.text.NumberFormat;
+import javax.swing.*;
/**
- *
* A JTextField which permits only decimal digits
- *
- * @author Gary McGath
*
+ * @author Gary McGath
*/
public class NumericField extends JFormattedTextField {
- // Initializer for number format
- private static NumberFormat numFormat =
- NumberFormat.getIntegerInstance ();
-
- public NumericField (int init)
- {
- super (numFormat);
- numFormat.setGroupingUsed (false);
- numFormat.setParseIntegerOnly (true);
- setValue (new Integer (init));
- }
+ // Initializer for number format
+ private static NumberFormat numFormat = NumberFormat.getIntegerInstance();
+
+ public NumericField(int init) {
+ super(numFormat);
+ numFormat.setGroupingUsed(false);
+ numFormat.setParseIntegerOnly(true);
+ setValue(new Integer(init));
+ }
}
diff --git a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/PrefsWindow.java b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/PrefsWindow.java
index e344c54c8..c4b9af8b4 100644
--- a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/PrefsWindow.java
+++ b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/PrefsWindow.java
@@ -1,120 +1,101 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003 by JSTOR and the President and Fellows of Harvard College
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove.viewer;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-
/**
* Window for setting preferences for the Jhove viewer.
*
* @author Gary McGath
- *
*/
-public class PrefsWindow extends JDialog
-{
- private JhoveWindow jhoveWin;
-
- private JCheckBox rawCheckBox;
- private JCheckBox checksumCheckBox;
-
- /* State saving information */
- private boolean saveRawOutput;
- private boolean saveChecksum;
-
- /**
- * Constructor.
- *
- */
- public PrefsWindow (JhoveWindow owner)
- {
- super (owner, "Jhove Preferences", true);
- addWindowListener (new PrefsWindowListener (this));
- jhoveWin = owner;
- JPanel mainPanel = new JPanel (new GridLayout (4, 1));
- getContentPane ().add (mainPanel, BorderLayout.CENTER);
- rawCheckBox = new JCheckBox ("Raw data", false);
- mainPanel.add (rawCheckBox);
- checksumCheckBox = new JCheckBox ("Calculate checksums", false);
- mainPanel.add (checksumCheckBox);
-
- JPanel bottomPanel = new JPanel (new GridLayout (1, 3));
- getContentPane ().add (bottomPanel, BorderLayout.SOUTH);
- JButton okButton = new JButton ("OK");
- okButton.addActionListener (
- new ActionListener () {
- @Override
- public void actionPerformed (ActionEvent e)
- {
- setPrefsFromDialog ();
- hide ();
- }
- }
- );
- JButton cancelButton = new JButton ("Cancel");
- cancelButton.addActionListener (
- new ActionListener () {
- @Override
- public void actionPerformed (ActionEvent e)
- {
- hide ();
- restore ();
- }
- }
- );
- bottomPanel.add (new JLabel (""));
- bottomPanel.add (cancelButton);
- bottomPanel.add (okButton);
- }
-
- /**
- * This is called when the window is made visible.
- * (For efficiency, it is hidden rather than being
- * disposed when the user clicks OK or cancel.) The
- * state of the dialog is saved, then it is made visible.
- * If the user clicks Cancel, the state of the dialog
- * will be restored.
- */
- public void saveAndShow ()
- {
- saveRawOutput = rawCheckBox.isSelected ();
- saveChecksum = checksumCheckBox.isSelected ();
- show ();
- }
-
- private void restore ()
- {
- rawCheckBox.setSelected (saveRawOutput);
- checksumCheckBox.setSelected (saveChecksum);
- }
-
- private void setPrefsFromDialog ()
- {
- jhoveWin.setRawOutput (rawCheckBox.isSelected ());
- jhoveWin.setDoChecksum(checksumCheckBox.isSelected ());
+public class PrefsWindow extends JDialog {
+ private JhoveWindow jhoveWin;
+
+ private JCheckBox rawCheckBox;
+ private JCheckBox checksumCheckBox;
+
+ /* State saving information */
+ private boolean saveRawOutput;
+ private boolean saveChecksum;
+
+ /** Constructor. */
+ public PrefsWindow(JhoveWindow owner) {
+ super(owner, "Jhove Preferences", true);
+ addWindowListener(new PrefsWindowListener(this));
+ jhoveWin = owner;
+ JPanel mainPanel = new JPanel(new GridLayout(4, 1));
+ getContentPane().add(mainPanel, BorderLayout.CENTER);
+ rawCheckBox = new JCheckBox("Raw data", false);
+ mainPanel.add(rawCheckBox);
+ checksumCheckBox = new JCheckBox("Calculate checksums", false);
+ mainPanel.add(checksumCheckBox);
+
+ JPanel bottomPanel = new JPanel(new GridLayout(1, 3));
+ getContentPane().add(bottomPanel, BorderLayout.SOUTH);
+ JButton okButton = new JButton("OK");
+ okButton.addActionListener(
+ new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ setPrefsFromDialog();
+ hide();
+ }
+ });
+ JButton cancelButton = new JButton("Cancel");
+ cancelButton.addActionListener(
+ new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ hide();
+ restore();
+ }
+ });
+ bottomPanel.add(new JLabel(""));
+ bottomPanel.add(cancelButton);
+ bottomPanel.add(okButton);
+ }
+
+ /**
+ * This is called when the window is made visible. (For efficiency, it is hidden rather than being
+ * disposed when the user clicks OK or cancel.) The state of the dialog is saved, then it is made
+ * visible. If the user clicks Cancel, the state of the dialog will be restored.
+ */
+ public void saveAndShow() {
+ saveRawOutput = rawCheckBox.isSelected();
+ saveChecksum = checksumCheckBox.isSelected();
+ show();
+ }
+
+ private void restore() {
+ rawCheckBox.setSelected(saveRawOutput);
+ checksumCheckBox.setSelected(saveChecksum);
+ }
+
+ private void setPrefsFromDialog() {
+ jhoveWin.setRawOutput(rawCheckBox.isSelected());
+ jhoveWin.setDoChecksum(checksumCheckBox.isSelected());
+ }
+
+ /**
+ * ****************************************************** WindowAdapter subclass for handling
+ * window closing ******************************************************
+ */
+ private class PrefsWindowListener extends WindowAdapter {
+ private PrefsWindow prefsWin;
+
+ public PrefsWindowListener(PrefsWindow w) {
+ prefsWin = w;
}
-
- /********************************************************
- * WindowAdapter subclass for handling window closing
- ********************************************************/
-
- private class PrefsWindowListener extends WindowAdapter
- {
- private PrefsWindow prefsWin;
-
- public PrefsWindowListener (PrefsWindow w) {
- prefsWin = w;
- }
-
-
- @Override
- public void windowClosing (WindowEvent e) {
- prefsWin.restore ();
- }
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ prefsWin.restore();
}
+ }
}
diff --git a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/ProgressWindow.java b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/ProgressWindow.java
index b488f1c3a..521ac4fe4 100644
--- a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/ProgressWindow.java
+++ b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/ProgressWindow.java
@@ -1,176 +1,155 @@
-/**********************************************************************
- * JhoveView - JSTOR/Harvard Object Validation Environment
- * Copyright 2003 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** JhoveView - JSTOR/Harvard
+ * Object Validation Environment Copyright 2003 by JSTOR and the President and Fellows of Harvard
+ * College ********************************************************************
+ */
package edu.harvard.hul.ois.jhove.viewer;
import java.awt.*;
-import javax.swing.*;
import java.awt.event.*;
+import javax.swing.*;
/**
- * Window for showing progress of file processing.
- * We may or may not have the total length available;
- * if we do, we show the total length as part of the
- * information.
- * Normally we keep one window alive for the whole application,
- * showing and hiding it as needed.
+ * Window for showing progress of file processing. We may or may not have the total length
+ * available; if we do, we show the total length as part of the information. Normally we keep one
+ * window alive for the whole application, showing and hiding it as needed.
*/
-public class ProgressWindow extends JFrame{
-
- private long _contentLength;
- private long _byteCount;
- private String _docName;
- private JLabel _progressLabel;
- private JLabel _docNameLabel;
- private int _progressState;
-
- /**
- * Progress state: Indeterminate or not yet started.
- */
- public final static int UNKNOWN = 0;
- /**
- * Progress state: URI is being downloaded.
- */
- public final static int DOWNLOADING = 1;
- /**
- * Progress state: Processing the document.
- */
- public final static int PROCESSING = 2;
-
- private final static String DIALOG = "Dialog";
-
-
- /**
- * Constructor.
- *
- * @param canceler An ActionListener which responds to the
- * Cancel button.
- */
- public ProgressWindow (ActionListener canceler)
- {
- Font fileFont = new Font (DIALOG, Font.PLAIN, 14);
- Font progFont = new Font (DIALOG, Font.PLAIN, 12);
- Dimension labelDim = new Dimension (460, 24);
- _docNameLabel = new JLabel ();
- _docNameLabel.setHorizontalAlignment (SwingConstants.CENTER);
- _docNameLabel.setFont (fileFont);
- _docNameLabel.setMinimumSize (labelDim);
- _docNameLabel.setPreferredSize (labelDim);
- getContentPane ().add (_docNameLabel, BorderLayout.NORTH);
-
- _progressLabel = new JLabel ();
- _progressLabel.setHorizontalAlignment (SwingConstants.CENTER);
- _progressLabel.setFont (progFont);
- _progressLabel.setMinimumSize (labelDim);
- _progressLabel.setPreferredSize (labelDim);
- getContentPane ().add (_progressLabel, BorderLayout.CENTER);
-
- // Put the Cancel button inside a panel so it doesn't
- // fill the whole space.
- JPanel botPanel = new JPanel ();
- getContentPane ().add (botPanel, BorderLayout.SOUTH);
- JButton cancelButton = new JButton ("Cancel");
- botPanel.add (cancelButton);
- cancelButton.addActionListener (canceler);
-
- setTitle ("Progress");
- setDefaultCloseOperation (WindowConstants.DO_NOTHING_ON_CLOSE);
- pack ();
- MainScreen.centerTopWindow (this);
-
- _contentLength = -1;
- _byteCount = -1;
- _progressState = UNKNOWN;
+public class ProgressWindow extends JFrame {
+
+ private long _contentLength;
+ private long _byteCount;
+ private String _docName;
+ private JLabel _progressLabel;
+ private JLabel _docNameLabel;
+ private int _progressState;
+
+ /** Progress state: Indeterminate or not yet started. */
+ public static final int UNKNOWN = 0;
+ /** Progress state: URI is being downloaded. */
+ public static final int DOWNLOADING = 1;
+ /** Progress state: Processing the document. */
+ public static final int PROCESSING = 2;
+
+ private static final String DIALOG = "Dialog";
+
+ /**
+ * Constructor.
+ *
+ * @param canceler An ActionListener which responds to the Cancel button.
+ */
+ public ProgressWindow(ActionListener canceler) {
+ Font fileFont = new Font(DIALOG, Font.PLAIN, 14);
+ Font progFont = new Font(DIALOG, Font.PLAIN, 12);
+ Dimension labelDim = new Dimension(460, 24);
+ _docNameLabel = new JLabel();
+ _docNameLabel.setHorizontalAlignment(SwingConstants.CENTER);
+ _docNameLabel.setFont(fileFont);
+ _docNameLabel.setMinimumSize(labelDim);
+ _docNameLabel.setPreferredSize(labelDim);
+ getContentPane().add(_docNameLabel, BorderLayout.NORTH);
+
+ _progressLabel = new JLabel();
+ _progressLabel.setHorizontalAlignment(SwingConstants.CENTER);
+ _progressLabel.setFont(progFont);
+ _progressLabel.setMinimumSize(labelDim);
+ _progressLabel.setPreferredSize(labelDim);
+ getContentPane().add(_progressLabel, BorderLayout.CENTER);
+
+ // Put the Cancel button inside a panel so it doesn't
+ // fill the whole space.
+ JPanel botPanel = new JPanel();
+ getContentPane().add(botPanel, BorderLayout.SOUTH);
+ JButton cancelButton = new JButton("Cancel");
+ botPanel.add(cancelButton);
+ cancelButton.addActionListener(canceler);
+
+ setTitle("Progress");
+ setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+ pack();
+ MainScreen.centerTopWindow(this);
+
+ _contentLength = -1;
+ _byteCount = -1;
+ _progressState = UNKNOWN;
+ }
+
+ /**
+ * Set the total length to be displayed. If this is set to a positive number, then the display
+ * will show "xxxx bytes of yyyy". If it is not set, or is set to a zero or negative number, the
+ * display will show "xxxx bytes".
+ *
+ * @param length The length to display
+ * @param update If I need to break out part of the ViewWindow code to here so it can produce the output for one
+ * file.
+ */
+ @Override
+ public void show(RepInfo info) {
+ _viewWin.addRepInfo(info, _base);
+ ++nDocs;
+ }
+
+ @Override
+ public void show() {}
+
+ @Override
+ public void show(App app) {}
+
+ @Override
+ public void show(Module module) {}
+
+ /** Complete the output. Does this have to do anything? */
+ @Override
+ public void showFooter() {
+ // If no files were processed, just discard the window. */
+ if (nDocs == 0) {
+ _viewWin.dispose();
+ }
+ // We synchronize this against the modal dialogs,
+ // since otherwise the application is apt to put up
+ // viewWin as a frozen window over the modal dialog.
+ synchronized (syncStr) {
+ // MainScreen.centerWindow (viewWin);
+ _viewWin.setLocation(viewWinXPos, viewWinYPos);
+ viewWinXPos += viewWinXInc;
+ viewWinYPos += viewWinYInc;
+
+ // After a while, cycle back to the original positions
+ // After a while, cycle back to the original positions
+ if (viewWinXPos > viewWinOrigXPos + 320) {
+ viewWinXPos = viewWinOrigXPos;
+ }
+ if (viewWinYPos > viewWinOrigYPos + 160) {
+ viewWinYPos = viewWinOrigYPos;
+ }
+ _viewWin.setVisible(true);
+ }
+ _viewWin.expandRows();
+ _viewWin.setVisible(true);
+ }
+
+ /**
+ * Outputs information about the OutputHandler specified in the parameter. Since this never should
+ * occur in a normal list of handlers, it's unnecessary to do anything (I think).
+ */
+ @Override
+ public void show(OutputHandler handler) {}
}
diff --git a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/ViewWindow.java b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/ViewWindow.java
index 2425c92fa..ee0d12e7e 100644
--- a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/ViewWindow.java
+++ b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/ViewWindow.java
@@ -1,175 +1,158 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2004-2012 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2004-2012 by JSTOR and the President and Fellows of Harvard
+ * College ********************************************************************
+ */
package edu.harvard.hul.ois.jhove.viewer;
+import edu.harvard.hul.ois.jhove.*;
import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.io.*;
+import java.util.*;
import javax.swing.*;
import javax.swing.tree.*;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-import java.util.*;
-import edu.harvard.hul.ois.jhove.*;
/**
- * This is the main window for viewing the results of a file analysis.
- * Multiple instances of InfoWindow are allowed; they are deleted
- * when closed. The URI of the analyzed object is used as the window
- * title. A JTree is used to display the information.
- *
- * The earlier version of this class displayed a single file. This
- * version is controlled by a ViewHandler, which displays multiple
- * files within a single window. There can still be multiple
- * ViewWindows, but each will come from a separate operation.
- * Dragging a directory to the main window will produce a single
- * ViewWindow; dragging a group of files will produce
- * multiple windows.
+ * This is the main window for viewing the results of a file analysis. Multiple instances of
+ * InfoWindow are allowed; they are deleted when closed. The URI of the analyzed object is used as
+ * the window title. A JTree is used to display the information.
*
+ * The earlier version of this class displayed a single file. This version is controlled by a
+ * ViewHandler, which displays multiple files within a single window. There can still be multiple
+ * ViewWindows, but each will come from a separate operation. Dragging a directory to the main
+ * window will produce a single ViewWindow; dragging a group of files will produce multiple windows.
*/
public class ViewWindow extends InfoWindow {
- private java.util.List ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
import java.util.*;
@@ -12,959 +13,866 @@
* Encapsulation of the AES Metadata for Audio documents
*
* @author Gary McGath
- *
*/
-public class AESAudioMetadata
-{
- /******************************************************************
- * PUBLIC CLASS FIELDS.
- ******************************************************************/
-
- /** Big-endian constant. */
- public static final int BIG_ENDIAN = 0;
-
- /** Little-endian constant. */
- public static final int LITTLE_ENDIAN = 1;
-
- /** Analog / digital labels. */
- public static final String [] A_D = {
- "ANALOG", "PHYS_DIGITAL", "FILE_DIGITAL"
- };
-
- /** Values for primary identifier type */
- public static final String
- FILE_NAME = "FILE_NAME",
- OTHER = "OTHER";
-
- /** Constant for an undefined integer value. */
- public static final int NULL = -1;
- /** Constant for an undefined floating-point value. */
- public static final double NILL = -1.0;
-
- /******************************************************************
- * PRIVATE INSTANCE FIELDS.
+public class AESAudioMetadata {
+ /**
+ * **************************************************************** PUBLIC CLASS FIELDS.
+ * ****************************************************************
+ */
+
+ /** Big-endian constant. */
+ public static final int BIG_ENDIAN = 0;
+
+ /** Little-endian constant. */
+ public static final int LITTLE_ENDIAN = 1;
+
+ /** Analog / digital labels. */
+ public static final String[] A_D = {"ANALOG", "PHYS_DIGITAL", "FILE_DIGITAL"};
+
+ /** Values for primary identifier type */
+ public static final String FILE_NAME = "FILE_NAME", OTHER = "OTHER";
+
+ /** Constant for an undefined integer value. */
+ public static final int NULL = -1;
+ /** Constant for an undefined floating-point value. */
+ public static final double NILL = -1.0;
+
+ /**
+ * **************************************************************** PRIVATE INSTANCE FIELDS.
+ *
+ * ****************************************************************
+ */
+
+ /** Constant value for the SchemaVersion field */
+ public static final String SCHEMA_VERSION = "1.02b";
+
+ /** Constant value for the disposition field */
+ private static final String DEFAULT_DISPOSITION = "validation";
+
+ private String _analogDigitalFlag;
+ private String _appSpecificData;
+ private String _audioDataEncoding;
+ private int _byteOrder;
+ private String _disposition;
+ private List ****************************************************************
+ */
+ /**
+ * Public interface to the nested FormatRegion object. Instances of this should be created only by
+ * addFormatRegion, but can be accessed through the public methods of this interface.
+ */
+ public static interface FormatRegion {
+ /** Returns the bit depth. */
+ public int getBitDepth();
+ /**
+ * Returns the bitrate reduction (compression information). This will be an array of seven
+ * strings (which may be empty, but should never be null) interpreted as follows:
*
- ******************************************************************/
-
- /** Constant value for the SchemaVersion field */
- public static final String SCHEMA_VERSION = "1.02b";
-
- /** Constant value for the disposition field */
- private static final String DEFAULT_DISPOSITION = "validation";
-
- private String _analogDigitalFlag;
- private String _appSpecificData;
- private String _audioDataEncoding;
- private int _byteOrder;
- private String _disposition;
- private List ****************************************************************
+ */
+ /**
+ * The implementation of the FormatRegion interface. The combination of a public interface and a
+ * private implementation is suggested in _Java in a Nutshell_.
+ */
+ class FormatRegionImpl implements FormatRegion {
- /** Returns primary identifier. */
- public String getPrimaryIdentifier ()
- {
- return _primaryIdentifier;
+ private int _bitDepth;
+ private double _sampleRate;
+ private int _wordSize;
+ private String[] _bitrateReduction;
+
+ public FormatRegionImpl() {
+ _bitDepth = NULL;
+ _sampleRate = NILL;
+ _wordSize = NULL;
+ _bitrateReduction = null;
}
- /** Returns primary identifier type. */
- public String getPrimaryIdentifierType ()
- {
- return _primaryIdentifierType;
+ /** Returns bit depth. */
+ @Override
+ public int getBitDepth() {
+ return _bitDepth;
}
- /** Returns schema version. */
- public String getSchemaVersion ()
- {
- return _schemaVersion;
+ /**
+ * Returns the bitrate reduction (compression information). This will be an array of seven
+ * strings (which may be empty but not null) interpreted respectively as follows:
+ *
+ * Accessor methods. ****************************************************************
+ */
+
+ /** Returns analog/digital flag. Value will always be "FILE_DIGITAL" in practice. */
+ public String getAnalogDigitalFlag() {
+ return _analogDigitalFlag;
+ }
+
+ /** Returns application-specific data. We assume this is representable in String format. */
+ public String getAppSpecificData() {
+ return _appSpecificData;
+ }
+
+ /** Returns audio data encoding. */
+ public String getAudioDataEncoding() {
+ return _audioDataEncoding;
+ }
+
+ /**
+ * Returns the bitrate reduction (compression information). This will be an array of seven strings
+ * (which may be empty, but should never be null) interpreted as follows:
+ *
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
/**
- * This class defines enumerated types for the analog/digital
- * flag of AESAudioMetadata.
- * Applications will not create or modify instances of this class, but will
- * use one of the predefined AnalogDigitalFlagType instances.
- *
- * @author Gary McGath
+ * This class defines enumerated types for the analog/digital flag of AESAudioMetadata. Applications
+ * will not create or modify instances of this class, but will use one of the predefined
+ * AnalogDigitalFlagType instances.
*
+ * @author Gary McGath
*/
public enum AnalogDigitalFlagType {
- /** Enumeration instance for analog data */
- ANALOG("ANALOG"),
- /** Enumeration instance for physical digital data */
- PHYS_DIGITAL("PHYS_DIGITAL"),
- /** Enumeration instance for FILE digital data */
- FILE_DIGITAL("FILE_DIGITAL");
- /** A String value for the type */
- public final String value;
-
- private AnalogDigitalFlagType(final String value) {
- this.value = value;
- }
+ /** Enumeration instance for analog data */
+ ANALOG("ANALOG"),
+ /** Enumeration instance for physical digital data */
+ PHYS_DIGITAL("PHYS_DIGITAL"),
+ /** Enumeration instance for FILE digital data */
+ FILE_DIGITAL("FILE_DIGITAL");
+ /** A String value for the type */
+ public final String value;
+ private AnalogDigitalFlagType(final String value) {
+ this.value = value;
+ }
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/App.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/App.java
index 4a1b504d5..00707249f 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/App.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/App.java
@@ -1,8 +1,8 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment Copyright 2003 by JSTOR
- * and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003 by JSTOR and the President and Fellows of Harvard College
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
import java.util.Calendar;
@@ -11,136 +11,125 @@
import org.openpreservation.jhove.ReleaseDetails;
/**
- * The application class for JHOVE. One instance of this class is generated by
- * the application. Various utility and informational methods are contained
- * here.
+ * The application class for JHOVE. One instance of this class is generated by the application.
+ * Various utility and informational methods are contained here.
*/
public final class App {
- private static final String NAME = "JHOVE";
-
- /** Application invocation syntax. */
- private static final String USAGE = "java " + NAME + " [-c config] " +
- "[-m module] [-h handler] [-e encoding] [-H handler] [-o output] " +
- "[-x saxclass] [-t tempdir] [-b bufsize] [-l loglevel] [[-krs] " +
- "dir-file-or-uri [...]]";
-
-
- /******************************************************************
- * PRIVATE INSTANCE FIELDS.
- ******************************************************************/
-
- /** Application build date. */
- private final Date _date;
-
- /** Application name. */
- private final String _name;
-
- /** Application release identifier. */
- private String _release;
-
- /** Application rights statement. */
- private final String _rights;
-
- /** Application invocation syntax. */
- private final String _usage;
-
- /******************************************************************
- * CLASS CONSTRUCTOR.
- ******************************************************************/
-
- /**
- * Creates an App object.
- *
- * @param name
- * Name of the application.
- * @param release
- * Release identifier.
- * @param date
- * Last modification date of the application code, in the form of
- * an array of three numbers. Accessor methods. ****************************************************************
+ */
+
+ /** Returns application code creation date */
+ public Date getDate() {
+ return _date;
+ }
+
+ /** Returns the name of this application */
+ public String getName() {
+ return _name;
+ }
+
+ /** Returns the release identifier for this application. */
+ public String getRelease() {
+ return _release;
+ }
+
+ /** Returns the rights string. */
+ public String getRights() {
+ return _rights;
+ }
+
+ /**
+ * Returns the usage string, which should be output when the user enters a command line with only
+ * the application name.
+ */
+ public String getUsage() {
+ return _usage;
+ }
+
+ /**
+ * **************************************************************** Serialization methods.
+ * ****************************************************************
+ */
+
+ /**
+ * Outputs detailed information about the application, including configuration, available modules
+ * and handlers, etc.
+ */
+ public void show(OutputHandler handler) {
+ handler.show(this);
+ }
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ByteArrayXMPSource.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ByteArrayXMPSource.java
index d7e182f95..14dfadc16 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ByteArrayXMPSource.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ByteArrayXMPSource.java
@@ -1,66 +1,54 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003 by JSTOR and the President and Fellows of Harvard College
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003 by JSTOR and the President and Fellows of Harvard College
*
- **********************************************************************/
-
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
import java.io.*;
/**
- * Class for providing an InputSource to XMPHandler,
- * with a ByteArrayInputStream as the basis of the
- * InputSource. This is suitable for a number of modules.
- *
- * @author Gary McGath
+ * Class for providing an InputSource to XMPHandler, with a ByteArrayInputStream as the basis of the
+ * InputSource. This is suitable for a number of modules.
*
+ * @author Gary McGath
*/
public class ByteArrayXMPSource extends XMPSource {
- /* The underlying ByteArrayInputStream. */
- ByteArrayInputStream _instrm;
-
- /**
- * Constructor based on ByteArrayInputStream.
- *
- * @param instrm ByteArrayInputStream containing the XMP
- */
- public ByteArrayXMPSource (ByteArrayInputStream instrm)
- {
- super (new InputStreamReader
- (new XMLWrapperStream (instrm)));
- _instrm = instrm;
- // Prepare for resetting.
- instrm.mark (instrm.available ());
- }
-
-
- /**
- * Constructor based on ByteArrayInputStream with encoding.
- *
- * @param instrm ByteArrayInputStream containing the XMP
- */
- public ByteArrayXMPSource (ByteArrayInputStream instrm,
- String encoding)
- throws IOException
- {
- super (new InputStreamReader
- (new XMLWrapperStream (instrm), encoding));
- _instrm = instrm;
- // Prepare for resetting.
- instrm.mark (instrm.available ());
- }
-
-
-
- /* (non-Javadoc)
- * @see edu.harvard.hul.ois.jhove.XMPSource#resetReader()
- */
- @Override
- protected void resetReader() {
- _instrm.reset ();
- _reader = new InputStreamReader (_instrm);
- }
-
+ /* The underlying ByteArrayInputStream. */
+ ByteArrayInputStream _instrm;
+
+ /**
+ * Constructor based on ByteArrayInputStream.
+ *
+ * @param instrm ByteArrayInputStream containing the XMP
+ */
+ public ByteArrayXMPSource(ByteArrayInputStream instrm) {
+ super(new InputStreamReader(new XMLWrapperStream(instrm)));
+ _instrm = instrm;
+ // Prepare for resetting.
+ instrm.mark(instrm.available());
+ }
+
+ /**
+ * Constructor based on ByteArrayInputStream with encoding.
+ *
+ * @param instrm ByteArrayInputStream containing the XMP
+ */
+ public ByteArrayXMPSource(ByteArrayInputStream instrm, String encoding) throws IOException {
+ super(new InputStreamReader(new XMLWrapperStream(instrm), encoding));
+ _instrm = instrm;
+ // Prepare for resetting.
+ instrm.mark(instrm.available());
+ }
+
+ /* (non-Javadoc)
+ * @see edu.harvard.hul.ois.jhove.XMPSource#resetReader()
+ */
+ @Override
+ protected void resetReader() {
+ _instrm.reset();
+ _reader = new InputStreamReader(_instrm);
+ }
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Callback.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Callback.java
index 708026c6f..9a8703e13 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Callback.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Callback.java
@@ -1,25 +1,20 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
-package edu.harvard.hul.ois.jhove;
-
/**
- * An interface for supporting a general, simple callback function.
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003 by JSTOR and the President and Fellows of Harvard College
+ * ********************************************************************
*/
-public interface Callback
-{
- /**
- * A generic callback function. Any class which needs to support
- * callback can implement callback and pass a reference to itself
- * to the function that does the callback.
- *
- * @param selector An indicator of the function to be performed.
- * Interpretation is determined by the implementing class.
- * @param parm Whatever data may be appropriate to the callback.
- *
- * @return As specified by the implementing class.
- */
- public int callback (int selector, Object parm);
+package edu.harvard.hul.ois.jhove;
+
+/** An interface for supporting a general, simple callback function. */
+public interface Callback {
+ /**
+ * A generic callback function. Any class which needs to support callback can implement callback
+ * and pass a reference to itself to the function that does the callback.
+ *
+ * @param selector An indicator of the function to be performed. Interpretation is determined by
+ * the implementing class.
+ * @param parm Whatever data may be appropriate to the callback.
+ * @return As specified by the implementing class.
+ */
+ public int callback(int selector, Object parm);
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Checksum.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Checksum.java
index a7be0ffaf..0fb13baa1 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Checksum.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Checksum.java
@@ -1,93 +1,75 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003 by JSTOR and the President and Fellows of Harvard College
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
-
/**
- * This class encapsulates the result of calculations which provide a greater
- * or lesser degree of confirmation of the integrity of a digital
- * object's content, including checksums, CRC's, message digests,
- * etc.
+ * This class encapsulates the result of calculations which provide a greater or lesser degree of
+ * confirmation of the integrity of a digital object's content, including checksums, CRC's, message
+ * digests, etc.
*
- * @see ChecksumType
- * @see Checksummer
+ * @see ChecksumType
+ * @see Checksummer
*/
-public class Checksum
-{
- /******************************************************************
- * PRIVATE INSTANCE FIELDS.
- ******************************************************************/
-
- private ChecksumType _type;
- private String _value;
+public class Checksum {
+ /**
+ * **************************************************************** PRIVATE INSTANCE FIELDS.
+ * ****************************************************************
+ */
+ private ChecksumType _type;
- /******************************************************************
- * CLASS CONSTRUCTOR.
- ******************************************************************/
+ private String _value;
- /**
- * Creates a Checksum with a given value and type
- */
- public Checksum (String value, ChecksumType type)
- {
- _value = value;
- _type = type;
- }
+ /**
+ * **************************************************************** CLASS CONSTRUCTOR.
+ * ****************************************************************
+ */
+ /** Creates a Checksum with a given value and type */
+ public Checksum(String value, ChecksumType type) {
+ _value = value;
+ _type = type;
+ }
- /******************************************************************
- * PUBLIC INSTANCE METHODS.
- *
- * Accessor methods.
- ******************************************************************/
+ /**
+ * **************************************************************** PUBLIC INSTANCE METHODS.
+ *
+ * Accessor methods. ****************************************************************
+ */
- /**
- * Returns this Checksum's type
- */
- public ChecksumType getType ()
- {
- return _type;
- }
+ /** Returns this Checksum's type */
+ public ChecksumType getType() {
+ return _type;
+ }
- /**
- * Returns this Checksum's value
- */
- public String getValue ()
- {
- return _value;
- }
+ /** Returns this Checksum's value */
+ public String getValue() {
+ return _value;
+ }
- /******************************************************************
- * Mutator methods.
- ******************************************************************/
+ /**
+ * **************************************************************** Mutator methods.
+ * ****************************************************************
+ */
- /**
- * Sets the type of this Checksum
- */
- public void setType (ChecksumType type)
- {
- _type = type;
- }
+ /** Sets the type of this Checksum */
+ public void setType(ChecksumType type) {
+ _type = type;
+ }
- /**
- * Sets the value of this Checksum
- */
- public void setValue (String value)
- {
- _value = value;
- }
+ /** Sets the value of this Checksum */
+ public void setValue(String value) {
+ _value = value;
+ }
- /******************************************************************
- * Put here as a convenience for checksum calculators
- *****************************************************************/
- /**
- * Maps unsigned byte value (0 to 256) to signed byte value (-128 to 127).
- */
- public static byte unsignedByteToByte (int value)
- {
- return (byte) ((value < 127) ? value : value - 256);
- }
+ /**
+ * **************************************************************** Put here as a convenience for
+ * checksum calculators ***************************************************************
+ */
+ /** Maps unsigned byte value (0 to 256) to signed byte value (-128 to 127). */
+ public static byte unsignedByteToByte(int value) {
+ return (byte) ((value < 127) ? value : value - 256);
+ }
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ChecksumInputStream.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ChecksumInputStream.java
index 3fdb7fe14..e62678fff 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ChecksumInputStream.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ChecksumInputStream.java
@@ -1,150 +1,127 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003-2006 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003-2006 by JSTOR and the President and Fellows of Harvard
+ * College ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
-import java.io.IOException;
import java.io.*;
+import java.io.IOException;
/**
- * A ChecksumInputStream is a FilterInputStream with the added
- * functionality of calculating checksums as it goes.
- *
- * The idea of replacing this with java.util.zip.CheckedInputStream
- * looks very tempting, but we need the byte count, which
- * CheckedInputStream doesn't provide.
- *
- * @author Gary McGath
+ * A ChecksumInputStream is a FilterInputStream with the added functionality of calculating
+ * checksums as it goes.
+ *
+ * The idea of replacing this with java.util.zip.CheckedInputStream looks very tempting, but we
+ * need the byte count, which CheckedInputStream doesn't provide.
*
+ * @author Gary McGath
*/
public class ChecksumInputStream extends FilterInputStream {
- private InputStream subsumedStream;
- private Checksummer _cksummer;
- private long _nBytes;
-
- /**
- * Constructor.
- *
- * @param stream Stream to be filtered
- * @param cksummer Object to calculate checksum on the bytes
- * as they are read
- */
- public ChecksumInputStream(InputStream stream, Checksummer cksummer) {
- super (stream);
- subsumedStream = stream;
- _cksummer = cksummer;
- _nBytes = 0;
- }
+ private InputStream subsumedStream;
+ private Checksummer _cksummer;
+ private long _nBytes;
- /**
- * Reads a byte from the subsumed stream, updating
- * the byte count and the checksums.
- */
- @Override
- public int read() throws IOException {
- int ch = subsumedStream.read ();
- if (ch >= 0) {
- _nBytes++;
- if (_cksummer != null) {
- _cksummer.update (ch);
- }
- }
- return ch;
- }
+ /**
+ * Constructor.
+ *
+ * @param stream Stream to be filtered
+ * @param cksummer Object to calculate checksum on the bytes as they are read
+ */
+ public ChecksumInputStream(InputStream stream, Checksummer cksummer) {
+ super(stream);
+ subsumedStream = stream;
+ _cksummer = cksummer;
+ _nBytes = 0;
+ }
- /**
- * Reads some number of bytes from the input stream and
- * stores them into the buffer array b. The number of
- * bytes actually read is returned as an integer.
- *
- * All bytes read are fed through the checksummer.
- */
- @Override
- public int read(byte[] b) throws IOException
- {
- int len = subsumedStream.read (b);
- // Careful here -- don't want to add -1 bytes at EOF
- if (len > 0) {
- if (_cksummer != null) {
- _cksummer.update (b);
- }
- _nBytes += len;
- }
- return len;
- }
-
- /**
- * Reads up to len bytes of data from the input stream
- * into an array of bytes. An attempt is made to read as
- * many as len bytes, but a smaller number may be read,
- * possibly zero. The number of bytes actually read is
- * returned as an integer.
- *
- * All bytes read are fed through the checksummer.
- */
- @Override
- public int read(byte[] b, int off, int len) throws IOException
- {
- len = subsumedStream.read (b, off, len);
- // Careful here -- don't want to add -1 bytes at EOF
- if (len > 0) {
- if (_cksummer != null) {
- _cksummer.update (b, off, len);
- }
- _nBytes += len;
- }
- return len;
- }
-
- /**
- * Skips n bytes.
- * Reads them and feeds them through the checksummer.
- */
- @Override
- public long skip (long n) throws IOException {
- long nret = 0;
- while (n > 0) {
- // grab the data in reasonable buffer-sized chunks.
- int bufsize = (int) (n > 8192 ? 8192 : n);
- byte[] buf = new byte[bufsize];
- int nread = read (buf);
- if (nread <= 0) {
- break;
- }
- nret += nread;
- n -= nread;
- }
- return nret;
+ /** Reads a byte from the subsumed stream, updating the byte count and the checksums. */
+ @Override
+ public int read() throws IOException {
+ int ch = subsumedStream.read();
+ if (ch >= 0) {
+ _nBytes++;
+ if (_cksummer != null) {
+ _cksummer.update(ch);
+ }
}
-
- /**
- * Closes the subsumed stream.
- */
- @Override
- public void close () throws IOException
- {
- subsumedStream.close();
+ return ch;
+ }
+
+ /**
+ * Reads some number of bytes from the input stream and stores them into the buffer array b. The
+ * number of bytes actually read is returned as an integer.
+ *
+ * All bytes read are fed through the checksummer.
+ */
+ @Override
+ public int read(byte[] b) throws IOException {
+ int len = subsumedStream.read(b);
+ // Careful here -- don't want to add -1 bytes at EOF
+ if (len > 0) {
+ if (_cksummer != null) {
+ _cksummer.update(b);
+ }
+ _nBytes += len;
}
-
- /**
- * Returns the byte count to date on the stream.
- * This returns the number of bytes read.
- * Because of buffering, this is not a reliable
- * indicator of how many bytes have actually been processed.
- */
- public long getNBytes ()
- {
- return _nBytes;
+ return len;
+ }
+
+ /**
+ * Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made
+ * to read as many as len bytes, but a smaller number may be read, possibly zero. The number of
+ * bytes actually read is returned as an integer.
+ *
+ * All bytes read are fed through the checksummer.
+ */
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ len = subsumedStream.read(b, off, len);
+ // Careful here -- don't want to add -1 bytes at EOF
+ if (len > 0) {
+ if (_cksummer != null) {
+ _cksummer.update(b, off, len);
+ }
+ _nBytes += len;
}
-
- /**
- * Returns the Checksummer object.
- */
- public Checksummer getChecksummer ()
- {
- return _cksummer;
+ return len;
+ }
+
+ /** Skips n bytes. Reads them and feeds them through the checksummer. */
+ @Override
+ public long skip(long n) throws IOException {
+ long nret = 0;
+ while (n > 0) {
+ // grab the data in reasonable buffer-sized chunks.
+ int bufsize = (int) (n > 8192 ? 8192 : n);
+ byte[] buf = new byte[bufsize];
+ int nread = read(buf);
+ if (nread <= 0) {
+ break;
+ }
+ nret += nread;
+ n -= nread;
}
+ return nret;
+ }
+
+ /** Closes the subsumed stream. */
+ @Override
+ public void close() throws IOException {
+ subsumedStream.close();
+ }
+
+ /**
+ * Returns the byte count to date on the stream. This returns the number of bytes read. Because of
+ * buffering, this is not a reliable indicator of how many bytes have actually been processed.
+ */
+ public long getNBytes() {
+ return _nBytes;
+ }
+
+ /** Returns the Checksummer object. */
+ public Checksummer getChecksummer() {
+ return _cksummer;
+ }
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ChecksumType.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ChecksumType.java
index 50a4119ea..657761fb8 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ChecksumType.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ChecksumType.java
@@ -1,37 +1,35 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003 by JSTOR and the President and Fellows of Harvard College
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
/**
- * This class defines enumerated types for a Checksum on a content
- * stream or file.
- * Applications will not create or modify ChecksumTypes, but will
- * use one of the predefined ChecksumType instances
+ * This class defines enumerated types for a Checksum on a content stream or file. Applications will
+ * not create or modify ChecksumTypes, but will use one of the predefined ChecksumType instances
* CRC32, MD5, SHA1, or SHA256.
*
* @see Checksum
*/
public enum ChecksumType {
- /** 32-bit Cyclical Redundancy Checksum. */
- CRC32("CRC32"),
- /** 128-bit Message Digest 5. */
- MD5("MD5"),
- /** 160-bit Secure Hash Algorithm. */
- SHA1("SHA-1"),
- /** 256-bit Secure Hash Algorithm. */
- SHA256("SHA-256");
- /** A String name for the type, used for reporting. */
- public final String name;
+ /** 32-bit Cyclical Redundancy Checksum. */
+ CRC32("CRC32"),
+ /** 128-bit Message Digest 5. */
+ MD5("MD5"),
+ /** 160-bit Secure Hash Algorithm. */
+ SHA1("SHA-1"),
+ /** 256-bit Secure Hash Algorithm. */
+ SHA256("SHA-256");
+ /** A String name for the type, used for reporting. */
+ public final String name;
- private ChecksumType(final String name) {
- this.name = name;
- }
+ private ChecksumType(final String name) {
+ this.name = name;
+ }
- @Override
- public String toString() {
- return this.name;
- }
+ @Override
+ public String toString() {
+ return this.name;
+ }
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Checksummer.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Checksummer.java
index 8c6a0dbe0..550e97c4d 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Checksummer.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Checksummer.java
@@ -1,213 +1,182 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003-2006 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003-2006 by JSTOR and the President and Fellows of Harvard
+ * College ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
+
import java.security.*;
import java.util.zip.*;
/**
- * The Checksummer class encapsulates the calculation of the
- * CRC32, MD5, SHA-1 and SHA-256 checksums.
+ * The Checksummer class encapsulates the calculation of the CRC32, MD5, SHA-1 and SHA-256
+ * checksums.
*/
-public class Checksummer implements java.util.zip.Checksum
-{
- /******************************************************************
- * PRIVATE INSTANCE FIELDS.
- ******************************************************************/
-
- /** Byte count. */
- protected long _nByte;
- /** CRC32 object. */
- private CRC32 _crc32;
- /** MD5 message digest. */
- private MessageDigest _md5;
- /** SHA-1 message digest. */
- private MessageDigest _sha1;
- /** SHA-256 message digest. */
- private MessageDigest _sha256;
-
- /**
- * Creates a Checksummer, with instances of each of
- * CRC32, MD5, SHA-1 and SHA-256 MessageDigest.
- * If one or both of the MessageDigests aren't supported
- * on the current platform, they are left as null.
- *
- * @see CRC32
- * @see MessageDigest
- */
- public Checksummer ()
- {
- reset ();
- }
-
- /** Resets all checksums and the byte count to their
- * initial values.
- */
- @Override
- public void reset ()
- {
- _nByte = 0;
- _crc32 = new CRC32 ();
- try {
- _md5 = MessageDigest.getInstance ("MD5");
- _sha1 = MessageDigest.getInstance ("SHA-1");
- _sha256 = MessageDigest.getInstance ("SHA-256");
- }
- catch (NoSuchAlgorithmException e) {
- throw new IllegalStateException("Missing checksum algorithm.", e);
- }
- }
-
- /** getValue is required by the Checksum interface, but
- * we can return only one of the three values. We
- * return the CRC32 value, since that's the one which
- * is guaranteed to be available.
- */
- @Override
- public long getValue ()
- {
- return _crc32.getValue ();
- }
-
- /**
- * Updates the checksum with the argument.
- * Called when a signed byte is available.
- */
- public void update (byte b)
- {
- _crc32.update (b);
- if (_md5 != null) {
- _md5.update (b);
- }
+public class Checksummer implements java.util.zip.Checksum {
+ /**
+ * **************************************************************** PRIVATE INSTANCE FIELDS.
+ * ****************************************************************
+ */
+
+ /** Byte count. */
+ protected long _nByte;
+ /** CRC32 object. */
+ private CRC32 _crc32;
+ /** MD5 message digest. */
+ private MessageDigest _md5;
+ /** SHA-1 message digest. */
+ private MessageDigest _sha1;
+ /** SHA-256 message digest. */
+ private MessageDigest _sha256;
+
+ /**
+ * Creates a Checksummer, with instances of each of CRC32, MD5, SHA-1 and SHA-256 MessageDigest.
+ * If one or both of the MessageDigests aren't supported on the current platform, they are left as
+ * null.
+ *
+ * @see CRC32
+ * @see MessageDigest
+ */
+ public Checksummer() {
+ reset();
+ }
+
+ /** Resets all checksums and the byte count to their initial values. */
+ @Override
+ public void reset() {
+ _nByte = 0;
+ _crc32 = new CRC32();
+ try {
+ _md5 = MessageDigest.getInstance("MD5");
+ _sha1 = MessageDigest.getInstance("SHA-1");
+ _sha256 = MessageDigest.getInstance("SHA-256");
+ } catch (NoSuchAlgorithmException e) {
+ throw new IllegalStateException("Missing checksum algorithm.", e);
+ }
+ }
+
+ /**
+ * getValue is required by the Checksum interface, but we can return only one of the three values.
+ * We return the CRC32 value, since that's the one which is guaranteed to be available.
+ */
+ @Override
+ public long getValue() {
+ return _crc32.getValue();
+ }
+
+ /** Updates the checksum with the argument. Called when a signed byte is available. */
+ public void update(byte b) {
+ _crc32.update(b);
+ if (_md5 != null) {
+ _md5.update(b);
+ }
if (_sha1 != null) {
- _sha1.update (b);
- }
+ _sha1.update(b);
+ }
if (_sha256 != null) {
- _sha256.update (b);
- }
- }
-
- /**
- * Updates the checksum with the argument.
- * Called when an unsigned byte is available.
- */
- @Override
- public void update (int b)
- {
- byte sb;
- if (b > 127) {
- sb = (byte) (b - 256);
- }
- else {
- sb = (byte) b;
- }
- update (sb);
- }
-
- /**
- * Updates the checksum with the argument.
- * Called when a byte array is available.
- */
- public void update (byte[] b)
- {
- _crc32.update (b);
- if (_md5 != null) {
- _md5.update (b);
- }
- if (_sha1 != null) {
- _sha1.update (b);
- }
- if (_sha256 != null) {
- _sha256.update (b);
- }
- }
-
- /**
- * Updates the checksum with the argument.
- * Called when a byte array is available.
- */
- @Override
- public void update (byte[] b, int off, int len)
- {
- _crc32.update (b, off, len);
- if (_md5 != null) {
- _md5.update (b, off, len);
- }
+ _sha256.update(b);
+ }
+ }
+
+ /** Updates the checksum with the argument. Called when an unsigned byte is available. */
+ @Override
+ public void update(int b) {
+ byte sb;
+ if (b > 127) {
+ sb = (byte) (b - 256);
+ } else {
+ sb = (byte) b;
+ }
+ update(sb);
+ }
+
+ /** Updates the checksum with the argument. Called when a byte array is available. */
+ public void update(byte[] b) {
+ _crc32.update(b);
+ if (_md5 != null) {
+ _md5.update(b);
+ }
if (_sha1 != null) {
- _sha1.update (b, off, len);
- }
+ _sha1.update(b);
+ }
if (_sha256 != null) {
- _sha256.update (b, off, len);
- }
- }
-
- /**
- * Returns the value of the CRC32 as a hex string.
- */
- public String getCRC32 ()
- {
- return padLeadingZeroes
- (Long.toHexString (_crc32.getValue ()), 8);
- }
-
- /**
- * Returns the value of the MD5 digest as a hex string.
- * Returns null if the digest is not available.
- */
- public String getMD5 ()
- {
- if (_md5 == null) {
- return null;
- }
- return convertToHex(_md5.digest());
- }
-
- /**
- * Returns the value of the SHA-1 digest as a hex string.
- * Returns null if the digest is not available.
- */
- public String getSHA1 ()
- {
- if (_sha1 == null) {
- return null;
- }
- return convertToHex(_sha1.digest());
- }
-
- /**
- * Returns the value of the SHA-256 digest as a hex string.
- * Returns null if the digest is not available.
- */
- public String getSHA256 ()
- {
- if (_sha256 == null) {
- return null;
- }
- return convertToHex(_sha256.digest());
- }
-
- private String convertToHex(final byte [] digest) {
- StringBuffer buffer = new StringBuffer();
- for (int i=0; i Accessor methods. ****************************************************************
+ */
+
+ /**
+ * Returns the List of Modules specified by the config file. Each element of the List is a
+ * String[2] whose elements are the module class name and initialization value.
+ *
+ * @see Module
+ */
+ public List It appears that not all SAX implementations will actually call this function for schema
+ * resolution, so this isn't a guarantee that the schema in the config file won't be called
+ * directly. But hopefully it will cut down on the burden on the server with the official schema
+ * copy.
+ */
+ @Override
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException {
+ if (systemId.endsWith(configSchemaName)) {
+ try {
+ URL resURL = this.getClass().getResource(configSchemaName);
+ InputStream strm = resURL.openStream();
+ return new InputSource(strm);
+ } catch (Exception e) {
+ }
}
+ // If we couldn't get the local resource, use default location methods
+ return super.resolveEntity(publicId, systemId);
+ }
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/CoreMessageConstants.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/CoreMessageConstants.java
index 6654c05f8..4242ffd0d 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/CoreMessageConstants.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/CoreMessageConstants.java
@@ -1,43 +1,43 @@
package edu.harvard.hul.ois.jhove;
/**
- * @author Carl Wilson
- * carlwilson AT github
- *
+ * @author Carl Wilson carlwilson AT github
* @version 0.1
- *
- * Created 2 Nov 2017:09:24:33
+ * Created 2 Nov 2017:09:24:33
*/
-
public enum CoreMessageConstants {
- INSTANCE;
+ INSTANCE;
- public static final String EXC_CHAR_ENC_UNSPPTD = "Unsupported character encoding: ";
- public static final String EXC_CONF_FILE_LOC_MISS = "Initialization exception; location not specified for configuration file.";
- public static final String EXC_CONF_FILE_INVAL = "Use -c to specify a configuration file. Path not found or not readable: ";
- public static final String EXC_CONF_FILE_UNRDBL = "Cannot read configuration file: ";
- public static final String EXC_CONF_FILE_UNPRS = "Error parsing configuration file: ";
- public static final String EXC_FILE_OPEN = "Cannot open output file: ";
- public static final String EXC_HNDL_INST_FAIL = "Cannot instantiate handler: ";
- public static final String EXC_JAVA_VER_INCMPT = "Java 1.8 or higher is required";
- public static final String EXC_MODL_INST_FAIL = "Cannot instantiate module: ";
- public static final String EXC_PRV_CNSTRCT = "Entered private constructor for: ";
- public static final String EXC_PROP_VAL_NULL = "Null value not permitted for property: ";
- public static final String EXC_SAX_PRSR_MISS = "SAX parser not found: ";
- public static final String EXC_PROP_CLSS_INCMPT = "Incompatible class for property: ";
- public static final String EXC_SCL_PROP_CLSS_INCMPT = "Scalar.";
- public static final String EXC_MAP_PROP_CLSS_INCMPT = "Map.";
- public static final String EXC_SET_PROP_CLSS_INCMPT = "Set.";
- public static final String EXC_LIST_PROP_CLSS_INCMPT = "List.";
- public static final String EXC_TEMP_FILE_CRT = "Cannot create temporary file";
- public static final String EXC_URI_CONV_FAIL = "Cannot convert URI to URL: ";
- public static final String EXC_URL_NOT_FND = "URL not found: ";
- public static final String EXC_UNEXPECTED = "Validation ended prematurely due to an unhandled exception.";
+ public static final String EXC_CHAR_ENC_UNSPPTD = "Unsupported character encoding: ";
+ public static final String EXC_CONF_FILE_LOC_MISS =
+ "Initialization exception; location not specified for configuration file.";
+ public static final String EXC_CONF_FILE_INVAL =
+ "Use -c to specify a configuration file. Path not found or not readable: ";
+ public static final String EXC_CONF_FILE_UNRDBL = "Cannot read configuration file: ";
+ public static final String EXC_CONF_FILE_UNPRS = "Error parsing configuration file: ";
+ public static final String EXC_FILE_OPEN = "Cannot open output file: ";
+ public static final String EXC_HNDL_INST_FAIL = "Cannot instantiate handler: ";
+ public static final String EXC_JAVA_VER_INCMPT = "Java 1.8 or higher is required";
+ public static final String EXC_MODL_INST_FAIL = "Cannot instantiate module: ";
+ public static final String EXC_PRV_CNSTRCT = "Entered private constructor for: ";
+ public static final String EXC_PROP_VAL_NULL = "Null value not permitted for property: ";
+ public static final String EXC_SAX_PRSR_MISS = "SAX parser not found: ";
+ public static final String EXC_PROP_CLSS_INCMPT = "Incompatible class for property: ";
+ public static final String EXC_SCL_PROP_CLSS_INCMPT = "Scalar.";
+ public static final String EXC_MAP_PROP_CLSS_INCMPT = "Map.";
+ public static final String EXC_SET_PROP_CLSS_INCMPT = "Set.";
+ public static final String EXC_LIST_PROP_CLSS_INCMPT = "List.";
+ public static final String EXC_TEMP_FILE_CRT = "Cannot create temporary file";
+ public static final String EXC_URI_CONV_FAIL = "Cannot convert URI to URL: ";
+ public static final String EXC_URL_NOT_FND = "URL not found: ";
+ public static final String EXC_UNEXPECTED =
+ "Validation ended prematurely due to an unhandled exception.";
- public static final String ERR_APP_PROP_MISS = "No application properties found for: ";
- public static final String ERR_ICC_PRFL_DESC_MISS = "No description in ICC profile v4";
- public static final String ERR_FILE_NOT_FOUND = "File not found";
- public static final String ERR_FILE_READ = "File cannot be read";
+ public static final String ERR_APP_PROP_MISS = "No application properties found for: ";
+ public static final String ERR_ICC_PRFL_DESC_MISS = "No description in ICC profile v4";
+ public static final String ERR_FILE_NOT_FOUND = "File not found";
+ public static final String ERR_FILE_READ = "File cannot be read";
- public static final String INF_FILE_EMPTY = "Zero-length file";
+ public static final String INF_FILE_EMPTY = "Zero-length file";
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/CountedInputStream.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/CountedInputStream.java
index dc7682c77..3535ff34b 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/CountedInputStream.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/CountedInputStream.java
@@ -1,116 +1,98 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2004 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2004 by JSTOR and the President and Fellows of Harvard College
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
import java.io.*;
/**
- * A FilterInputStream which passes only a specified
- * number of bytes, then returns an EOF condition.
+ * A FilterInputStream which passes only a specified number of bytes, then returns an EOF condition.
*
* @author Gary McGath
- *
*/
public class CountedInputStream extends FilterInputStream {
- private int bytesLeft;
-
- /**
- * @param instrm The InputStream being counted
- * @param count The number of bytes to be allowed
- */
- public CountedInputStream(InputStream instrm, int count) {
- super(instrm);
- bytesLeft = count;
- }
+ private int bytesLeft;
+ /**
+ * @param instrm The InputStream being counted
+ * @param count The number of bytes to be allowed
+ */
+ public CountedInputStream(InputStream instrm, int count) {
+ super(instrm);
+ bytesLeft = count;
+ }
- /** Reads a single byte from the stream and decrements
- * the count of remaining bytes. If the count
- * is exhausted, returns -1 to signify end of file. */
- @Override
- public int read() throws IOException {
- if (bytesLeft <= 0) {
- return -1;
- }
- int ch = super.read ();
- if (ch != -1) {
- --bytesLeft;
- }
- return ch;
+ /**
+ * Reads a single byte from the stream and decrements the count of remaining bytes. If the count
+ * is exhausted, returns -1 to signify end of file.
+ */
+ @Override
+ public int read() throws IOException {
+ if (bytesLeft <= 0) {
+ return -1;
}
-
-
- /**
- * Reads some number of bytes from the input stream and
- * stores them into the buffer array b. The number of
- * bytes actually read is returned as an integer.
- *
- * The number of bytes read will not exceed the number
- * of bytes remaining in the count. The count is
- * decremented by the number of bytes actually read.
- */
- @Override
- public int read(byte[] b) throws IOException
- {
- int len = b.length;
- int bytesRead;
- if (len <= bytesLeft) {
- // Limit doesn't affect us, do normal read
- bytesRead = super.read (b);
- }
- else {
- // Limit the read to bytesLeft
- bytesRead = super.read (b, 0, bytesLeft);
- }
- bytesLeft -= bytesRead;
- return bytesRead;
+ int ch = super.read();
+ if (ch != -1) {
+ --bytesLeft;
}
+ return ch;
+ }
+ /**
+ * Reads some number of bytes from the input stream and stores them into the buffer array b. The
+ * number of bytes actually read is returned as an integer.
+ *
+ * The number of bytes read will not exceed the number of bytes remaining in the count. The
+ * count is decremented by the number of bytes actually read.
+ */
+ @Override
+ public int read(byte[] b) throws IOException {
+ int len = b.length;
+ int bytesRead;
+ if (len <= bytesLeft) {
+ // Limit doesn't affect us, do normal read
+ bytesRead = super.read(b);
+ } else {
+ // Limit the read to bytesLeft
+ bytesRead = super.read(b, 0, bytesLeft);
+ }
+ bytesLeft -= bytesRead;
+ return bytesRead;
+ }
- /**
- * Reads up to len bytes of data from the input stream
- * into an array of bytes. An attempt is made to read as
- * many as len bytes, but a smaller number may be read,
- * possibly zero. The number of bytes actually read is
- * returned as an integer.
- *
- * The number of bytes read will not exceed the number
- * of bytes remaining in the count. The count is
- * decremented by the number of bytes actually read.
- */
- @Override
- public int read(byte[] b, int off, int len) throws IOException
- {
- int bytesRead;
- if (len <= bytesLeft) {
- // Limit doesn't affect us, do normal read
- bytesRead = super.read (b, off, len);
- }
- else {
- bytesRead = super.read (b, off, bytesLeft);
- }
- bytesLeft -= bytesRead;
- return bytesRead;
+ /**
+ * Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made
+ * to read as many as len bytes, but a smaller number may be read, possibly zero. The number of
+ * bytes actually read is returned as an integer.
+ *
+ * The number of bytes read will not exceed the number of bytes remaining in the count. The
+ * count is decremented by the number of bytes actually read.
+ */
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ int bytesRead;
+ if (len <= bytesLeft) {
+ // Limit doesn't affect us, do normal read
+ bytesRead = super.read(b, off, len);
+ } else {
+ bytesRead = super.read(b, off, bytesLeft);
}
+ bytesLeft -= bytesRead;
+ return bytesRead;
+ }
- /**
- * Skips n bytes.
- * Decrements the count by the number of bytes
- * actually skipped.
- */
- @Override
- public long skip (long n) throws IOException {
- long bytesRead = super.skip (n);
- if (bytesLeft < bytesRead) {
- bytesLeft = 0;
- }
- else {
- bytesLeft -= bytesRead;
- }
- return bytesRead;
+ /** Skips n bytes. Decrements the count by the number of bytes actually skipped. */
+ @Override
+ public long skip(long n) throws IOException {
+ long bytesRead = super.skip(n);
+ if (bytesLeft < bytesRead) {
+ bytesLeft = 0;
+ } else {
+ bytesLeft -= bytesRead;
}
+ return bytesRead;
+ }
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Document.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Document.java
index bf3e6b46f..c3538807e 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Document.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Document.java
@@ -1,194 +1,137 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003 by JSTOR and the President and Fellows of Harvard College
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
import java.util.*;
-/**
- * This class encapsulates information about format specification documents.
+/**
+ * This class encapsulates information about format specification documents.
*
- * @see DocumentType
+ * @see DocumentType
*/
-public class Document
-{
- private List This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU Lesser General Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
import java.io.*;
-/**
- * Common methods for dump utilities.
- */
-public class Dump
-{
- /******************************************************************
- * CLASS CONSTRUCTOR.
- ******************************************************************/
- public Dump ()
- {
- }
+/** Common methods for dump utilities. */
+public class Dump {
+ /**
+ * **************************************************************** CLASS CONSTRUCTOR.
+ * ****************************************************************
+ */
+ public Dump() {}
- /******************************************************************
- * PUBLIC CLASS METHODS.
- ******************************************************************/
+ /**
+ * **************************************************************** PUBLIC CLASS METHODS.
+ * ****************************************************************
+ */
- /**
- * Return leading characters to pad out the byte offset to field width.
- * @param os Byte offset
- * @param width Field width
- * @return String of leading zeros
- */
- protected static String leading (int os, int width)
- {
- return leading (os, width, '0');
- }
+ /**
+ * Return leading characters to pad out the byte offset to field width.
+ *
+ * @param os Byte offset
+ * @param width Field width
+ * @return String of leading zeros
+ */
+ protected static String leading(int os, int width) {
+ return leading(os, width, '0');
+ }
- /**
- * Return leading characters to pad out the byte offset to field width.
- * @param os Byte offset
- * @param width Field width
- * @return String of leading zeros
- */
- protected static String leading (long os, int width)
- {
- return leading (os, width, '0');
- }
+ /**
+ * Return leading characters to pad out the byte offset to field width.
+ *
+ * @param os Byte offset
+ * @param width Field width
+ * @return String of leading zeros
+ */
+ protected static String leading(long os, int width) {
+ return leading(os, width, '0');
+ }
- /**
- * Return leading characters to pad out the byte offset to field width.
- * @param os Byte offset
- * @param width Field width
- * @param pad Padding character
- * @return String of leading characters
- */
- protected static String leading (int os, int width, char pad)
- {
- return leading ((long) os, width, pad);
- }
+ /**
+ * Return leading characters to pad out the byte offset to field width.
+ *
+ * @param os Byte offset
+ * @param width Field width
+ * @param pad Padding character
+ * @return String of leading characters
+ */
+ protected static String leading(int os, int width, char pad) {
+ return leading((long) os, width, pad);
+ }
- /**
- * Return leading characters to pad out the byte offset to field width.
- * @param os Byte offset
- * @param width Field width
- * @param pad Padding character
- * @return String of leading characters
- */
- protected static String leading (long os, int width, char pad)
- {
- String ss = Long.toString (os);
- StringBuffer buffer = new StringBuffer ();
- for (int j=0; j Initialization methods. ****************************************************************
+ */
+
+ /** Reset the handler. This needs to be called before each invocation. */
+ @Override
+ public void reset() {
+ _level = -1;
+ }
+
+ /**
+ * Set a a List of default parameters for the module.
+ *
+ * @param params A List whose elements are Strings. May be empty.
+ */
+ @Override
+ public void setDefaultParams(List XML methods. ****************************************************************
+ */
+
+ /**
+ * Return the XML DOCTYPE instruction.
+ *
+ * @param root Root element of the DTD
+ * @param uri URI of the DTD
+ */
+ protected static String doctype(String root, String uri) {
+ return doctype(root, null, uri);
+ }
+
+ /**
+ * Return the XML DOCTYPE instruction.
+ *
+ * @param root Root element of the DTD
+ * @param name Public name of the DTD
+ * @param uri URI of the DTD
+ */
+ protected static String doctype(String root, String name, String uri) {
+ StringBuffer s = new StringBuffer("");
+
+ return s.toString();
+ }
+
+ /**
+ * Returns, as a String, an empty XML.
+ *
+ * @param tag XML tag
+ */
+ protected static String element(String tag) {
+ return "<" + tag + "/>";
+ }
+
+ /**
+ * Returns, as a String, an XML element with a given tag and content
+ *
+ * @param tag An XML tag
+ * @param content Content string. Characters requiring conversion to entitites will be converted.
+ */
+ protected static String element(String tag, String content) {
+ return elementStart(tag) + Utils.encodeContent(content) + elementEnd(tag);
+ }
+
+ /**
+ * Returns, as a String, an XML element with a given tag and attributes
+ *
+ * @param tag An XML tag
+ * @param attrs An array of String[2] elements, where for each element, attrs[i][0] is the
+ * attribute key and attrs[i][1] is the attribute value. Null values are skipped.
+ */
+ protected static String element(String tag, String[][] attrs) {
+ StringBuffer buffer = new StringBuffer("<");
+ buffer.append(tag);
+ for (int i = 0; i < attrs.length; i++) {
+ if (attrs[i][0] != null && attrs[i][1] != null) {
+ buffer.append(" ");
+ buffer.append(attrs[i][0]);
+ buffer.append("=\"");
+ buffer.append(Utils.encodeValue(attrs[i][1]));
+ buffer.append("\"");
+ }
}
-
- /**
- * Callback indicating a directory is finished being processed.
- */
- @Override
- public void endDirectory ()
- {
- /* Do nothing, which is sufficient for most handlers. */
+ buffer.append("/>");
+
+ return buffer.toString();
+ }
+
+ /**
+ * Returns, as a String, an XML element with a given tag, content and attributes
+ *
+ * @param tag An XML tag
+ * @param content Content string. Characters requiring conversion to entitites will be converted.
+ * @param attrs An array of String[2] elements, where for each element, attrs[i][0] is the
+ * attribute key and attrs[i][1] is the attribute value. Null values are skipped.
+ */
+ protected static String element(String tag, String[][] attrs, String content) {
+ StringBuffer buffer = new StringBuffer("<");
+ buffer.append(tag);
+ for (int i = 0; i < attrs.length; i++) {
+ if (attrs[i][0] != null && attrs[i][1] != null) {
+ buffer.append(" ");
+ buffer.append(attrs[i][0]);
+ buffer.append("=\"");
+ buffer.append(Utils.encodeValue(attrs[i][1]));
+ buffer.append("\"");
+ }
}
-
- /**
- * Callback to give the handler the opportunity to decide whether or
- * not to process a file. Most handlers will always return true.
- * @param filepath File pathname
- */
- @Override
- public boolean okToProcess (String filepath)
- {
- return true;
+ buffer.append(">");
+ buffer.append(Utils.encodeContent(content));
+ buffer.append(elementEnd(tag));
+
+ return buffer.toString();
+ }
+
+ /**
+ * Returns, as a String, the closing tag of an element. No checking is done that opening and
+ * closing tags match.
+ *
+ * @param tag An XML tag
+ */
+ protected static String elementEnd(String tag) {
+ return "" + tag + ">";
+ }
+
+ /**
+ * Returns, as a String, the opening tag of an element.
+ *
+ * @param tag An XML tag
+ */
+ protected static String elementStart(String tag) {
+ return "<" + tag + ">";
+ }
+
+ /**
+ * Returns, as a String, the opening tag of an element with specified attributes.
+ *
+ * @param tag An XML tag
+ * @param attrs An array of String[2] elements, where for each element, attrs[i][0] is the
+ * attribute key and attrs[i][1] is the attribute value.
+ */
+ protected static String elementStart(String tag, String[][] attrs) {
+ StringBuffer buffer = new StringBuffer("<");
+ buffer.append(tag);
+ for (int i = 0; i < attrs.length; i++) {
+ buffer.append(" ");
+ buffer.append(attrs[i][0]);
+ buffer.append("=\"");
+ buffer.append(Utils.encodeValue(attrs[i][1]));
+ buffer.append("\"");
+ }
+ buffer.append(">");
+
+ return buffer.toString();
+ }
+
+ /** Return a canonical XML declaration with default encoding. */
+ protected static String xmlDecl() {
+ return "";
+ }
+
+ /** Return a canonical XML declaration with specified encoding. */
+ protected static String xmlDecl(String encoding) {
+ return "";
+ }
+
+ /**
+ * **************************************************************** Nesting level methods.
+ * ****************************************************************
+ */
+
+ /** Returns a String containing a number of spaces equal to the current indent level. */
+ protected static String getIndent(int level) {
+ StringBuffer s = new StringBuffer();
+ for (int i = 0; i < level; i++) {
+ s.append(" ");
+ }
+
+ return s.toString();
+ }
+
+ /**
+ * **************************************************************** Array methods.
+ * ****************************************************************
+ */
+
+ /** Return String representation of an integer array. */
+ protected static String integerArray(int[] iarray) {
+ return integerArray(iarray, ' ');
+ }
+
+ /** Return String representation of an integer array with specified separator. */
+ protected static String integerArray(int[] iarray, char separator) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < iarray.length; i++) {
+ if (i > 0) {
+ buffer.append(separator);
+ }
+ buffer.append(Integer.toString(iarray[i]));
}
+ return buffer.toString();
+ }
- /**
- * Outputs information about a Module
- */
- @Override
- public abstract void show (Module module);
-
- /**
- * Outputs the information contained in a RepInfo object
- */
- @Override
- public abstract void show (RepInfo info);
-
- /**
- * Outputs information about the OutputHandler specified
- * in the parameter
- */
- @Override
- public abstract void show (OutputHandler handler);
-
- /**
- * Outputs minimal information about the application
- */
- @Override
- public abstract void show ();
-
- /**
- * Outputs detailed information about the application,
- * including configuration, available modules and handlers,
- * etc.
- */
- @Override
- public abstract void show (App app);
-
- /**
- * Do the initial output. This should be in a suitable format
- * for including multiple files between the header and the footer.
- */
- @Override
- public abstract void showHeader ();
-
- /**
- * Do the final output. This should be in a suitable format
- * for including multiple files between the header and the footer.
- */
- @Override
- public abstract void showFooter ();
-
- /**
- * Close the writer after all output has been done.
- */
- @Override
- public void close ()
- {
- _writer.close ();
+ /** Return String representation of an array of long with space separator. */
+ protected static String longArray(long[] larray) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < larray.length; i++) {
+ if (i > 0) {
+ buffer.append(" ");
+ }
+ buffer.append(Long.toString(larray[i]));
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Return String representation of an array of Rational, each evaluated as a double, with space
+ * separator.
+ */
+ protected static String rationalArray(Rational[] rarray) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < rarray.length; i++) {
+ if (i > 0) {
+ buffer.append(" ");
+ }
+ buffer.append(rarray[i].toDouble());
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Return String representation of an array of Rational, each as two integers, with space
+ * separator.
+ */
+ protected static String rationalArray10(Rational[] rarray) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < rarray.length; i++) {
+ if (i > 0) {
+ buffer.append(" ");
+ }
+ buffer.append(rarray[i].getNumerator());
+ buffer.append(" ");
+ buffer.append(rarray[i].getNumerator());
+ }
+ return buffer.toString();
+ }
+
+ /** Return String representation of an array of double. */
+ protected static String doubleArray(double[] darray) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < darray.length; i++) {
+ if (i > 0) {
+ buffer.append(" ");
+ }
+ buffer.append(Double.toString(darray[i]));
+ }
+ return buffer.toString();
+ }
+
+ /* Text formatting methods. */
+ /* Convert a date to the dateTime format used by the
+ * XML schema. This is ISO 8610 with a colon between
+ * the hour and minute fields of the time zone. Unfortunately,
+ * SimpleDateFormat generates the time zone without the
+ * colon; this also conforms to 8601, but doesn't conform
+ * to the schema, so we have to diddle it.
+ */
+ protected String toDateTime(Date date) {
+ String isoStr = iso8601.format(date);
+ // We can't directly use a SimpleDateFormat, because
+ // the 'z' field gives us the colonless time zone.
+ int len = isoStr.length();
+ // Add the colon before the last two characters.
+ return isoStr.substring(0, len - 2) + ":" + isoStr.substring(len - 2);
+ }
+
+ /** A DateFormat class to address an issue of thread safety. */
+ public static class SynchronizedDateFormat extends SimpleDateFormat {
+ public SynchronizedDateFormat(String pattern) {
+ super(pattern);
}
- /**
- * Callback indicating a new directory is being processed.
- * @param directory Directory path
- */
@Override
- public void startDirectory (String directory)
- {
- /* Do nothing, which is sufficient for most handlers. */
- }
-
- /******************************************************************
- * PRIVATE CLASS METHODS.
- *
- * XML methods.
- ******************************************************************/
-
- /**
- * Return the XML DOCTYPE instruction.
- * @param root Root element of the DTD
- * @param uri URI of the DTD
- */
- protected static String doctype (String root, String uri)
- {
- return doctype (root, null, uri);
- }
-
- /**
- * Return the XML DOCTYPE instruction.
- * @param root Root element of the DTD
- * @param name Public name of the DTD
- * @param uri URI of the DTD
- */
- protected static String doctype (String root, String name, String uri)
- {
- StringBuffer s = new StringBuffer ("");
-
- return s.toString ();
- }
-
- /**
- * Returns, as a String, an empty XML.
- *
- * @param tag XML tag
- */
- protected static String element (String tag)
- {
- return "<" + tag + "/>";
- }
-
- /**
- * Returns, as a String, an XML element with a given tag and content
- *
- * @param tag An XML tag
- * @param content Content string. Characters requiring
- * conversion to entitites will be converted.
- */
- protected static String element (String tag, String content)
- {
- return elementStart (tag) + Utils.encodeContent (content) + elementEnd (tag);
- }
-
- /**
- * Returns, as a String,
- * an XML element with a given tag and attributes
- *
- * @param tag An XML tag
- * @param attrs An array of String[2] elements, where for each
- * element, attrs[i][0] is the attribute key and
- * attrs[i][1] is the attribute value.
- * Null values are skipped.
- */
- protected static String element (String tag, String [][] attrs)
- {
- StringBuffer buffer = new StringBuffer ("<");
- buffer.append (tag);
- for (int i=0; i More than one JhoveBase may be instantiated and process files in concurrent threads. Any one
+ * instance must not be multithreaded.
*/
public class JhoveBase {
- public static final String _name = "JhoveBase";
-
- private static final ReleaseDetails RELEASE_DETAILS =
- ReleaseDetails.getInstance();
-
- private static final String JAVA_TEMP_DIR_PROP_KEY = "java.io.tmpdir";
- private static final String HUL_PROPERTY_PREFIX = "edu.harvard.hul.ois.";
- private static final String JHOVE_PROPERTY_PREFIX = HUL_PROPERTY_PREFIX
- + "jhove.";
-
- /** JHOVE buffer size property. */
- private static final String BUFFER_PROPERTY = JHOVE_PROPERTY_PREFIX
- + "bufferSize";
-
- /** JHOVE home directory */
- private static final String JHOVE_DIR = "jhove";
-
- /** JHOVE configuration directory */
- private static final String CONFIG_DIR = "conf";
-
- /** JHOVE configuration file property. */
- private static final String CONFIG_PROPERTY = JHOVE_PROPERTY_PREFIX
- + "config";
-
- /** JHOVE default buffer size. */
- private static final int DEFAULT_BUFFER = 131072;
-
- /** JHOVE default character encoding. */
- private static final String DEFAULT_ENCODING = "utf-8";
-
- /** Default temporary directory. */
- private static final String DEFAULT_TEMP =
- System.getProperty(JAVA_TEMP_DIR_PROP_KEY);
-
- /** JHOVE encoding property. */
- private static final String ENCODING_PROPERTY = JHOVE_PROPERTY_PREFIX
- + "encoding";
-
- /** JHOVE SAX parser class property. */
- private static final String SAX_PROPERTY = JHOVE_PROPERTY_PREFIX
- + "saxClass";
-
- /** JHOVE temporary directory property. */
- private static final String TEMPDIR_PROPERTY = JHOVE_PROPERTY_PREFIX
- + "tempDirectory";
-
- /** Flag for aborting activity. */
- protected boolean _abort;
- /** Buffer size for buffered I/O. */
- protected int _bufferSize;
- protected boolean _checksum;
- /** Configuration file pathname. */
- protected String _configFile;
- /** Selected encoding. */
- protected String _encoding;
- /** Ordered list of output handlers. */
- protected List Instantiates a This method parses the configuration file and initialises the JHOVE engine based on the
+ * values parsed.
+ *
+ * Version 1.11 would create the configuration file if not found. Version 1.12 changes this
+ * behaviour. The file path supplied must be resolvable to an existing JHOVE config file.
+ *
+ * @param configFile Configuration file pathname
+ * @param saxClass a SAX parser class, will use JVM default if not supplied
+ * @throws JhoveException when anything goes wrong
+ */
+ public void init(String configFile, String saxClass) throws JhoveException {
+
+ if (configFile == null) {
+ throw new JhoveException(CoreMessageConstants.EXC_CONF_FILE_LOC_MISS);
+ }
+ _configFile = configFile;
- // Initialize the engine.
- _moduleList = new ArrayList<>(20);
- _moduleMap = new TreeMap<>();
+ File config = new File(_configFile);
- _handlerList = new ArrayList<>();
- _handlerMap = new TreeMap<>();
+ if (!config.exists() || !config.isFile()) {
+ throw new JhoveException(config.getAbsolutePath() + CoreMessageConstants.EXC_CONF_FILE_INVAL);
+ }
- _abort = false;
- _bufferSize = -1;
- _checksum = false;
- _showRaw = false;
- _signature = false;
- _callback = null;
+ _saxClass = saxClass;
+ XMLReader parser = null;
+
+ try {
+ if (saxClass == null) {
+ // Use Java 1.4 methods to create default parser.
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(true);
+ parser = factory.newSAXParser().getXMLReader();
+ } else {
+ parser = XMLReaderFactory.createXMLReader(saxClass);
+ }
+ } catch (Exception e) {
+ // If we can't get a SAX parser, we're stuck.
+ throw new JhoveException(CoreMessageConstants.EXC_SAX_PRSR_MISS + saxClass, e);
}
- /**
- * Initializes the JHOVE engine.
- *
- * This method parses the configuration file and initialises the JHOVE
- * engine based on the values parsed.
- *
- * Version 1.11 would create the configuration file if not found. Version
- * 1.12 changes this behaviour. The file path supplied must be resolvable
- * to an existing JHOVE config file.
- *
- * @param configFile
- * Configuration file pathname
- * @param saxClass
- * a SAX parser class, will use JVM default if not supplied
- * @throws JhoveException
- * when anything goes wrong
- */
- public void init(String configFile, String saxClass) throws JhoveException {
-
- if (configFile == null) {
- throw new JhoveException(CoreMessageConstants.EXC_CONF_FILE_LOC_MISS);
- }
- _configFile = configFile;
+ _logger.info("Using SAX parser " + parser.getClass().getName());
+ ConfigHandler configHandler = new ConfigHandler();
+ parser.setContentHandler(configHandler);
+ parser.setEntityResolver(configHandler);
+
+ // Attempt to set schema awareness to avoid validation errors.
+ try {
+ parser.setFeature("http://xml.org/sax/features/validation", true);
+ parser.setProperty(
+ "http://java.sun.com/xml/jaxp/" + "properties/schemaLanguage",
+ "http://www.w3.org/2001/XMLSchema");
+ } catch (SAXException saxe) {
+ }
- File config = new File(_configFile);
+ try {
+ String canonicalPath = config.getCanonicalPath();
+ String fileURL = "file://";
+ if (canonicalPath.charAt(0) != '/') {
+ fileURL += Character.toString('/');
+ }
+ fileURL += canonicalPath;
+ parser.parse(fileURL);
+ } catch (IOException ioe) {
+ throw new JhoveException(CoreMessageConstants.EXC_CONF_FILE_UNRDBL + configFile, ioe);
+ } catch (SAXException saxe) {
+ throw new JhoveException(CoreMessageConstants.EXC_CONF_FILE_UNPRS + saxe.getMessage(), saxe);
+ }
- if (!config.exists() || !config.isFile()) {
- throw new JhoveException(config.getAbsolutePath() +
- CoreMessageConstants.EXC_CONF_FILE_INVAL);
- }
+ // Update the application state to reflect the configuration file,
+ // if necessary.
+ _jhoveHome = configHandler.getJhoveHome();
- _saxClass = saxClass;
- XMLReader parser = null;
+ _encoding = configHandler.getEncoding();
+ if (_encoding == null) {
+ _encoding = getFromProperties(ENCODING_PROPERTY);
+ if (_encoding == null) {
+ _encoding = DEFAULT_ENCODING;
+ }
+ }
- try {
- if (saxClass == null) {
- // Use Java 1.4 methods to create default parser.
- SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setNamespaceAware(true);
- parser = factory.newSAXParser().getXMLReader();
- } else {
- parser = XMLReaderFactory.createXMLReader(saxClass);
- }
- } catch (Exception e) {
- // If we can't get a SAX parser, we're stuck.
- throw new JhoveException(CoreMessageConstants.EXC_SAX_PRSR_MISS + saxClass, e);
- }
+ _tempDir = configHandler.getTempDir();
+ if (_tempDir == null) {
+ _tempDir = getFromProperties(TEMPDIR_PROPERTY);
+ if (_tempDir == null) {
+ _tempDir = DEFAULT_TEMP;
+ }
+ }
- _logger.info("Using SAX parser " + parser.getClass().getName());
- ConfigHandler configHandler = new ConfigHandler();
- parser.setContentHandler(configHandler);
- parser.setEntityResolver(configHandler);
+ // Get the MIX version. If not specified, defaults to 2.0.
+ _mixVsn = configHandler.getMixVsn();
+ if (_mixVsn == null) {
+ _mixVsn = "2.0";
+ }
- // Attempt to set schema awareness to avoid validation errors.
- try {
- parser.setFeature("http://xml.org/sax/features/validation", true);
- parser.setProperty("http://java.sun.com/xml/jaxp/"
- + "properties/schemaLanguage",
- "http://www.w3.org/2001/XMLSchema");
- } catch (SAXException saxe) {
- }
+ // Get the maximum number of bytes to examine when doing
+ // pseudo-signature checking
+ _sigBytes = configHandler.getSigBytes();
+ // If a log level was specified in the config file,
+ // attempt to set it, unless it was already explicitly set.
+ if (_logLevel == null) {
+ _logLevel = configHandler.getLogLevel();
+ if (_logLevel != null) {
try {
- String canonicalPath = config.getCanonicalPath();
- String fileURL = "file://";
- if (canonicalPath.charAt(0) != '/') {
- fileURL += Character.toString('/');
- }
- fileURL += canonicalPath;
- parser.parse(fileURL);
- } catch (IOException ioe) {
- throw new JhoveException(CoreMessageConstants.EXC_CONF_FILE_UNRDBL
- + configFile, ioe);
- } catch (SAXException saxe) {
- throw new JhoveException(CoreMessageConstants.EXC_CONF_FILE_UNPRS
- + saxe.getMessage(), saxe);
- }
-
- // Update the application state to reflect the configuration file,
- // if necessary.
- _jhoveHome = configHandler.getJhoveHome();
-
- _encoding = configHandler.getEncoding();
- if (_encoding == null) {
- _encoding = getFromProperties(ENCODING_PROPERTY);
- if (_encoding == null) {
- _encoding = DEFAULT_ENCODING;
- }
- }
-
- _tempDir = configHandler.getTempDir();
- if (_tempDir == null) {
- _tempDir = getFromProperties(TEMPDIR_PROPERTY);
- if (_tempDir == null) {
- _tempDir = DEFAULT_TEMP;
- }
- }
-
- // Get the MIX version. If not specified, defaults to 2.0.
- _mixVsn = configHandler.getMixVsn();
- if (_mixVsn == null) {
- _mixVsn = "2.0";
- }
-
- // Get the maximum number of bytes to examine when doing
- // pseudo-signature checking
- _sigBytes = configHandler.getSigBytes();
-
- // If a log level was specified in the config file,
- // attempt to set it, unless it was already explicitly set.
- if (_logLevel == null) {
- _logLevel = configHandler.getLogLevel();
- if (_logLevel != null) {
- try {
- _logger.setLevel(Level.parse(_logLevel));
- } catch (SecurityException se) {
- // Can't set the logger level due to security exception
- }
- }
- }
-
- _bufferSize = configHandler.getBufferSize();
- if (_bufferSize < 0) {
- String size = getFromProperties(BUFFER_PROPERTY);
- if (size != null) {
- try {
- _bufferSize = Integer.parseInt(size);
- } catch (Exception e) {
- }
- }
- if (_bufferSize < 0) {
- _bufferSize = DEFAULT_BUFFER;
- }
- }
-
- // Retrieve the ordered lists of modules and output handlers
- List Any non-negative value less than 1024 will result in a buffer size of 1024.
+ */
+ public void setBufferSize(int bufferSize) {
+ if (bufferSize >= 0 && bufferSize < 1024) {
+ _bufferSize = 1024;
+ } else {
+ _bufferSize = bufferSize;
}
-
- /**
- * Sets the current thread for parsing.
- */
- public void setCurrentThread(Thread t) {
- _currentThread = t;
+ }
+
+ /** Sets the output encoding. */
+ public void setEncoding(String encoding) {
+ _encoding = encoding;
+ }
+
+ /** Sets the temporary directory path. */
+ public void setTempDirectory(String tempDir) {
+ _tempDir = tempDir;
+ }
+
+ /**
+ * Sets the log level. The value should be the name of a predefined instance of
+ * java.util.logging.Level, e.g., "WARNING", "INFO", "ALL". This will override the config file
+ * setting.
+ */
+ public void setLogLevel(String level) {
+ _logLevel = level;
+ if (level != null) {
+ try {
+ _logger.setLevel(Level.parse(_logLevel));
+ } catch (Exception e) {
+ }
}
-
- /**
- * Resets the abort flag. This must be called at the beginning of any
- * activity for which the abort flag may subsequently be set.
- */
- public void resetAbort() {
- _abort = false;
+ }
+
+ /** Sets the value to be returned by
- * Currently this code isn't actually used, since the
- * Jhove application is specified as checking only internal
- * signatures. Should some future version or add-on code
- * wish to use it, the code should look something like this:
- * Currently this code isn't actually used, since the Jhove application is specified as
+ * checking only internal signatures. Should some future version or add-on code wish to use it,
+ * the code should look something like this:
+ *
+ * Accessor methods. ****************************************************************
+ */
+
+ /** Returns the message text. */
+ public String getMessage() {
+ return this.message.getMessage();
+ }
+
+ /** Returns the submessage text. */
+ public String getSubMessage() {
+ return this._subMessage;
+ }
+
+ /** Returns the offset to which this message is related. */
+ public long getOffset() {
+ return this._offset;
+ }
+
+ /** Returns the message's identifier. */
+ public String getId() {
+ return this.message.getId();
+ }
+
+ public JhoveMessage getJhoveMessage() {
+ return this.message;
+ }
+
+ @SuppressWarnings("static-method")
+ public String getPrefix() {
+ return "";
+ }
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Module.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Module.java
index c7ef75580..ed6efac50 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Module.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Module.java
@@ -1,8 +1,8 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003-4 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003-4 by JSTOR and the President and Fellows of Harvard College
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
import java.io.*;
@@ -10,255 +10,172 @@
/**
* Public interface for Jhove format-specific plug-in modules.
- *
- * All format modules must implement the Module interface;
- * usually the best way to do this will be to subclass ModuleBase.
- * Modules must be declared in the configuration file and present
- * in the Classpath to be recognized by Jhove.
*
- * @see ModuleBase
+ * All format modules must implement the Module interface; usually the best way to do this will
+ * be to subclass ModuleBase. Modules must be declared in the configuration file and present in the
+ * Classpath to be recognized by Jhove.
+ *
+ * @see ModuleBase
*/
-public interface Module
-{
- public static final int
- MAXIMUM_VERBOSITY = 1,
- MINIMUM_VERBOSITY = 2;
-
- /**
- * Per-instantiation initialization.
- *
- * @param init Initialization parameter. This is typically obtained
- * from the configuration file.
- */
- public void init (String init)
- throws Exception;
-
- /**
- * Sets list of default parameters.
- *
- * @param params A List whose elements are Strings.
- * May be empty.
- */
- public void setDefaultParams (List Initialization methods. ****************************************************************
+ */
+
+ /**
+ * Initializes the feature list. This method puts the following features in the list:
+ *
+ * Every module must initialize the value of _bigEndian for this function, or else assign its
+ * value when parsing a file, to return a meaningful result. For some modules (e.g., ASCII,
+ * endianness has no meaning.
+ */
+ public boolean isBigEndian() {
+ return _bigEndian;
+ }
+
+ /**
+ * Return details as to the specific format versions or variants that are supported by this module
+ */
+ @Override
+ public final String getCoverage() {
+ return _coverage;
+ }
+
+ /** Return the last modification date of this Module, as a Java Date object */
+ @Override
+ public final Date getDate() {
+ return _date;
+ }
+
+ /** Return the array of format names supported by this Module */
+ @Override
+ public final String[] getFormat() {
+ return _format;
+ }
+
+ /** Return the array of MIME type strings for formats supported by this Module */
+ @Override
+ public final String[] getMimeType() {
+ return _mimeType;
+ }
+
+ /** Return the module name */
+ @Override
+ public final String getName() {
+ return _name;
+ }
+
+ /** Return the module note */
+ @Override
+ public final String getNote() {
+ return _note;
+ }
+
+ /** Return the release identifier */
+ @Override
+ public final String getRelease() {
+ return _release;
+ }
+
+ /** Return the RepInfo note */
+ @Override
+ public final String getRepInfoNote() {
+ return _repInfoNote;
+ }
+
+ /** Return the copyright information string */
+ @Override
+ public final String getRights() {
+ return _rights;
+ }
+
+ /** Return the List of Signatures recognized by this Module */
+ @Override
+ public final List It is recommended that features be named using package nomenclature. The following features
+ * are, by default, supported by the modules developed by OIS:
+ *
+ * 6 Basic image parameters ****************************************************************
+ */
+
+ /** 6.1.1 MIME type */
+ private String _mimeType;
+
+ /** 6.1.2 Byte order */
+ private String _byteOrder;
+
+ /** 6.1.3.1 Compression scheme */
+ private int _compressionScheme;
+ /** 6.1.3.2 Compression level */
+ private int _compressionLevel;
+
+ /** 6.1.4.1 Color space */
+ private int _colorSpace;
+
+ /** 6.1.4.2.1 ICC profile name */
+ private String _profileName;
+ /** 6.1.4.2.2 ICC profile url */
+ private String _profileURL;
+
+ /** 6.1.4.3 YCbCr sub-sampling */
+ private int[] _yCbCrSubSampling;
+ /** 6.1.4.4 YCbCr positioning */
+ private int _yCbCrPositioning;
+ /** 6.1.4.5 YCbCr coefficients */
+ private Rational[] _yCbCrCoefficients;
+ /** 6.1.4.6 Reference black and white */
+ private Rational[] _referenceBlackWhite;
+
+ /** 6.1.5.1 Segment type */
+ private int _segmentType;
+ /** 6.1.5.2 Strip offsets */
+ private long[] _stripOffsets;
+ /** 6.1.5.3 Rows per strip */
+ private long _rowsPerStrip;
+ /** 6.1.5.4 Strip byte counts */
+ private long[] _stripByteCounts;
+ /** 6.1.5.5 Tile width */
+ private long _tileWidth;
+ /** 6.1.5.6 Tile length */
+ private long _tileLength;
+ /** 6.1.5.7 Tile offsets */
+ private long[] _tileOffsets;
+ /** 6.1.5.8 Tile byte counts */
+ private long[] _tileByteCounts;
+
+ /** 6.1.6 Planar configuration */
+ private int _planarConfiguration;
+
+ /** 6.2.1 Image identifier */
+ private String _imageIdentifier;
+ /** 6.2.1.1 Image identifier location */
+ private String _imageIdentifierLocation;
+
+ /** 6.2.2 File size */
+ private long _fileSize;
+ /** 6.2.3.1 Checksum method */
+ private int _checksumMethod;
+ /** 6.2.3.2 Checksum value */
+ private String _checksumValue;
+
+ /** 6.2.4 orientation */
+ private int _orientation;
+
+ /** 6.2.5 Display orientation */
+ private int _displayOrientation;
+
+ /** 6.2.6.1 X targeted display aspect ratio */
+ private long _xTargetedDisplayAR;
+ /** 6.2.6.2 Y targeted display aspect ratio */
+ private long _yTargetedDisplayAR;
+
+ /** 6.3 Preferred presentation */
+ private String _preferredPresentation;
+
+ /**
+ * **************************************************************** Special Format Characteristics
+ * From Data Dictionary - Technical Metadata for Digital Still Images (ANSI/NISO Z39.87-2006) Only
+ * used for JPEG2000 format ****************************************************************
+ */
+ /** 7.2.1.2.1 tiles */
+ private String _jp2Tiles;
+ /** 7.2.1.2.2 qualityLayers */
+ private int _jp2Layers;
+ /** 7.2.1.2.3resolutionLevels */
+ private int _jp2ResolutionLevels;
+
+ /**
+ * **************************************************************** 7 Image creation
+ * ****************************************************************
+ */
+
+ /** 7.1 Source type */
+ private String _sourceType;
+
+ /** 7.2 Source ID */
+ private String _sourceID;
+
+ /** 7.3 Image producer */
+ private String _imageProducer;
+
+ /** 7.4 Host computer */
+ private String _hostComputer;
+ /** 7.4.1 Operating system */
+ private String _os;
+ /** 7.4.2 OS version */
+ private String _osVersion;
+
+ /** 7.5 Device source */
+ private String _deviceSource;
+
+ /** 7.6.1.1 Scanner system manufacturer */
+ private String _scannerManufacturer;
+ /** 7.6.1.2.1 Scanner model name */
+ private String _scannerModelName;
+ /** 7.6.1.2.2 Scanner model number */
+ private String _scannerModelNumber;
+ /** 7.6.1.2.3 Scanner model serial number */
+ private String _scannerModelSerialNo;
+ /** 7.6.2.1 Scanning software */
+ private String _scanningSoftware;
+ /** 7.6.2.2 Scanning software version number */
+ private String _scanningSoftwareVersionNo;
+
+ /** 7.6.3 Pixel size (in meters) */
+ private double _pixelSize;
+
+ /** 7.6.3.2.1 X physical scan resolution */
+ private double _xPhysScanResolution;
+ /** 7.6.3.2.2 Y physical scan resolution */
+ private double _yPhysScanResolution;
+
+ /** 7.7.1 Digital camera manufacturer */
+ private String _digitalCameraManufacturer;
+ /** 7.7.2 Digital camera model name */
+ private String _digitalCameraModelName;
+ /** 7.7.2 Digital camera model number */
+ private String _digitalCameraModelNumber;
+ /** 7.7.2 Digital camera model serial number */
+ private String _digitalCameraModelSerialNo;
+
+ /** 7.7.3.1 F number */
+ private double _fNumber;
+ /** 7.7.3.2 Exposure time */
+ private double _exposureTime;
+
+ private int _exposureProgram;
+ private String _exifVersion;
+ private Rational _maxApertureValue;
+
+ /** 7.7.3.3 Brightness */
+ private Rational _brightness;
+ /** 7.7.3.4 Exposure bias */
+ private Rational _exposureBias;
+ /** 7.7.3.5 Subject distance */
+ private double[] _subjectDistance;
+ /** 7.7.3.6 Metering mode */
+ private int _meteringMode;
+ /** 7.7.3.7 Scene illuminant */
+ private int _sceneIlluminant;
+ /** 7.7.3.8 Color temperature */
+ private double _colorTemp;
+ /** 7.7.3.9 Focal length (in meters) */
+ private double _focalLength;
+ /** 7.7.3.10 Flash */
+ private int _flash;
+ /** 7.7.3.11 Flash energy */
+ private Rational _flashEnergy;
+ /** 7.7.3.12 Flash return */
+ private int _flashReturn;
+ /** 7.7.3.13 Back light */
+ private int _backLight;
+ /** 7.7.3.14 Exposure index */
+ private double _exposureIndex;
+ /** 7.7.3.15 Auto focus */
+ private int _autoFocus;
+ /** 7.7.3.16.1 X print aspect ratio */
+ private double _xPrintAspectRatio;
+ /** 7.7.3.16.2 Y print aspect ratio */
+ private double _yPrintAspectRatio;
+
+ /** 7.8 Sensor */
+ private int _sensor;
+
+ /** 7.9 Date/time created */
+ private String _dateTimeCreated;
+
+ /** 7.10 Methodology */
+ private String _methodology;
+
+ /**
+ * **************************************************************** Imaging performance assessment
+ * ****************************************************************
+ */
+
+ /** 8.1.1 Sampling frequency plane */
+ private int _samplingFrequencyPlane;
+ /** 8.1.2 Sampling frequency unit */
+ private int _samplingFrequencyUnit;
+ /** 8.1.3 X sampling frequency */
+ private Rational _xSamplingFrequency;
+ /** 8.1.4 Y sampling frequency */
+ private Rational _ySamplingFrequency;
+ /** 8.1.5 Image width */
+ private long _imageWidth;
+ /** 8.1.6 Image Length */
+ private long _imageLength;
+ /** 8.1.7 Source X dimension */
+ private double _sourceXDimension;
+ /** 8.1.8 Source X dimension unit */
+ private int _sourceXDimensionUnit;
+ /** 8.1.9 Source Y dimension */
+ private double _sourceYDimension;
+ /** 8.1.10 Source Y dimension unit */
+ private int _sourceYDimensionUnit;
+
+ /** 8.2.1 Bits per sample */
+ private int[] _bitsPerSample;
+ /** 8.2.2 Samples per pixel */
+ private int _samplesPerPixel;
+ /** 8.2.3 Extra samples */
+ private int[] _extraSamples;
+
+ /** 8.2.4.1 Colormap reference */
+ private String _colormapReference;
+ /** 8.2.4.2 Colormap bit code value */
+ private int[] _colormapBitCodeValue;
+ /** 8.2.4.3 Colormap red value */
+ private int[] _colormapRedValue;
+ /** 8.2.4.4 Colormap green value */
+ private int[] _colormapGreenValue;
+ /** 8.2.4.5 Colormap blue value */
+ private int[] _colormapBlueValue;
+
+ /** 8.2.5 Gray response curve */
+ private int[] _grayResponseCurve;
+ /** 8.2.6 Gray response unit */
+ private int _grayResponseUnit;
+
+ /** 8.2.7.1 Whitepoint X value */
+ private Rational _whitePointXValue;
+ /** 8.2.7.2 Whitepoint Y value */
+ private Rational _whitePointYValue;
+
+ /** 8.2.8.1 Primary chromaticities Red X */
+ private Rational _primaryChromaticitiesRedX;
+ /** 8.2.8.2 Primary chromaticities Red Y */
+ private Rational _primaryChromaticitiesRedY;
+ /** 8.2.8.3 Primary chromaticities Green X */
+ private Rational _primaryChromaticitiesGreenX;
+ /** 8.2.8.4 Primary chromaticities Green Y */
+ private Rational _primaryChromaticitiesGreenY;
+ /** 8.2.8.5 Primary chromaticities Blue X */
+ private Rational _primaryChromaticitiesBlueX;
+ /** 8.2.8.6 Primary chromaticities Blue Y */
+ private Rational _primaryChromaticitiesBlueY;
+
+ /* 8.3 Target data */
+ /** 8.3.1 Target Type */
+ private int _targetType;
+ /** 8.3.2.1 TargetIDManufacturer */
+ private String _targetIDManufacturer;
+ /** 8.3.2.2 TargetIDName */
+ private String _targetIDName;
+ /** 8.3.2.3 TargetIDNo */
+ private String _targetIDNo;
+ /** 8.3.2.4 TargetIDMedia */
+ private String _targetIDMedia;
+ /** 8.3.3 ImageData */
+ private String _imageData;
+ /** 8.3.4 PerformanceData */
+ private String _performanceData;
+ /** 8.3.5 Profiles */
+ private String _profiles;
+
+ /* 9 Change history */
+ /** 9.1.1 DateTimeProcessed */
+ private String _dateTimeProcessed;
+ /** 9.1.2 SourceData */
+ private String _sourceData;
+ /** 9.1.3 ProcessingAgency */
+ private String _processingAgency;
+ /** 9.1.4.1 ProcessingSoftwareName */
+ private String _processingSoftwareName;
+ /** 9.1.4.2 ProcessingSoftwareVersion */
+ private String _processingSoftwareVersion;
+ /** 9.1.5 ProcessingActions */
+ private String[] _processingActions;
+
+ /* 9.2 PreviousImageMetadata -- not currently supported */
+
+ /* Data for Swing-based viewer. */
+ private Property _viewerData;
+
+ /**
+ * **************************************************************** CLASS CONSTRUCTOR.
+ * ****************************************************************
+ */
+
+ /** Instantiate a Accessor methods. ****************************************************************
+ */
+
+ /** Get 7.7.3.15 auto focus. */
+ public int getAutoFocus() {
+ return _autoFocus;
+ }
+
+ /** Get 7.7.3.13 back light. */
+ public int getBackLight() {
+ return _backLight;
+ }
+
+ /** Get 8.2.1 bits per sample. */
+ public int[] getBitsPerSample() {
+ return _bitsPerSample;
+ }
+
+ /** Get 7.7.3.3 Brightness. */
+ public Rational getBrightness() {
+ return _brightness;
+ }
+
+ /** Get 6.1.2 byte order. */
+ public String getByteOrder() {
+ return _byteOrder;
+ }
+
+ /** Get 6.2.3.1 Checksum method. */
+ public int getChecksumMethod() {
+ return _checksumMethod;
+ }
+
+ /** Get 6.2.3.2 Checksum value. */
+ public String getChecksumValue() {
+ return _checksumValue;
+ }
+
+ /** Get 8.2.4.2 colormap bit code value. */
+ public int[] getColormapBitCodeValue() {
+ return _colormapBitCodeValue;
+ }
+
+ /** Get 8.2.4.5 colormap blue value. */
+ public int[] getColormapBlueValue() {
+ return _colormapBlueValue;
+ }
+
+ /** Get 8.2.4.4 colormap green value. */
+ public int[] getColormapGreenValue() {
+ return _colormapGreenValue;
+ }
+
+ /** Get 8.2.4.3 colormap red value. */
+ public int[] getColormapRedValue() {
+ return _colormapRedValue;
+ }
+
+ /** Get 8.2.4.1 colormap reference. */
+ public String getColormapReference() {
+ return _colormapReference;
+ }
+
+ /** Get 6.1.4.1 color space. */
+ public int getColorSpace() {
+ return _colorSpace;
+ }
+
+ /** Get 7.7.3.8 color temperature. */
+ public double getColorTemp() {
+ return _colorTemp;
+ }
+
+ /** Get 6.1.3.2 compression level. */
+ public int getCompressionLevel() {
+ return _compressionLevel;
+ }
+
+ /** Get 6.1.3.1 compression scheme. */
+ public int getCompressionScheme() {
+ return _compressionScheme;
+ }
+
+ /** Get 7.9 date/time created. */
+ public String getDateTimeCreated() {
+ return _dateTimeCreated;
+ }
+
+ /** Get 9.1.1 DateTimeProcessed */
+ public String getDateTimeProcessed() {
+ return _dateTimeProcessed;
+ }
+
+ /** Get 7.5 device source. */
+ public String getDeviceSource() {
+ return _deviceSource;
+ }
+
+ /** Get 7.7.1 digital camera manufacturer. */
+ public String getDigitalCameraManufacturer() {
+ return _digitalCameraManufacturer;
+ }
+
+ /** Get 7.7.2 digital camera model. */
+ public String getDigitalCameraModelName() {
+ return _digitalCameraModelName;
+ }
+
+ public String getDigitalCameraModelNumber() {
+ return _digitalCameraModelNumber;
+ }
+
+ public String getDigitalCameraModelSerialNo() {
+ return _digitalCameraModelSerialNo;
+ }
+
+ /** Get 6.2.5 Display orientation. */
+ public int getDisplayOrientation() {
+ return _displayOrientation;
+ }
+
+ public String getExifVersion() {
+ return _exifVersion;
+ }
+
+ /** Get 7.7.3.4 exposure bias. */
+ public Rational getExposureBias() {
+ return _exposureBias;
+ }
+
+ /** Get 7.7.3.14 exposure index. */
+ public double getExposureIndex() {
+ return _exposureIndex;
+ }
+
+ public int getExposureProgram() {
+ return _exposureProgram;
+ }
+
+ /** Get 7.7.3.2 exposure time. */
+ public double getExposureTime() {
+ return _exposureTime;
+ }
+
+ /** Get 8.2.3 extra samples. */
+ public int[] getExtraSamples() {
+ return _extraSamples;
+ }
+
+ /** Get 6.2.2 file size. */
+ public long getFileSize() {
+ return _fileSize;
+ }
+
+ /** Get 7.7.3.10 flash. */
+ public int getFlash() {
+ return _flash;
+ }
+
+ /** Get 7.7.3.11 flash energy. */
+ public Rational getFlashEnergy() {
+ return _flashEnergy;
+ }
+
+ /** Get 7.7.3.12 flash return. */
+ public int getFlashReturn() {
+ return _flashReturn;
+ }
+
+ /** Get 7.7.3.1 F number. */
+ public double getFNumber() {
+ return _fNumber;
+ }
+
+ /** Get 7.7.3.9 focal length. */
+ public double getFocalLength() {
+ return _focalLength;
+ }
+
+ /** Get 8.2.5 gray response curve. */
+ public int[] getGrayResponseCurve() {
+ return _grayResponseCurve;
+ }
+
+ /** Get 8.2.6 gray response unit. */
+ public int getGrayResponseUnit() {
+ return _grayResponseUnit;
+ }
+
+ /** Get 7.4 host computer. */
+ public String getHostComputer() {
+ return _hostComputer;
+ }
+
+ /** Get 8.3.3 ImageData */
+ public String getImageData() {
+ return _imageData;
+ }
+
+ /** Get 6.2.1 Image identifier. */
+ public String getImageIdentifier() {
+ return _imageIdentifier;
+ }
+
+ /** Get 6.2.1.1 Image identifier location. */
+ public String getImageIdentifierLocation() {
+ return _imageIdentifierLocation;
+ }
+
+ /** Get 8.1.6 image length. */
+ public long getImageLength() {
+ return _imageLength;
+ }
+
+ /** Get 7.3 Image producer. */
+ public String getImageProducer() {
+ return _imageProducer;
+ }
+
+ /** Get 8.1.5 image width. */
+ public long getImageWidth() {
+ return _imageWidth;
+ }
+
+ public Rational getMaxApertureValue() {
+ return _maxApertureValue;
+ }
+
+ /** Get 7.7.3.6 metering mode. */
+ public int getMeteringMode() {
+ return _meteringMode;
+ }
+
+ /** Get 7.10 methodology. */
+ public String getMethodology() {
+ return _methodology;
+ }
+
+ /** Get 6.1.1 MIME type. */
+ public String getMimeType() {
+ return _mimeType;
+ }
+
+ /** Get 6.2.4 Orientation. */
+ public int getOrientation() {
+ return _orientation;
+ }
+
+ /** Get 7.4.1 OS (operating system). */
+ public String getOS() {
+ return _os;
+ }
+
+ /** Get 7.4.2 OS version. */
+ public String getOSVersion() {
+ return _osVersion;
+ }
+
+ /** Get 8.3.4 PerformanceData. */
+ public String getPerformanceData() {
+ return _performanceData;
+ }
+
+ /** Get 7.6.3.1 pixel size. */
+ public double getPixelSize() {
+ return _pixelSize;
+ }
+
+ /** Get 6.1.6 Planar configuration. */
+ public int getPlanarConfiguration() {
+ return _planarConfiguration;
+ }
+
+ /** Get 6.3 preferred presentation. */
+ public String getPreferredPresentation() {
+ return _preferredPresentation;
+ }
+
+ public String getJp2Tiles() {
+ return _jp2Tiles;
+ }
+
+ public void setJp2Tiles(String jp2Tiles) {
+ this._jp2Tiles = jp2Tiles;
+ }
+
+ public int getJp2Layers() {
+ return _jp2Layers;
+ }
+
+ public void setJp2Layers(int jp2Layers) {
+ this._jp2Layers = jp2Layers;
+ }
+
+ public int getJp2ResolutionLevels() {
+ return _jp2ResolutionLevels;
+ }
+
+ public void setJp2ResolutionLevels(int jp2ResolutionLevels) {
+ this._jp2ResolutionLevels = jp2ResolutionLevels;
+ }
+
+ /** Get 8.2.8.5 primary chromaticities blue X. */
+ public Rational getPrimaryChromaticitiesBlueX() {
+ return _primaryChromaticitiesBlueX;
+ }
+
+ /** Get 8.2.8.6 primary chromaticities blue Y. */
+ public Rational getPrimaryChromaticitiesBlueY() {
+ return _primaryChromaticitiesBlueY;
+ }
+
+ /** Get 8.2.8.3 primary chromaticities green X. */
+ public Rational getPrimaryChromaticitiesGreenX() {
+ return _primaryChromaticitiesGreenX;
+ }
+
+ /** Get 8.2.8.4 primary chromaticities green Y. */
+ public Rational getPrimaryChromaticitiesGreenY() {
+ return _primaryChromaticitiesGreenY;
+ }
+
+ /** Get 8.2.8.1 primary chromaticities red X. */
+ public Rational getPrimaryChromaticitiesRedX() {
+ return _primaryChromaticitiesRedX;
+ }
+
+ /** Get 8.2.8.2 primary chromaticities red Y. */
+ public Rational getPrimaryChromaticitiesRedY() {
+ return _primaryChromaticitiesRedY;
+ }
+
+ /** Get 9.1.5 ProcessingActions. */
+ public String[] getProcessingActions() {
+ return _processingActions;
+ }
+
+ /** Get 9.1.3 ProcessingAgency. */
+ public String getProcessingAgency() {
+ return _processingAgency;
+ }
+
+ /** Get 9.1.4.1 ProcessingSoftwareName */
+ public String getProcessingSoftwareName() {
+ return _processingSoftwareName;
+ }
+
+ /** Get 9.1.4.2 ProcessingSoftwareVersion */
+ public String getProcessingSoftwareVersion() {
+ return _processingSoftwareVersion;
+ }
+
+ /** Get 6.1.4.2.1 ICC profile name. */
+ public String getProfileName() {
+ return _profileName;
+ }
+
+ /** Get 8.3.5 Profiles */
+ public String getProfiles() {
+ return _profiles;
+ }
+
+ /** Get 6.1.4.2.2 ICC profile URL. */
+ public String getProfileURL() {
+ return _profileURL;
+ }
+
+ /** Get 6.1.4.6 Reference black and white. */
+ public Rational[] getReferenceBlackWhite() {
+ return _referenceBlackWhite;
+ }
+
+ /** Get 6.1.5.3 Rows per strip. */
+ public long getRowsPerStrip() {
+ return _rowsPerStrip;
+ }
+
+ /** Get 8.2.2 samples per pixel. */
+ public int getSamplesPerPixel() {
+ return _samplesPerPixel;
+ }
+
+ /** Get 8.1.1 sampling frequency plane. */
+ public int getSamplingFrequencyPlane() {
+ return _samplingFrequencyPlane;
+ }
+
+ /** Get 8.1.2 sampling frequency unit. */
+ public int getSamplingFrequencyUnit() {
+ return _samplingFrequencyUnit;
+ }
+
+ /** Get 7.6.1.1 scanner manufacturer. */
+ public String getScannerManufacturer() {
+ return _scannerManufacturer;
+ }
+
+ /** Get 7.6.1.2.1 scanner model name. */
+ public String getScannerModelName() {
+ return _scannerModelName;
+ }
+
+ /** Get 7.6.1.2.2 scanner model number. */
+ public String getScannerModelNumber() {
+ return _scannerModelNumber;
+ }
+
+ /** Get 7.6.1.2.3 scanner model serial number. */
+ public String getScannerModelSerialNo() {
+ return _scannerModelSerialNo;
+ }
+
+ /** Get 7.6.2.1 scanning software. */
+ public String getScanningSoftware() {
+ return _scanningSoftware;
+ }
+
+ /** Get 7.6.2.2 scanning software version number. */
+ public String getScanningSoftwareVersionNo() {
+ return _scanningSoftwareVersionNo;
+ }
+
+ /** Get 7.7.3.7 scene illuminant. */
+ public int getSceneIlluminant() {
+ return _sceneIlluminant;
+ }
+
+ /** Get 6.1.5.1 segment type. */
+ public int getSegmentType() {
+ return _segmentType;
+ }
+
+ /** Get 7.8 sensor. */
+ public int getSensor() {
+ return _sensor;
+ }
+
+ /** Get 9.1.2 SourceData. */
+ public String getSourceData() {
+ return _sourceData;
+ }
+
+ /** Get 7.2 source ID. */
+ public String getSourceID() {
+ return _sourceID;
+ }
+
+ /** Get 7.1 Source type. */
+ public String getSourceType() {
+ return _sourceType;
+ }
+
+ public double getSourceXDimension() {
+ return _sourceXDimension;
+ }
+
+ public int getSourceXDimensionUnit() {
+ return _sourceXDimensionUnit;
+ }
+
+ public double getSourceYDimension() {
+ return _sourceYDimension;
+ }
+
+ public int getSourceYDimensionUnit() {
+ return _sourceYDimensionUnit;
+ }
+
+ /** Get 6.1.5.4 Strip byte counts. */
+ public long[] getStripByteCounts() {
+ return _stripByteCounts;
+ }
+
+ /** Get 6.1.5.2 Strip offsets. */
+ public long[] getStripOffsets() {
+ return _stripOffsets;
+ }
+
+ /** Get 7.7.3.5 Subject distance. */
+ public double[] getSubjectDistance() {
+ return _subjectDistance;
+ }
+
+ /** Get 8.3.2.1 TargetIDManufacturer */
+ public String getTargetIDManufacturer() {
+ return _targetIDManufacturer;
+ }
+
+ /** Get 8.3.2.3 TargetIDMedia */
+ public String getTargetIDMedia() {
+ return _targetIDMedia;
+ }
+
+ /** Get 8.3.2.2 TargetIDName */
+ public String getTargetIDName() {
+ return _targetIDName;
+ }
+
+ /** Get 8.3.2.3 TargetIDNo */
+ public String getTargetIDNo() {
+ return _targetIDNo;
+ }
+
+ /** Get 8.3.1 Target Type */
+ public int getTargetType() {
+ return _targetType;
+ }
+
+ /** Get 6.1.5.8 Tile byte counts. */
+ public long[] getTileByteCounts() {
+ return _tileByteCounts;
+ }
+
+ /** Get 6.1.5.6 Tile length. */
+ public long getTileLength() {
+ return _tileLength;
+ }
+
+ /** Get 6.1.5.7 Tile offsets. */
+ public long[] getTileOffsets() {
+ return _tileOffsets;
+ }
+
+ /** Get 6.1.5.5 Tile width. */
+ public long getTileWidth() {
+ return _tileWidth;
+ }
+
+ /** Get 8.2.7.1 white point X value. */
+ public Rational getWhitePointXValue() {
+ return _whitePointXValue;
+ }
+
+ /** Get 8.2.7.2 white point Y value. */
+ public Rational getWhitePointYValue() {
+ return _whitePointYValue;
+ }
+
+ /** Get 7.7.3.16.1 X print aspect ratio. */
+ public double getXPrintAspectRatio() {
+ return _xPrintAspectRatio;
+ }
+
+ /** Get 7.6.3.2.1 X physcal scanning resolution. */
+ public double getXPhysScanResolution() {
+ return _xPhysScanResolution;
+ }
+
+ /** Get 8.1.3 X sampling frequency. */
+ public Rational getXSamplingFrequency() {
+ return _xSamplingFrequency;
+ }
+
+ /** Get 6.2.6 X targeted display aspect ratio. */
+ public long getXTargetedDisplayAR() {
+ return _xTargetedDisplayAR;
+ }
+
+ /** Get 6.1.4.5 YCbCr coefficients. */
+ public Rational[] getYCbCrCoefficients() {
+ return _yCbCrCoefficients;
+ }
+
+ /** Get 6.1.4.4 YCbCr positioning. */
+ public int getYCbCrPositioning() {
+ return _yCbCrPositioning;
+ }
+
+ /** Get 6.1.4.3 YCbCr subsampling. */
+ public int[] getYCbCrSubSampling() {
+ return _yCbCrSubSampling;
+ }
+
+ /** Get 7.6.3.2.2 Y physcal scanning resolution. */
+ public double getYPhysScanResolution() {
+ return _yPhysScanResolution;
+ }
+
+ /** Get 7.7.3.16.2 Y print aspect ratio. */
+ public double getYPrintAspectRatio() {
+ return _yPrintAspectRatio;
+ }
+
+ /** Get 8.1.4 Y sampling frequency. */
+ public Rational getYSamplingFrequency() {
+ return _ySamplingFrequency;
+ }
+
+ /** Get 6.2.7 Y targeted display aspect ratio. */
+ public long getYTargetedDisplayAR() {
+ return _yTargetedDisplayAR;
+ }
+
+ /** Get data for Swing GUI viewer. */
+ public Property getViewerData() {
+ return _viewerData;
+ }
+
+ /**
+ * **************************************************************** Mutator methods.
+ * ****************************************************************
+ */
+
+ /**
+ * Set 7.7.3.15 auto focus.
+ *
+ * @param focus Auto focus
+ */
+ public void setAutoFocus(int focus) {
+ _autoFocus = focus;
+ }
+
+ /**
+ * Set 7.7.3.13 back light.
+ *
+ * @param light Back light
+ */
+ public void setBackLight(int light) {
+ _backLight = light;
+ }
+
+ /**
+ * Set 8.2.1 bits per sample.
+ *
+ * @param bits Bits per sample
+ */
+ public void setBitsPerSample(int[] bits) {
+ _bitsPerSample = bits;
+ }
+
+ /**
+ * Set 7.7.3.3 brightness.
+ *
+ * @param brightness Brightness
+ */
+ public void setBrightness(Rational brightness) {
+ _brightness = brightness;
+ }
+
+ /**
+ * Set 6.1.2 byte order.
+ *
+ * @param order Byte order
+ */
+ public void setByteOrder(String order) {
+ _byteOrder = order;
+ }
+
+ /**
+ * Set 8.2.4.2 colormap bit code value.
+ *
+ * @param value Bit code value
+ */
+ public void setColormapBitCodeValue(int[] value) {
+ _colormapBitCodeValue = value;
+ }
+
+ /**
+ * Set 8.2.4.4 colormap blue value.
+ *
+ * @param value Blue value
+ */
+ public void setColormapBlueValue(int[] value) {
+ _colormapBlueValue = value;
+ }
+
+ /**
+ * Set 8.2.4.3 colormap green value.
+ *
+ * @param value Green value
+ */
+ public void setColormapGreenValue(int[] value) {
+ _colormapGreenValue = value;
+ }
+
+ /**
+ * Set 8.2.4.2 colormap red value.
+ *
+ * @param value Red value
+ */
+ public void setColormapRedValue(int[] value) {
+ _colormapRedValue = value;
+ }
+
+ /**
+ * Set 8.2.4.1 colormap reference.
+ *
+ * @param reference Colormap reference
+ */
+ public void setColormapReference(String reference) {
+ _colormapReference = reference;
+ }
+
+ /**
+ * Set 6.1.4.1 color space
+ *
+ * @param space Color space
+ */
+ public void setColorSpace(int space) {
+ _colorSpace = space;
+ }
+
+ /**
+ * Set 7.7.3.8 color temperature.
+ *
+ * @param temp Color temperature
+ */
+ public void setColorTemp(double temp) {
+ _colorTemp = temp;
+ }
+
+ /**
+ * Set 6.1.3.2 compression level.
+ *
+ * @param level Compression level
+ */
+ public void setCompressionLevel(int level) {
+ _compressionLevel = level;
+ }
+
+ /**
+ * Set 6.1.3.1 compression scheme.
+ *
+ * @param scheme Compression scheme
+ */
+ public void setCompressionScheme(int scheme) {
+ _compressionScheme = scheme;
+ }
+
+ /**
+ * Set 7.9 date/time created. TIFF dates get converted to ISO 8601 format.
+ *
+ * @param date Date/time created
+ */
+ public void setDateTimeCreated(String date) {
+ _dateTimeCreated = make8601Valid(date);
+ }
+
+ /**
+ * Set 9.1.1 DateTimeProcessed. TIFF dates get converted to ISO 8601 format.
+ *
+ * @param date Date/time processed
+ */
+ public void setDateTimeProcessed(String date) {
+ _dateTimeProcessed = make8601Valid(date);
+ }
+
+ /**
+ * Set 7.5 Device source.
+ *
+ * @param source Device source
+ */
+ public void setDeviceSource(String source) {
+ _deviceSource = source;
+ }
+
+ /**
+ * Set 7.7.1 digital camera manufacturer.
+ *
+ * @param manufacturer Camera manufacturer
+ */
+ public void setDigitalCameraManufacturer(String manufacturer) {
+ _digitalCameraManufacturer = manufacturer;
+ }
+
+ /**
+ * Set 7.7.2 digital camera model.
+ *
+ * @param modelName Camera model
+ */
+ public void setDigitalCameraModelName(String modelName) {
+ _digitalCameraModelName = modelName;
+ }
+
+ public void setDigitalCameraModelNumber(String modelNumber) {
+ _digitalCameraModelNumber = modelNumber;
+ }
+
+ public void setDigitalCameraModelSerialNo(String modelSerialNo) {
+ _digitalCameraModelSerialNo = modelSerialNo;
+ }
+
+ /**
+ * Set 6.2.5 display orientation.
+ *
+ * @param orientation Display orientation
+ */
+ public void setDisplayOrientation(int orientation) {
+ _displayOrientation = orientation;
+ }
+
+ public void setExifVersion(String version) {
+ _exifVersion = version;
+ }
+
+ /**
+ * Set 7.2.3.4 exposure bias.
+ *
+ * @param bias Exposure bias
+ */
+ public void setExposureBias(Rational bias) {
+ _exposureBias = bias;
+ }
+
+ /**
+ * Set 7.2.3.14 exposure index.
+ *
+ * @param index Exposure index
+ */
+ public void setExposureIndex(double index) {
+ _exposureIndex = index;
+ }
+
+ public void setExposureProgram(int program) {
+ _exposureProgram = program;
+ }
+
+ /**
+ * Set 7.7.3.2 exposure time.
+ *
+ * @param time Exposure time
+ */
+ public void setExposureTime(double time) {
+ _exposureTime = time;
+ }
+
+ /**
+ * Set 8.2.3 extra samples.
+ *
+ * @param extra Extra samples
+ */
+ public void setExtraSamples(int[] extra) {
+ _extraSamples = extra;
+ }
+
+ /**
+ * Set 6.2.2 file size.
+ *
+ * @param size File size
+ */
+ public void setFileSize(long size) {
+ _fileSize = size;
+ }
+
+ /**
+ * Set 7.7.3.1 F number.
+ *
+ * @param f F number
+ */
+ public void setFNumber(double f) {
+ _fNumber = f;
+ }
+
+ /**
+ * Set 7.7.3.11 flash energy.
+ *
+ * @param energy Flash energy
+ */
+ public void setFlashEnergy(Rational energy) {
+ _flashEnergy = energy;
+ }
+
+ /**
+ * Set 7.7.3.12 flash return.
+ *
+ * @param ret Flash return
+ */
+ public void setFlashReturn(int ret) {
+ _flashReturn = ret;
+ }
+
+ /**
+ * Set 7.7.3.10 flash.
+ *
+ * @param flash Flash
+ */
+ public void setFlash(int flash) {
+ _flash = flash;
+ }
+
+ /**
+ * Set 7.7.3.9 focal length (double meters).
+ *
+ * @param length Focal length
+ */
+ public void setFocalLength(double length) {
+ _focalLength = length;
+ }
+
+ /**
+ * Set 8.2.5 gray response curve.
+ *
+ * @param curve Gray response curve
+ */
+ public void setGrayResponseCurve(int[] curve) {
+ _grayResponseCurve = curve;
+ }
+
+ /**
+ * Set 8.2.6 gray response unit.
+ *
+ * @param unit Gray response unit
+ */
+ public void setGrayResponseUnit(int unit) {
+ _grayResponseUnit = unit;
+ }
+
+ /**
+ * Set 7.4 host computer.
+ *
+ * @param computer Host computer
+ */
+ public void setHostComputer(String computer) {
+ _hostComputer = computer;
+ }
+
+ /**
+ * Set 8.3.3 ImageData.
+ *
+ * @param imageData Image Data filename or URN
+ */
+ public void setImageData(String imageData) {
+ _imageData = imageData;
+ }
+
+ /**
+ * Set 6.2.1 Image identifier.
+ *
+ * @param identifier Image identifier
+ */
+ public void setImageIdentifier(String identifier) {
+ _imageIdentifier = identifier;
+ }
+
+ /**
+ * Set 6.2.1 Image identifier location.
+ *
+ * @param location identifier location
+ */
+ public void setImageIdentifierLocation(String location) {
+ _imageIdentifierLocation = location;
+ }
+
+ /**
+ * Set 8.1.6 image length.
+ *
+ * @param length Image length
+ */
+ public void setImageLength(long length) {
+ _imageLength = length;
+ }
+
+ /**
+ * Set 7.3 image producer.
+ *
+ * @param producer Image producer
+ */
+ public void setImageProducer(String producer) {
+ _imageProducer = producer;
+ }
+
+ /**
+ * Set 8.1.5 image width.
+ *
+ * @param width Image width
+ */
+ public void setImageWidth(long width) {
+ _imageWidth = width;
+ }
+
+ public void setMaxApertureValue(Rational value) {
+ _maxApertureValue = value;
+ }
+
+ /**
+ * Set 7.7.3.6 metering mode.
+ *
+ * @param mode Metering mode
+ */
+ public void setMeteringMode(int mode) {
+ _meteringMode = mode;
+ }
+
+ /**
+ * Set 7.10 methodology.
+ *
+ * @param methodology Methodology
+ */
+ public void setMethodology(String methodology) {
+ _methodology = methodology;
+ }
+
+ /**
+ * Set 6.1.1 MIME type.
+ *
+ * @param type MIME type
+ */
+ public void setMimeType(String type) {
+ _mimeType = type;
+ }
+
+ /**
+ * Set 6.2.4 orientation.
+ *
+ * @param orientation Orientation
+ */
+ public void setOrientation(int orientation) {
+ _orientation = orientation;
+ }
+
+ /* Set 7.4.1 OS (operating system).
+ * @param os Operating system
+ */
+ public void setOS(String os) {
+ _os = os;
+ }
+
+ /**
+ * Set 7.4.2 OS version.
+ *
+ * @param version OS version
+ */
+ public void setOSVersion(String version) {
+ _osVersion = version;
+ }
+
+ /**
+ * Set 8.3.4 PerformanceData.
+ *
+ * @param performanceData Performance data filename or URN
+ */
+ public void setPerformanceData(String performanceData) {
+ _performanceData = performanceData;
+ }
+
+ /**
+ * Set 7.6.3.1 pixel size.
+ *
+ * @param size Pixel size
+ */
+ public void setPixelSize(double size) {
+ _pixelSize = size;
+ }
+
+ /**
+ * Set 6.1.6 Planar configuration.
+ *
+ * @param configuration Planar configuration
+ */
+ public void setPlanarConfiguration(int configuration) {
+ _planarConfiguration = configuration;
+ }
+
+ /**
+ * Set 6.3 preferred presentation.
+ *
+ * @param presentation Preferred presentation
+ */
+ public void setPreferredPresentation(String presentation) {
+ _preferredPresentation = presentation;
+ }
+
+ /**
+ * Set 8.2.8.5 primary chromaticities blue X.
+ *
+ * @param x Blue x
+ */
+ public void setPrimaryChromaticitiesBlueX(Rational x) {
+ _primaryChromaticitiesBlueX = x;
+ }
+
+ /**
+ * Set 8.2.8.6 primary chromaticities blue Y.
+ *
+ * @param y Blue y
+ */
+ public void setPrimaryChromaticitiesBlueY(Rational y) {
+ _primaryChromaticitiesBlueY = y;
+ }
+
+ /**
+ * Set 8.2.8.3 primary chromaticities green X.
+ *
+ * @param x Green x
+ */
+ public void setPrimaryChromaticitiesGreenX(Rational x) {
+ _primaryChromaticitiesGreenX = x;
+ }
+
+ /**
+ * Set 8.2.8.4 primary chromaticities green Y.
+ *
+ * @param y Green y
+ */
+ public void setPrimaryChromaticitiesGreenY(Rational y) {
+ _primaryChromaticitiesGreenY = y;
+ }
+
+ /**
+ * Set 8.2.8.1 primary chromaticities red X.
+ *
+ * @param x Red x
+ */
+ public void setPrimaryChromaticitiesRedX(Rational x) {
+ _primaryChromaticitiesRedX = x;
+ }
+
+ /**
+ * Set 8.2.8.2 primary chromaticities red Y.
+ *
+ * @param y Red y
+ */
+ public void setPrimaryChromaticitiesRedY(Rational y) {
+ _primaryChromaticitiesRedY = y;
+ }
+
+ /**
+ * Set 9.1.5 ProcessingActions.
+ *
+ * @param actions Array of strings giving image processing steps
+ */
+ public void setProcessingActions(String[] actions) {
+ _processingActions = actions;
+ }
+
+ /**
+ * Set 9.1.3 ProcessingAgency.
+ *
+ * @param processingAgency Identifier of producing organization
+ */
+ public void setProcessingAgency(String processingAgency) {
+ _processingAgency = processingAgency;
+ }
+
+ /**
+ * Set 9.1.4.1 ProcessingSoftwareName
+ *
+ * @param name Name of the image processing software
+ */
+ public void setProcessingSoftwareName(String name) {
+ _processingSoftwareName = name;
+ }
+
+ /**
+ * Set 9.1.4.2 ProcessingSoftwareVersion
+ *
+ * @param version Version number of the processing software
+ */
+ public void setProcessingSoftwareVersion(String version) {
+ _processingSoftwareVersion = version;
+ }
+
+ /**
+ * Set 6.1.4.1 ICC profile name.
+ *
+ * @param name Profile name
+ */
+ public void setProfileName(String name) {
+ _profileName = name;
+ }
+
+ /**
+ * Set 8.3.5 Profiles.
+ *
+ * @param profiles Color profile filename or URN
+ */
+ public void setProfiles(String profiles) {
+ _profiles = profiles;
+ }
+
+ /**
+ * Set 6.1.4.2 ICC profile URL.
+ *
+ * @param URL Profile URL
+ */
+ public void setProfileURL(String URL) {
+ _profileURL = URL;
+ }
+
+ /**
+ * Set 6.1.4.6 reference black and white.
+ *
+ * @param reference Reference
+ */
+ public void setReferenceBlackWhite(Rational[] reference) {
+ _referenceBlackWhite = reference;
+ }
+
+ /**
+ * Set 6.1.5.3 Rows per strip.
+ *
+ * @param rows Rows per strip
+ */
+ public void setRowsPerStrip(long rows) {
+ _rowsPerStrip = rows;
+ }
+
+ /**
+ * Set 8.1.1 sampling frequency plane.
+ *
+ * @param plane Sampling frequency plane
+ */
+ public void setSamplingFrequencyPlane(int plane) {
+ _samplingFrequencyPlane = plane;
+ }
+
+ /**
+ * Set 8.2.2 samples per pixel.
+ *
+ * @param samples Samples per pixel
+ */
+ public void setSamplesPerPixel(int samples) {
+ _samplesPerPixel = samples;
+ }
+
+ /**
+ * Set 8.1.2 sampling frequency unit.
+ *
+ * @param unit Sampling frequency unit
+ */
+ public void setSamplingFrequencyUnit(int unit) {
+ _samplingFrequencyUnit = unit;
+ }
+
+ /**
+ * Set 7.6.1.1 scanner manufacturer.
+ *
+ * @param manufacturer Scanner manufacturer
+ */
+ public void setScannerManufacturer(String manufacturer) {
+ _scannerManufacturer = manufacturer;
+ }
+
+ /**
+ * Set 7.6.1.2.1 scanner model name.
+ *
+ * @param name Scanner model name
+ */
+ public void setScannerModelName(String name) {
+ _scannerModelName = name;
+ }
+
+ /**
+ * Set 7.6.1.2.2 scanner model number.
+ *
+ * @param number Scanner model number
+ */
+ public void setScannerModelNumber(String number) {
+ _scannerModelNumber = number;
+ }
+
+ /**
+ * Set 7.6.1.2.3 scanner model serial number.
+ *
+ * @param number Scanner model serial number
+ */
+ public void setScannerModelSerialNo(String number) {
+ _scannerModelSerialNo = number;
+ }
+
+ /**
+ * Set 7.6.2.1 scanning software.
+ *
+ * @param software Scanning software
+ */
+ public void setScanningSoftware(String software) {
+ _scanningSoftware = software;
+ }
+
+ /**
+ * Set 7.6.2.2 scanning software version number.
+ *
+ * @param number Scanning software version number
+ */
+ public void setScanningSoftwareVersionNo(String number) {
+ _scanningSoftwareVersionNo = number;
+ }
+
+ /**
+ * Set 7.7.3.7 scene illuminant.
+ *
+ * @param illuminant Scene illuminant
+ */
+ public void setSceneIlluminant(int illuminant) {
+ _sceneIlluminant = illuminant;
+ }
+
+ /**
+ * Set 7.8 sensor.
+ *
+ * @param sensor Sensor
+ */
+ public void setSensor(int sensor) {
+ _sensor = sensor;
+ }
+
+ /**
+ * Set 9.1.2 SourceData.
+ *
+ * @param sourceData Source data identifier
+ */
+ public void setSourceData(String sourceData) {
+ _sourceData = sourceData;
+ }
+
+ /**
+ * Set 7.2 source ID.
+ *
+ * @param id Source ID
+ */
+ public void setSourceID(String id) {
+ _sourceID = id;
+ }
+
+ /**
+ * Set 7.1 source type.
+ *
+ * @param type Source type
+ */
+ public void setSourceType(String type) {
+ _sourceType = type;
+ }
+
+ /**
+ * Set 8.1.7 source X dimension.
+ *
+ * @param x X dimension
+ */
+ public void setSourceXDimension(double x) {
+ _sourceXDimension = x;
+ }
+
+ /**
+ * Set 8.1.7.1 source X dimension unit.
+ *
+ * @param unit X dimension unit
+ */
+ public void setSourceXDimensionUnit(int unit) {
+ _sourceXDimensionUnit = unit;
+ }
+
+ /**
+ * Set 8.1.8 source Y dimension.
+ *
+ * @param y Y dimension
+ */
+ public void setSourceYDimension(double y) {
+ _sourceYDimension = y;
+ }
+
+ /**
+ * Set 8.1.8.1 source Y dimension unit.
+ *
+ * @param unit Y dimension unit
+ */
+ public void setSourceYDimensionUnit(int unit) {
+ _sourceYDimensionUnit = unit;
+ }
+
+ /**
+ * Set 6.1.5.4 Strip byte counts.
+ *
+ * @param counts Byte counts
+ */
+ public void setStripByteCounts(long[] counts) {
+ _stripByteCounts = counts;
+ }
+
+ /**
+ * Set 6.1.5.2 Strip offsets.
+ *
+ * @param offsets Strip offsets
+ */
+ public void setStripOffsets(long[] offsets) {
+ _stripOffsets = offsets;
+ }
+
+ /**
+ * Set 7.7.3.5 Subject distance
+ *
+ * @param distance Subject distance
+ */
+ public void setSubjectDistance(double[] distance) {
+ _subjectDistance = distance;
+ }
+
+ /** Set 8.3.2.1 TargetIDManufacturer */
+ public void setTargetIDManufacturer(String targetIDManufacturer) {
+ _targetIDManufacturer = targetIDManufacturer;
+ }
+
+ /** Set 8.3.2.4 TargetIDMedia */
+ public void setTargetIDMedia(String targetIDMedia) {
+ _targetIDMedia = targetIDMedia;
+ }
+
+ /** Set 8.3.2.2 TargetIDName */
+ public void setTargetIDName(String targetIDName) {
+ _targetIDName = targetIDName;
+ }
+
+ /** Set 8.3.2.3 TargetIDNo */
+ public void setTargetIDNo(String targetIDNo) {
+ _targetIDNo = targetIDNo;
+ }
+
+ /** Set 8.3.1 TargetType */
+ public void setTargetType(int targetType) {
+ _targetType = targetType;
+ }
+
+ /**
+ * Set 6.1.5.8 Tile byte counts.
+ *
+ * @param counts Byte counts
+ */
+ public void setTileByteCounts(long[] counts) {
+ _tileByteCounts = counts;
+ }
+
+ /**
+ * Set 6.1.5.6 Tile length.
+ *
+ * @param length Tile length
+ */
+ public void setTileLength(long length) {
+ _tileLength = length;
+ }
+
+ /**
+ * Set 6.1.5.7 Tile offsets.
+ *
+ * @param offsets tile offsets
+ */
+ public void setTileOffsets(long[] offsets) {
+ _tileOffsets = offsets;
+ }
+
+ /**
+ * Set 6.1.5.5 Tile width.
+ *
+ * @param width Tile width
+ */
+ public void setTileWidth(long width) {
+ _tileWidth = width;
+ }
+
+ /**
+ * Set 8.2.7.1 white point X value.
+ *
+ * @param x White point X
+ */
+ public void setWhitePointXValue(Rational x) {
+ _whitePointXValue = x;
+ }
+
+ /**
+ * Set 8.2.7.2 white point Y value.
+ *
+ * @param y White point Y
+ */
+ public void setWhitePointYValue(Rational y) {
+ _whitePointYValue = y;
+ }
+
+ /**
+ * Set 7.6.3.2.1 X physical scanning resolution.
+ *
+ * @param x X physical scanning resolution
+ */
+ public void setXPhysScanResolution(double x) {
+ _xPhysScanResolution = x;
+ }
+
+ /**
+ * Set 7.7.3.16.1 X print aspect ratio.
+ *
+ * @param x X aspect ratio
+ */
+ public void setXPrintAspectRatio(double x) {
+ _xPrintAspectRatio = x;
+ }
+
+ /**
+ * Set 8.1.3 X sampling frequency.
+ *
+ * @param x X sampling frequency
+ */
+ public void setXSamplingFrequency(Rational x) {
+ _xSamplingFrequency = x;
+ }
+
+ /**
+ * Set 6.2.6.1 X targeted display aspect ratio.
+ *
+ * @param x X units
+ */
+ public void setXTargetedDisplayAspectRatio(long x) {
+ _xTargetedDisplayAR = x;
+ }
+
+ /**
+ * Set 6.1.4.5 YCbCr coefficients.
+ *
+ * @param coefficients Coefficients
+ */
+ public void setYCbCrCoefficients(Rational[] coefficients) {
+ _yCbCrCoefficients = coefficients;
+ }
+
+ /**
+ * Set 6.1.4.4 YCbCr positioning.
+ *
+ * @param positioning Positioning
+ */
+ public void setYCbCrPositioning(int positioning) {
+ _yCbCrPositioning = positioning;
+ }
+
+ /**
+ * Set 6.1.4.3 YCbCr Sub-sampling.
+ *
+ * @param sampling Sub-sampling
+ */
+ public void setYCbCrSubSampling(int[] sampling) {
+ _yCbCrSubSampling = sampling;
+ }
+
+ /**
+ * Set 7.6.3.2.2 Y physical scanning resolution.
+ *
+ * @param y Y physical scanning resolution
+ */
+ public void setYPhysScanResolution(double y) {
+ _yPhysScanResolution = y;
+ }
+
+ /**
+ * Set 7.7.3.16.2 Y print aspect ratio.
+ *
+ * @param y Y aspect ratio
+ */
+ public void setYPrintAspectRatio(double y) {
+ _yPrintAspectRatio = y;
+ }
+
+ /**
+ * Set 8.1.4 Y sampling frequency.
+ *
+ * @param y Y sampling frequency
+ */
+ public void setYSamplingFrequency(Rational y) {
+ _ySamplingFrequency = y;
+ }
+
+ /**
+ * Set 6.2.6.2 Y targeted display aspect ratio.
+ *
+ * @param y Y units
+ */
+ public void setYTargetedDisplayAspectRatio(long y) {
+ _yTargetedDisplayAR = y;
+ }
+
+ /**
+ * Set information for Swing GUI viewer.
+ *
+ * @param viewerData Private data for RepTreeModel
+ */
+ public void setViewerData(Property viewerData) {
+ _viewerData = viewerData;
+ }
+
+ /* Canonicizes (canonizes? whatever) a date to ISO
+ * 8601 format. Returns null if it can't make sense of
+ * it. Returns the date unchanged if it's already
+ * canonical. Initially this converts TIFF dates to ISO.
+ */
+ private String make8601Valid(String date) {
+ try {
+ if (date.charAt(4) == ':') {
+ // It's a TIFF date, or a good imitation of one.
+ // TIFF dates have exact offsets, making things easy.
+ String yr = date.substring(0, 4);
+ String mo = date.substring(5, 7);
+ String da = date.substring(8, 10);
+ String hr = date.substring(11, 13);
+ String mi = date.substring(14, 16);
+ String se = date.substring(17, 19);
+ return yr + "-" + mo + "-" + da + "T" + hr + TIME_SEP + mi + TIME_SEP + se;
+ }
+ return date; // default
+ } catch (Exception e) {
+ // Malformed date
+ return null;
+ }
+ }
+
+ public static String extractIccProfileDescription(byte[] data) throws IllegalArgumentException {
+ // Validate the ICCProfile with the java library
+ ICC_Profile profile = ICC_Profile.getInstance(data);
+ // Extract the 'desc' record (cf http://www.color.org/ICC1-V41.pdf)
+ byte[] dataProf = profile.getData(ICC_Profile.icSigProfileDescriptionTag);
+ if (dataProf == null) {
+ return null;
+ }
+
+ String description = null;
+ ByteBuffer bb = ByteBuffer.wrap(dataProf).asReadOnlyBuffer();
+ int majorVersion = profile.getMajorVersion();
+ int minorVersion = profile.getMinorVersion();
+ LOGGER.fine("Version " + majorVersion + "." + minorVersion);
+
+ int beginTag = bb.getInt(0);
+ if (beginTag == ICC_Profile.icSigProfileDescriptionTag) {
+ // Invariant option
+ // ICC v2 http://www.color.org/ICC_Minor_Revision_for_Web.pdf
+ // Read only the ASCII form (cf 6.5.17 ICC v2)
+ final int OFFSET_LENGTH = 8;
+ final int OFFSET_DESC = OFFSET_LENGTH + 4;
+
+ int lengthAscii = bb.getInt(OFFSET_LENGTH);
+
+ // readString
+ byte[] asciiDesc = new byte[lengthAscii - 1];
+ bb.position(OFFSET_DESC);
+ bb.get(asciiDesc);
+
+ description = new String(asciiDesc, StandardCharsets.US_ASCII);
+ } else {
+ // ICC v4 http://www.color.org/ICC1-V41.pdf
+ final int OFFSET_NUMBER = 8;
+ final int MLUC_TAG = 0x6D6C7563;
+ final int OFFSET_NAME_LENGTH = 20;
+ final int OFFSET_NAME_OFFSET = 24;
+
+ // 6.2 segment tag table definition
+ int tagMluc = bb.getInt(0);
+
+ // Read the 1st mulc form (cf 6.5.12 ICC v4)
+ int nb = bb.getInt(OFFSET_NUMBER);
+ if (tagMluc != MLUC_TAG || nb < 1) {
+ throw new IllegalArgumentException(CoreMessageConstants.ERR_ICC_PRFL_DESC_MISS);
+ }
+ int firstNameLength = bb.getInt(OFFSET_NAME_LENGTH);
+ int firstNameOffset = bb.getInt(OFFSET_NAME_OFFSET);
+ // readString
+ byte[] desc = new byte[firstNameLength];
+ bb.position(firstNameOffset);
+ bb.get(desc);
+
+ // The Unicode strings in storage are encoded as 16-bit
+ // big-endian, UTF-16BE, and should not be NULL terminated.
+ description = new String(desc, StandardCharsets.UTF_16BE);
+ }
+ return description;
+ }
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ObjectIdentifier.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ObjectIdentifier.java
index 9dad6acc8..95cdcdc60 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ObjectIdentifier.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ObjectIdentifier.java
@@ -1,118 +1,105 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003-4 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003-4 by JSTOR and the President and Fellows of Harvard College
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
import java.io.*;
import java.util.*;
/**
- * Module for identification of a document. "Identification"
- * means determining, by querying modules successively, what the format
- * of a document is. The Bytestream module is always queried last,
- * so a document will by identified as a Bytestream if all else fails.
+ * Module for identification of a document. "Identification" means determining, by querying modules
+ * successively, what the format of a document is. The Bytestream module is always queried last, so
+ * a document will by identified as a Bytestream if all else fails.
*/
-public class ObjectIdentifier
-{
- /******************************************************************
- * PRIVATE INSTANCE FIELDS.
- ******************************************************************/
-
- private List Processing methods.
+ *
+ * ****************************************************************
+ */
+ /**
+ * Perform identification on a file. The file is parsed by each of the modules in the module list
+ * until one declares that the file is well-formed. It is assumed that there is a module in the
+ * list (normally Bytestream at the end) which will always consider a file well-formed.
+ */
+ public void identify(File file, RepInfo info, String parm, boolean verbose, boolean shortCheck) {
/**
- * Perform identification on a file. The file is parsed by
- * each of the modules in the module list until one
- * declares that the file is well-formed. It is assumed
- * that there is a module in the list (normally Bytestream
- * at the end) which will always consider a file well-formed.
+ * **************************************************** Go through all modules, in the order in
+ * the config file, calling the parse method till we find one which matches.
+ * ****************************************************
*/
- public void identify (File file, RepInfo info,
- String parm, boolean verbose,
- boolean shortCheck)
- {
- /******************************************************
- * Go through all modules, in the order in the config
- * file, calling the parse method till we find one
- * which matches.
- ******************************************************/
+ ListIterator The components of a Property may themselves be Property objects, allowing nested structures.
*
- * @see PropertyType
- * @see PropertyArity
+ * @see PropertyType
+ * @see PropertyArity
*/
-public class Property
-{
- /******************************************************************
- * PRIVATE INSTANCE FIELDS.
- ******************************************************************/
-
- private String _name;
- private PropertyType _type;
- private PropertyArity _arity;
- private Object _value;
-
-
- /******************************************************************
- * CLASS CONSTRUCTOR.
- ******************************************************************/
-
- /**
- * Creates a Property with arity SCALAR.
- *
- * @param name The displayable name of the property
- * @param type The type of property
- * @param value The value of the property. The type of the
- * parameter must agree with Accessor methods. ****************************************************************
+ */
+
+ /** Returns the arity (type of structure) of this Property. */
+ public PropertyArity getArity() {
+ return _arity;
+ }
+
+ /**
+ * Return a property by its name, regardless of its position in the structural hierarchy of
+ * properties.
+ *
+ * @param name Property name
+ * @return Named property (or null)
+ */
+ public Property getByName(String name) {
+ if (_name.equals(name)) {
+ return this;
}
- /**
- * Returns the displayable name of this Property.
- */
- public String getName ()
- {
- return _name;
+ if (!_arity.equals(PropertyArity.SCALAR) && _type.equals(PropertyType.PROPERTY)) {
+ if (_arity.equals(PropertyArity.ARRAY)) {
+ Property[] array = (Property[]) _value;
+ for (int i = 0; i < array.length; i++) {
+ Property prop = array[i].getByName(name);
+ if (prop != null) {
+ return prop;
+ }
+ }
+ } else if (_arity.equals(PropertyArity.LIST)) {
+ Listfile
, it will not be replaced or overwritten
- * until writeFile
has successfully written out
- * the temporary file.
- *
- * @param file Location of the configuration file
- *
- * @param parent The ConfigWindow which invoked this instance.
- * May be null if invoked to write a default config file.
- */
- public ConfigWriter (File file, ConfigWindow parent) throws IOException
- {
- _confFile = file;
- _parent = parent;
- // Set up a temporary file to write to.
- String path = file.getParent();
- file.getParentFile().mkdirs(); // Make sure the directory exists
- _tempFile = File.createTempFile ("jho", ".conf", new File (path));
- //_tempFile.createNewFile();
- FileOutputStream ostrm = new FileOutputStream (_tempFile);
- OutputStreamWriter osw = new OutputStreamWriter (ostrm, "UTF-8");
- _confOut = new PrintWriter (osw);
+ private PrintWriter _confOut;
+ private File _tempFile;
+ private File _confFile;
+ ConfigWindow _parent;
+
+ private static final String CLASS_TAG_START = " file
, it will not be replaced or
+ * overwritten until writeFile
has successfully written out the temporary file.
+ *
+ * @param file Location of the configuration file
+ * @param parent The ConfigWindow which invoked this instance. May be null if invoked to write a
+ * default config file.
+ */
+ public ConfigWriter(File file, ConfigWindow parent) throws IOException {
+ _confFile = file;
+ _parent = parent;
+ // Set up a temporary file to write to.
+ String path = file.getParent();
+ file.getParentFile().mkdirs(); // Make sure the directory exists
+ _tempFile = File.createTempFile("jho", ".conf", new File(path));
+ // _tempFile.createNewFile();
+ FileOutputStream ostrm = new FileOutputStream(_tempFile);
+ OutputStreamWriter osw = new OutputStreamWriter(ostrm, "UTF-8");
+ _confOut = new PrintWriter(osw);
+ }
+
+ /**
+ * Writes out the content of the file to the temporary file, then deletes the existing
+ * configuration file (as specified by the constructor parameter) and renames the temporary file
+ * to the configuration file.
+ *
+ * selectHandler
to obtain an
- * OutputHandler with which to produce data.
- */
- protected OutputHandler selectHandler ()
- {
- _lastHandler = (String) _handlerBox.getSelectedItem ();
- OutputHandler handler =
- _base.getHandlerMap().get (_lastHandler.toLowerCase ());
- _lastEncoding = (String) _encodingBox.getSelectedItem ();
- handler.setEncoding (_lastEncoding);
- handler.setApp (_app);
- handler.setBase (_base);
- return handler;
- }
-
- /**
- * Handler for the "Close" menu item.
- * Simply hides the window without deleting it.
- */
- protected void closeFromMenu ()
- {
- setVisible (false);
+ return null;
+ }
}
+ return null;
+ }
+
+ /**
+ * Sets up the OutputHandler from the JComboBox and returns it. Subclasses should call
+ * selectHandler
to obtain an OutputHandler with which to produce data.
+ */
+ protected OutputHandler selectHandler() {
+ _lastHandler = (String) _handlerBox.getSelectedItem();
+ OutputHandler handler = _base.getHandlerMap().get(_lastHandler.toLowerCase());
+ _lastEncoding = (String) _encodingBox.getSelectedItem();
+ handler.setEncoding(_lastEncoding);
+ handler.setApp(_app);
+ handler.setBase(_base);
+ return handler;
+ }
+
+ /** Handler for the "Close" menu item. Simply hides the window without deleting it. */
+ protected void closeFromMenu() {
+ setVisible(false);
+ }
}
diff --git a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/JhoveWindow.java b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/JhoveWindow.java
index 3c4a56633..1e70c3789 100644
--- a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/JhoveWindow.java
+++ b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/JhoveWindow.java
@@ -1,25 +1,28 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003-2005 by JSTOR and the President and Fellows of Harvard College
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003-2005 by JSTOR and the President and Fellows of Harvard
+ * College
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- **********************************************************************/
-
+ * true
, requests a display update.
+ */
+ public void setContentLength(long length, boolean update) {
+ _contentLength = length;
+ if (update) {
+ updateDisplay();
}
-
- /**
- * Set the total length to be displayed. If this is set
- * to a positive number, then the display will show
- * "xxxx bytes of yyyy". If it is not set, or is set
- * to a zero or negative number, the display will show
- * "xxxx bytes".
- *
- * @param length The length to display
- * @param update If true
, requests a display update.
- */
- public void setContentLength (long length, boolean update)
- {
- _contentLength = length;
- if (update) {
- updateDisplay ();
- }
+ }
+
+ /**
+ * Set the progress state.
+ *
+ * @param state The state value to assign. Valid values are UNKNOWN, DOWNLOADING, and PROCESSING.
+ * @param update If true
, requests a display update
+ */
+ public void setProgressState(int state, boolean update) {
+ _progressState = state;
+ if (update) {
+ updateDisplay();
}
-
- /** Set the progress state.
- *
- * @param state The state value to assign. Valid values are
- * UNKNOWN, DOWNLOADING, and PROCESSING.
- * @param update If true
, requests a display update
- */
- public void setProgressState (int state, boolean update) {
- _progressState = state;
- if (update) {
- updateDisplay ();
- }
+ }
+
+ /**
+ * Set the name of the document being displayed.
+ *
+ * @param name The file name or URL to display
+ * @param update If true
, requests a display update
+ */
+ public void setDocName(String name, boolean update) {
+ _docName = name;
+ if (update) {
+ updateDisplay();
}
-
-
- /**
- * Set the name of the document being displayed.
- *
- * @param name The file name or URL to display
- * @param update If true
, requests a display update
- */
- public void setDocName (String name, boolean update)
- {
- _docName = name;
- if (update) {
- updateDisplay ();
- }
+ }
+
+ /**
+ * Update the byte count. Setting the count to a negative number blanks the byte count pane.
+ *
+ * @param count The new byte count value
+ * @param update If true
, requests a display update
+ */
+ public void setByteCount(long count, boolean update) {
+ _byteCount = count;
+ if (update) {
+ updateDisplay();
}
-
-
- /**
- * Update the byte count. Setting the count to a negative number blanks
- * the byte count pane.
- *
- * @param count The new byte count value
- * @param update If true
, requests a display update
- */
- public void setByteCount (long count, boolean update)
- {
- _byteCount = count;
- if (update) {
- updateDisplay ();
- }
+ }
+
+ private void updateDisplay() {
+ String progString = "";
+ String txt;
+ switch (_progressState) {
+ case DOWNLOADING:
+ txt = "Downloading " + _docName;
+ break;
+ case PROCESSING:
+ txt = "Processing " + _docName;
+ break;
+ default:
+ txt = _docName;
+ break;
}
-
- private void updateDisplay ()
- {
- String progString = "";
- String txt;
- switch (_progressState) {
- case DOWNLOADING:
- txt = "Downloading " + _docName;
- break;
- case PROCESSING:
- txt = "Processing " + _docName;
- break;
- default:
- txt = _docName;
- break;
- }
- _docNameLabel.setText (txt);
- if (_byteCount >= 0) {
- progString = Long.toString (_byteCount) + " bytes";
- if (_contentLength > 0) {
- progString += " out of " + Long.toString (_contentLength);
- }
- }
- _progressLabel.setText (progString);
- Container content = getContentPane ();
- content.update (content.getGraphics ());
+ _docNameLabel.setText(txt);
+ if (_byteCount >= 0) {
+ progString = Long.toString(_byteCount) + " bytes";
+ if (_contentLength > 0) {
+ progString += " out of " + Long.toString(_contentLength);
+ }
}
+ _progressLabel.setText(progString);
+ Container content = getContentPane();
+ content.update(content.getGraphics());
+ }
}
diff --git a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/RepTreeRoot.java b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/RepTreeRoot.java
index 13cabad83..d9e98645a 100644
--- a/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/RepTreeRoot.java
+++ b/jhove-apps/src/main/java/edu/harvard/hul/ois/jhove/viewer/RepTreeRoot.java
@@ -1,20 +1,10 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003-2005 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003-2005 by JSTOR and the President and Fellows of Harvard
+ * College ********************************************************************
+ */
package edu.harvard.hul.ois.jhove.viewer;
-import java.text.DateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.swing.tree.DefaultMutableTreeNode;
-
import edu.harvard.hul.ois.jhove.AESAudioMetadata;
import edu.harvard.hul.ois.jhove.Checksum;
import edu.harvard.hul.ois.jhove.ErrorMessage;
@@ -29,1490 +19,1374 @@
import edu.harvard.hul.ois.jhove.Rational;
import edu.harvard.hul.ois.jhove.RepInfo;
import edu.harvard.hul.ois.jhove.TextMDMetadata;
+import java.text.DateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.swing.tree.DefaultMutableTreeNode;
/**
- * This subclass of DefaultMutableTreeNode simply adds a method for constructing
- * the tree. All nodes in the tree except for the root will be plain
- * DefaultMutablereeNodes.
+ * This subclass of DefaultMutableTreeNode simply adds a method for constructing the tree. All nodes
+ * in the tree except for the root will be plain DefaultMutablereeNodes.
*/
public class RepTreeRoot extends DefaultMutableTreeNode {
- /**
- * Serialisation identifier
- */
- private static final long serialVersionUID = -4409152022584715925L;
- private RepInfo _info;
- private JhoveBase _base;
- private boolean _rawOutput;
- private DateFormat _dateFmt;
-
- /* Sample rate. */
- private double _sampleRate;
-
- /**
- * Constructor.
- *
- * @param info
- * The RepInfo object whose contents are to be displayed.
- * @param base
- * The JHOVE base on which we're operating.
- */
- public RepTreeRoot(RepInfo info, JhoveBase base) {
- super(info.getUri());
- _info = info;
- _base = base;
- _rawOutput = _base.getShowRawFlag();
-
- // Set the DateFormat for displaying the module date.
- _dateFmt = DateFormat.getDateInstance();
-
- // Snarf everything up into the tree.
-
- snarfRepInfo();
- }
-
- private static final String TEXT_MD_METADTA = "TextMDMetadata";
- private static final String FORMAT = "Format: ";
- private static final String VERSION = "Version: ";
- private static final String BYTE_ORDER = "ByteOrder: ";
- private static final String FRAME_COUNT_30 = "FrameCount: 30";
- private static final String TIME_BASE_1000 = "TimeBase: 1000";
- private static final String VIDEO_FIELD_FIELD_1 = "VideoField: FIELD_1";
- private static final String COUNTING_MODE_NTSC_NON_DROP_FRAME= "CountingMode: NTSC_NON_DROP_FRAME";
- private static final String HOURS = "Hours: ";
- private static final String MINUTES = "Minutes: ";
- private static final String SECONDS = "Seconds: ";
- private static final String FRAMES = "Frames: ";
- private static final String SAMPLES = "Samples";
- private static final String NUMBER_OF_SAMPLES = "NumberOfSamples: ";
- private static final String FILM_FRAMING = "FilmFraming";
- private static final String FRAMING_NOT_APPLICABLE = "Framing: NOT_APPLICABLE";
- private static final String NTSC_FILM_FRAMING_TYPE = "Type: ntscFilmFramingType";
-
-
-
- /**
- * Constructs a DefaultMutableTreeNode representing a property
- */
- private DefaultMutableTreeNode propToNode(Property pProp) {
- PropertyArity arity = pProp.getArity();
- PropertyType typ = pProp.getType();
- Object pValue = pProp.getValue();
- if (arity == PropertyArity.SCALAR) {
- if (null == typ) {
- // Simple types: just use name plus string value.
- DefaultMutableTreeNode val = new DefaultMutableTreeNode(
- pProp.getName() + ": " + pValue.toString());
- return val;
- } else {
- TextMDMetadata tData;
- DefaultMutableTreeNode val;
- switch (typ) {
- case NISOIMAGEMETADATA:
- // NISO Image metadata is a world of its own.
- NisoImageMetadata nData = (NisoImageMetadata) pValue;
- return nisoToNode(nData);
- case AESAUDIOMETADATA:
- // AES audio metadata is another world.
- AESAudioMetadata aData = (AESAudioMetadata) pValue;
- return aesToNode(aData);
- case TEXTMDMETADATA:
- // textMD metadata is another world.
- tData = (TextMDMetadata) pValue;
- return textMDToNode(tData);
- case PROPERTY:
-
- if (TEXT_MD_METADTA.equals(pProp.getName())) {
- tData = (TextMDMetadata) pValue;
- return textMDToNode(tData);
- }
- // A scalar property of type Property -- seems
- // pointless, but we handle it.
- val = new DefaultMutableTreeNode(pProp.getName());
- val.add(propToNode((Property) pValue));
- return val;
-
- default:
-
- // Simple types: just use name plus string value.
- val = new DefaultMutableTreeNode(pProp.getName() + ": "
- + pValue.toString());
- return val;
-
- }
- }
- }
- // Compound properties. The text of the node is the
- // property name.
- DefaultMutableTreeNode val = new DefaultMutableTreeNode(pProp.getName());
- if (null != arity)
- switch (arity) {
- case ARRAY:
- addArrayMembers(val, pProp);
- break;
- case LIST:
- addListMembers(val, pProp);
- break;
- case MAP:
- addMapMembers(val, pProp);
- break;
- case SET:
- addSetMembers(val, pProp);
- break;
- default:
- break;
- }
- return val;
- }
-
- /**
- * Find the index of an object in its parent. Understands the Jhove property
- * structure.
- */
- public int getIndexOfChild(Object parent, Object child) {
- Property pProp = (Property) parent;
- PropertyArity arity = pProp.getArity();
- // For Lists, Maps, and Sets we construct an Iterator.
- Iterator> iter = null;
- if (arity == PropertyArity.SET || arity == PropertyArity.LIST
- || arity == PropertyArity.MAP) {
- if (null == arity) {
- List> list = (List>) pProp.getValue();
- iter = list.iterator();
- } else
- switch (arity) {
- case SET:
- Set> set = (Set>) pProp.getValue();
- iter = set.iterator();
- break;
- case MAP:
- Map, ?> map = (Map, ?>) pProp.getValue();
- iter = map.values().iterator();
- break;
- default:
- List> list = (List>) pProp.getValue();
- iter = list.iterator();
- break;
- }
- for (int i = 0;; i++) {
- if (!iter.hasNext()) {
- return 0; // Should never happen
- } else if (iter.next() == child) {
- return i;
- }
- }
- }
- // OK, that was the easy one. Now for that damn array arity.
- // In the case of non-object types, we can't actually tell which
- // position matches the object, so we return 0 and hope it doesn't
- // mess things up too much.
- PropertyType propType = pProp.getType();
- java.util.Date[] dateArray = null;
- Property[] propArray = null;
- Rational[] rationalArray = null;
- Object[] objArray = null;
- int n = 0;
-
- if (null == propType) {
- return 0; // non-object array type
- } else
- // if (child instanceof LeafHolder) {
- // return ((LeafHolder) child).getPosition ();
- // }
- // else
- switch (propType) {
- case DATE:
- dateArray = (java.util.Date[]) pProp.getValue();
- n = dateArray.length;
- break;
- case OBJECT:
- objArray = (Object[]) pProp.getValue();
- n = objArray.length;
- break;
- case RATIONAL:
- rationalArray = (Rational[]) pProp.getValue();
- n = rationalArray.length;
- break;
- case PROPERTY:
- propArray = (Property[]) pProp.getValue();
- n = propArray.length;
- break;
- default:
- return 0; // non-object array type
- }
-
- for (int i = 0; i < n; i++) {
- Object elem = null;
- switch (propType) {
- case DATE:
- elem = dateArray[i];
- break;
- case OBJECT:
- elem = objArray[i];
- break;
- case RATIONAL:
- elem = rationalArray[i];
- break;
- case PROPERTY:
- elem = propArray[i];
- break;
- default:
- break;
- }
- if (elem == child) {
- return i;
- }
- }
- return 0; // somehow fell through
- }
-
- private void snarfRepInfo() {
- // This node has two children, for the module and the RepInfo
-
- Module module = _info.getModule();
- if (module != null) {
- // Create a subnode for the module, which has three
- // leaf children.
- DefaultMutableTreeNode moduleNode = new DefaultMutableTreeNode(
- "Module");
- moduleNode.add(new DefaultMutableTreeNode(module.getName(), false));
- moduleNode.add(new DefaultMutableTreeNode("Release: "
- + module.getRelease(), false));
- moduleNode.add(new DefaultMutableTreeNode("Date: "
- + _dateFmt.format(module.getDate()), false));
- add(moduleNode);
- }
-
- DefaultMutableTreeNode infoNode = new DefaultMutableTreeNode("RepInfo");
- infoNode.add(new DefaultMutableTreeNode("URI: " + _info.getUri(), false));
- Date dt = _info.getCreated();
- if (dt != null) {
- infoNode.add(new DefaultMutableTreeNode(
- "Created: " + dt.toString(), false));
- }
- dt = _info.getLastModified();
- if (dt != null) {
- infoNode.add(new DefaultMutableTreeNode("LastModified: "
- + dt.toString(), false));
- }
- long sz = _info.getSize();
- if (sz != -1) {
- infoNode.add(new DefaultMutableTreeNode("Size: "
- + Long.toString(sz), false));
- }
- String s = _info.getFormat();
- if (s != null) {
- infoNode.add(new DefaultMutableTreeNode(FORMAT + s, false));
- }
- s = _info.getVersion();
- if (s != null) {
- infoNode.add(new DefaultMutableTreeNode(VERSION + s, false));
- }
- String wfStr;
- switch (_info.getWellFormed()) {
- case RepInfo.TRUE:
- wfStr = "Well-Formed";
- break;
- case RepInfo.FALSE:
- wfStr = "Not well-formed";
- break;
- default:
- wfStr = "Unknown";
- break;
- }
- if (_info.getWellFormed() == RepInfo.TRUE) {
- switch (_info.getValid()) {
- case RepInfo.TRUE:
- wfStr += " and valid";
- break;
-
- case RepInfo.FALSE:
- wfStr += ", but not valid";
- break;
-
- // case UNDETERMINED: add nothing
- }
- }
- infoNode.add(new DefaultMutableTreeNode("Status: " + wfStr, false));
-
- // Report modules that said their signatures match
- ListNisoImageMetadata
object. */
+ public AESAudioMetadata() {
+ _schemaVersion = SCHEMA_VERSION;
+ _disposition = DEFAULT_DISPOSITION;
+ _analogDigitalFlag = null;
+ _format = null;
+ _specificationVersion = null;
+ _audioDataEncoding = null;
+ _primaryIdentifier = null;
+ _primaryIdentifierType = null;
+ _use = null;
+
+ // We add one format region to get started. In practice,
+ // that one is all we're likely to need. but more can be
+ // added if necessary.
+ _formatList = new LinkedList<>();
+ _faceList = new LinkedList<>();
+ addFormatRegion();
+ addFace();
+ _numChannels = NULL;
+ _byteOrder = NULL;
+ _firstSampleOffset = NULL;
+ }
+
+ /**
+ * **************************************************************** PUBLIC STATIC INTERFACES.
+ *
+ * NisoImageMetadata
object.
+ *
+ *
*/
- public AESAudioMetadata ()
- {
- _schemaVersion = SCHEMA_VERSION;
- _disposition = DEFAULT_DISPOSITION;
- _analogDigitalFlag = null;
- _format = null;
- _specificationVersion = null;
- _audioDataEncoding = null;
- _primaryIdentifier = null;
- _primaryIdentifierType = null;
- _use = null;
-
- // We add one format region to get started. In practice,
- // that one is all we're likely to need. but more can be
- // added if necessary.
- _formatList = new LinkedList<> ();
- _faceList = new LinkedList<> ();
- addFormatRegion ();
- addFace ();
- _numChannels = NULL;
- _byteOrder = NULL;
- _firstSampleOffset = NULL;
- }
-
- /******************************************************************
- * PUBLIC STATIC INTERFACES.
- *
- ******************************************************************/
+ public String[] getBitrateReduction();
+ /** Returns the sample rate. */
+ public double getSampleRate();
+ /** Returns the word size. */
+ int getWordSize();
+ /** Returns true
if the region is empty. */
+ public boolean isEmpty();
+ /** Sets the bit depth value. */
+ public void setBitDepth(int bitDepth);
+ /** Sets the bitrate reduction information to null (no compression). */
+ public void clearBitrateReduction();
+ /** Sets the bitrate reduction (aka compression type). */
+ public void setBitrateReduction(
+ String codecName,
+ String codecNameVersion,
+ String codecCreatorApplication,
+ String codecCreatorApplicationVersion,
+ String codecQuality,
+ String dataRate,
+ String dataRateMode);
+ /** Sets the sample rate. */
+ public void setSampleRate(double sampleRate);
+ /** Sets the word size. */
+ public void setWordSize(int wordSize);
+ }
+
+ /**
+ * Public interface to the nested TimeDesc object. Instances of this should be created only by
+ * appropriate methods, but can be accessed through the public methods of this interface.
+ */
+ public static interface TimeDesc {
+ /** Returns the hours component. */
+ public long getHours();
+ /** Returns the minutes component. */
+ public long getMinutes();
+ /** Returns the seconds component. */
+ public long getSeconds();
/**
- * Public interface to the nested FormatRegion object. Instances
- * of this should be created only by addFormatRegion, but can be
- * accessed through the public methods of this interface.
+ * Returns the frames component of the fraction of a second. We always consider frames to be
+ * thirtieths of a second.
*/
- public static interface FormatRegion {
- /** Returns the bit depth. */
- public int getBitDepth ();
- /** Returns the bitrate reduction (compression information).
- * This will be an array of seven strings (which may be
- * empty, but should never be null) interpreted as follows:
- *
- *
- */
- public String[] getBitrateReduction ();
- /** Returns the sample rate. */
- public double getSampleRate ();
- /** Returns the word size. */
- int getWordSize ();
- /** Returns true
if the region is empty. */
- public boolean isEmpty ();
- /** Sets the bit depth value. */
- public void setBitDepth (int bitDepth);
- /** Sets the bitrate reduction information to null (no compression). */
- public void clearBitrateReduction ();
- /** Sets the bitrate reduction (aka compression type). */
- public void setBitrateReduction (String codecName,
- String codecNameVersion,
- String codecCreatorApplication,
- String codecCreatorApplicationVersion,
- String codecQuality,
- String dataRate,
- String dataRateMode);
- /** Sets the sample rate. */
- public void setSampleRate (double sampleRate);
- /** Sets the word size. */
- public void setWordSize (int wordSize);
- }
+ public long getFrames();
+ /** Returns the samples remaining after the frames part of the fractional second. */
+ public long getSamples();
+ /** Returns the sample rate on which the samples remainder is based. */
+ public double getSampleRate();
+ }
+
+ /**
+ * Public interface to the nested Face object. Instances of this should be created only by
+ * appropriate methods, but can be accessed through the public methods of this interface.
+ */
+ public static interface Face {
+ /** Returns an indexed FaceRegion. */
+ public FaceRegion getFaceRegion(int i);
+
+ /** Adds a FaceRegion. This may be called repeatedly to add multiple FaceRegions. */
+ public void addFaceRegion();
+
+ /** Returns the starting time. */
+ public TimeDesc getStartTime();
+
+ /** Returns the duration. */
+ public TimeDesc getDuration();
+
+ /** Returns the direction. */
+ public String getDirection();
+
+ /** Sets the starting time. This will be converted into a TimeDesc. */
+ public void setStartTime(long samples);
+
+ /** Sets the duration. This will be converted into a TimeDesc. */
+ public void setDuration(long samples);
/**
- * Public interface to the nested TimeDesc object. Instances
- * of this should be created only by appropriate methods, but can be
- * accessed through the public methods of this interface.
- */
- public static interface TimeDesc {
- /** Returns the hours component. */
- public long getHours ();
- /** Returns the minutes component. */
- public long getMinutes ();
- /** Returns the seconds component. */
- public long getSeconds ();
- /** Returns the frames component of the fraction of a second.
- * We always consider frames to be thirtieths of a second. */
- public long getFrames ();
- /** Returns the samples remaining after the frames part of
- * the fractional second. */
- public long getSamples ();
- /** Returns the sample rate on which the samples remainder
- * is based. */
- public double getSampleRate ();
- }
-
- /** Public interface to the nested Face object. Instances
- * of this should be created only by appropriate methods, but can be
- * accessed through the public methods of this interface. */
- public static interface Face {
- /** Returns an indexed FaceRegion. */
- public FaceRegion getFaceRegion (int i);
-
- /** Adds a FaceRegion. This may be called repeatedly to
- * add multiple FaceRegions. */
- public void addFaceRegion ();
-
- /** Returns the starting time. */
- public TimeDesc getStartTime ();
-
- /** Returns the duration. */
- public TimeDesc getDuration ();
-
- /** Returns the direction. */
- public String getDirection ();
-
- /** Sets the starting time. This will be converted
- * into a TimeDesc. */
- public void setStartTime (long samples);
-
- /** Sets the duration. This will be converted
- * into a TimeDesc. */
- public void setDuration (long samples);
-
- /** Sets the direction. This must be one of the
- * directionTypes. FORWARD is recommended for most
- * or all cases.
- */
- public void setDirection (String direction);
-
- /* End of interface Face */
- }
-
- /** Public interface to the nested FaceRegion object. Instances
- * of this should be created only by appropriate methods, but can be
- * accessed through the public methods of this interface. */
- public static interface FaceRegion {
- /** Returns the starting time. */
- public TimeDesc getStartTime ();
-
- /** Returns the duration. */
- public TimeDesc getDuration ();
-
- /** Returns the channel map locations. The array length must
- * equal the number of channels. */
- public String[] getMapLocations ();
-
- /** Sets the starting time. */
- public void setStartTime (long samples);
-
- /** Sets the duration. */
- public void setDuration (long samples);
-
- /** Sets the channel map locations. The array length must
- * equal the number of channels. */
- public void setMapLocations (String[] locations);
-
- /* End of interface FaceRegion */
- }
-
- /******************************************************************
- * STATIC MEMBER CLASSES.
- *
- ******************************************************************/
- /** The implementation of the FormatRegion interface. The combination
- * of a public interface and a private implementation is suggested
- * in _Java in a Nutshell_.
- */
- class FormatRegionImpl implements FormatRegion {
-
- private int _bitDepth;
- private double _sampleRate;
- private int _wordSize;
- private String[] _bitrateReduction;
-
- public FormatRegionImpl () {
- _bitDepth = NULL;
- _sampleRate = NILL;
- _wordSize = NULL;
- _bitrateReduction = null;
- }
-
- /** Returns bit depth. */
- @Override
- public int getBitDepth ()
- {
- return _bitDepth;
- }
-
- /** Returns the bitrate reduction (compression information).
- * This will be an array of seven strings (which may be
- * empty but not null) interpreted respectively as follows:
- *
- *
- */
- @Override
- public String[] getBitrateReduction ()
- {
- return _bitrateReduction;
- }
-
- /** Returns sample rate. */
- @Override
- public double getSampleRate ()
- {
- return _sampleRate;
- }
-
- /** Returns word size. */
- @Override
- public int getWordSize ()
- {
- return _wordSize;
- }
-
- /** Returns true if the FormatRegion contains only
- * default values. */
- @Override
- public boolean isEmpty ()
- {
- return _bitDepth == NULL &&
- _sampleRate == NILL &&
- _wordSize == NULL;
- }
-
- /** Sets bit depth. */
- @Override
- public void setBitDepth (int bitDepth)
- {
- _bitDepth = bitDepth;
- }
-
- /** Sets the bitrate reduction information to null (no compression). */
- @Override
- public void clearBitrateReduction ()
- {
- _bitrateReduction = null;
- }
-
- /** Sets the bitrate reduction (compression type). */
- @Override
- public void setBitrateReduction (String codecName,
- String codecNameVersion,
- String codecCreatorApplication,
- String codecCreatorApplicationVersion,
- String codecQuality,
- String dataRate,
- String dataRateMode)
- {
- _bitrateReduction = new String[7];
- _bitrateReduction[0] = codecName;
- _bitrateReduction[1] = codecNameVersion;
- _bitrateReduction[2] = codecCreatorApplication;
- _bitrateReduction[3] = codecCreatorApplicationVersion;
- _bitrateReduction[4] = codecQuality;
- _bitrateReduction[5] = dataRate;
- _bitrateReduction[6] = dataRateMode;
- }
-
- /** Sets sample rate. */
- @Override
- public void setSampleRate (double sampleRate)
- {
- _sampleRate = sampleRate;
- }
-
-
- /** Sets word size. */
- @Override
- public void setWordSize (int wordSize)
- {
- _wordSize = wordSize;
- }
-
- /* End of FormatRegionImpl */
- }
-
- /** The implementation of the TimeDesc interface. The combination
- * of a public interface and a private implementation is suggested
- * in _Java in a Nutshell_.
- */
- class TimeDescImpl implements TimeDesc
- {
- private long _hours;
- private long _minutes;
- private long _seconds;
- private long _frames;
- private long _samples;
- private double _sampleRate;
- private long _frameCount;
-
- /* Constructor rewritten to avoid rounding errors when converting to
- * TCF. Now uses integer remainder math instead of floating point.
- * Changed the base unit from a double representing seconds to a long
- * representing samples. Changed all existing calls (that I could find)
- * to this method to accomodate this change.
- *
- * @author David Ackerman
- */
- public TimeDescImpl (long samples)
- {
- long _sample_count = samples;
- _frameCount = 30;
- _sampleRate = _curFormatRegion.getSampleRate ();
-
- /* It seems that this method is initially called before a valid
- * sample rate has been established, causing a divide by zero
- * error.
- */
- if (_sampleRate < 0) {
- _sampleRate = 44100.0; //reasonable default value
- }
-
- long sample_in_1_frame = (long)(_sampleRate/_frameCount);
- long sample_in_1_second = sample_in_1_frame * _frameCount;
- long sample_in_1_minute = sample_in_1_frame * _frameCount * 60;
- long sample_in_1_hour = sample_in_1_frame * _frameCount * 60 * 60;
- long sample_in_1_day = sample_in_1_frame * _frameCount * 60 * 60 * 24;
-
- // BWF allows for a negative timestamp but tcf does not, so adjust
- // time accordingly
- // this might be a good place to report a warning during validation
- if (_sample_count < 0) {
- _sample_count += sample_in_1_day;
- _sample_count = (_sample_count % sample_in_1_day);
- }
-
- _hours = _sample_count / sample_in_1_hour;
- _sample_count -= _hours * sample_in_1_hour;
- _minutes = _sample_count / sample_in_1_minute;
- _sample_count -= _minutes * sample_in_1_minute;
- _seconds = _sample_count / sample_in_1_second;
- _sample_count -= _seconds * sample_in_1_second;
- _frames = _sample_count / sample_in_1_frame;
- _sample_count -= _frames * sample_in_1_frame;
- _samples = _sample_count;
-
- /* At present TCF does not have the ability to handle time stamps
- * > midnight. Industry practice is to roll the clock forward to
- * zero or back to 23:59:59:29... when crossing this boundary
- * condition.
- */
- _hours = _hours % 24;
- }
-
- /** Returns the hours component. */
- @Override
- public long getHours () {
- return _hours;
- }
-
- /** Returns the minutes component. */
- @Override
- public long getMinutes () {
- return _minutes;
- }
-
- /** Returns the seconds component. */
- @Override
- public long getSeconds () {
- return _seconds;
- }
-
- /** Returns the frames component of the fraction of a second.
- * We always consider frames to be thirtieths of a second. */
- @Override
- public long getFrames () {
- return _frames;
- }
-
- /** Returns the samples remaining after the frames part of
- * the fractional second. */
- @Override
- public long getSamples () {
- return _samples;
- }
-
- /** Returns the sample rate on which the samples remainder
- * is based. */
- @Override
- public double getSampleRate () {
- return _sampleRate;
- }
- } /* End of TimeDescImpl */
-
- /** The implementation of the Face interface. The combination
- * of a public interface and a private implementation is suggested
- * in _Java in a Nutshell_.
+ * Sets the direction. This must be one of the directionTypes. FORWARD is recommended for most
+ * or all cases.
*/
- class FaceImpl implements Face {
- private List
- *
- */
- public String[] getBitrateReduction ()
- {
- return _curFormatRegion.getBitrateReduction();
- }
-
- /* Returns the sample rate. */
- public double getSampleRate ()
- {
- return _curFormatRegion.getSampleRate ();
- }
-
- /** Return the byte order: 0 = big-endian; 1 = little-endian. */
- public int getByteOrder ()
- {
- return _byteOrder;
- }
-
- /** Returns disposition. */
- public String getDisposition ()
- {
- return _disposition;
- }
-
- /** Gets the list of Faces. Normally there will be only one face
- * in a digital file. */
- public List
+ *
+ */
+ @Override
+ public String[] getBitrateReduction() {
+ return _bitrateReduction;
}
-
- /** Returns specification version of the document format. */
- public String getSpecificationVersion ()
- {
- return _specificationVersion;
+
+ /** Returns sample rate. */
+ @Override
+ public double getSampleRate() {
+ return _sampleRate;
}
-
- /** Returns the use (role of the document).
- * The value returned is an array of two strings,
- * the useType and the otherType. */
- public String[] getUse ()
- {
- return _use;
+
+ /** Returns word size. */
+ @Override
+ public int getWordSize() {
+ return _wordSize;
}
-
-
+ /** Returns true if the FormatRegion contains only default values. */
+ @Override
+ public boolean isEmpty() {
+ return _bitDepth == NULL && _sampleRate == NILL && _wordSize == NULL;
+ }
+ /** Sets bit depth. */
+ @Override
+ public void setBitDepth(int bitDepth) {
+ _bitDepth = bitDepth;
+ }
- /******************************************************************
- * Mutator methods.
- ******************************************************************/
-
- /** Sets the analog/digital flag. The value set should always
- * be "FILE_DIGITAL". */
- public void setAnalogDigitalFlag (String flagType)
- {
- _analogDigitalFlag = flagType;
+ /** Sets the bitrate reduction information to null (no compression). */
+ @Override
+ public void clearBitrateReduction() {
+ _bitrateReduction = null;
}
/** Sets the bitrate reduction (compression type). */
- public void setBitrateReduction (String codecName,
- String codecNameVersion,
- String codecCreatorApplication,
- String codecCreatorApplicationVersion,
- String codecQuality,
- String dataRate,
- String dataRateMode)
- {
- _curFormatRegion.setBitrateReduction (codecName,
- codecNameVersion, codecCreatorApplication,
- codecCreatorApplicationVersion,
- codecQuality, dataRate, dataRateMode);
- }
-
- /** Set the bitrate reduction information to null (no compression). */
- public void clearBitrateReduction ()
- {
- _curFormatRegion.clearBitrateReduction ();
- }
-
- /** Sets the byte order.
- * @param order Byte order: 0 = big-endian, 1 = little-endian
+ @Override
+ public void setBitrateReduction(
+ String codecName,
+ String codecNameVersion,
+ String codecCreatorApplication,
+ String codecCreatorApplicationVersion,
+ String codecQuality,
+ String dataRate,
+ String dataRateMode) {
+ _bitrateReduction = new String[7];
+ _bitrateReduction[0] = codecName;
+ _bitrateReduction[1] = codecNameVersion;
+ _bitrateReduction[2] = codecCreatorApplication;
+ _bitrateReduction[3] = codecCreatorApplicationVersion;
+ _bitrateReduction[4] = codecQuality;
+ _bitrateReduction[5] = dataRate;
+ _bitrateReduction[6] = dataRateMode;
+ }
+
+ /** Sets sample rate. */
+ @Override
+ public void setSampleRate(double sampleRate) {
+ _sampleRate = sampleRate;
+ }
+
+ /** Sets word size. */
+ @Override
+ public void setWordSize(int wordSize) {
+ _wordSize = wordSize;
+ }
+
+ /* End of FormatRegionImpl */
+ }
+
+ /**
+ * The implementation of the TimeDesc interface. The combination of a public interface and a
+ * private implementation is suggested in _Java in a Nutshell_.
+ */
+ class TimeDescImpl implements TimeDesc {
+ private long _hours;
+ private long _minutes;
+ private long _seconds;
+ private long _frames;
+ private long _samples;
+ private double _sampleRate;
+ private long _frameCount;
+
+ /* Constructor rewritten to avoid rounding errors when converting to
+ * TCF. Now uses integer remainder math instead of floating point.
+ * Changed the base unit from a double representing seconds to a long
+ * representing samples. Changed all existing calls (that I could find)
+ * to this method to accomodate this change.
+ *
+ * @author David Ackerman
*/
- public void setByteOrder (int order)
- {
- _byteOrder = order;
+ public TimeDescImpl(long samples) {
+ long _sample_count = samples;
+ _frameCount = 30;
+ _sampleRate = _curFormatRegion.getSampleRate();
+
+ /* It seems that this method is initially called before a valid
+ * sample rate has been established, causing a divide by zero
+ * error.
+ */
+ if (_sampleRate < 0) {
+ _sampleRate = 44100.0; // reasonable default value
+ }
+
+ long sample_in_1_frame = (long) (_sampleRate / _frameCount);
+ long sample_in_1_second = sample_in_1_frame * _frameCount;
+ long sample_in_1_minute = sample_in_1_frame * _frameCount * 60;
+ long sample_in_1_hour = sample_in_1_frame * _frameCount * 60 * 60;
+ long sample_in_1_day = sample_in_1_frame * _frameCount * 60 * 60 * 24;
+
+ // BWF allows for a negative timestamp but tcf does not, so adjust
+ // time accordingly
+ // this might be a good place to report a warning during validation
+ if (_sample_count < 0) {
+ _sample_count += sample_in_1_day;
+ _sample_count = (_sample_count % sample_in_1_day);
+ }
+
+ _hours = _sample_count / sample_in_1_hour;
+ _sample_count -= _hours * sample_in_1_hour;
+ _minutes = _sample_count / sample_in_1_minute;
+ _sample_count -= _minutes * sample_in_1_minute;
+ _seconds = _sample_count / sample_in_1_second;
+ _sample_count -= _seconds * sample_in_1_second;
+ _frames = _sample_count / sample_in_1_frame;
+ _sample_count -= _frames * sample_in_1_frame;
+ _samples = _sample_count;
+
+ /* At present TCF does not have the ability to handle time stamps
+ * > midnight. Industry practice is to roll the clock forward to
+ * zero or back to 23:59:59:29... when crossing this boundary
+ * condition.
+ */
+ _hours = _hours % 24;
+ }
+
+ /** Returns the hours component. */
+ @Override
+ public long getHours() {
+ return _hours;
+ }
+
+ /** Returns the minutes component. */
+ @Override
+ public long getMinutes() {
+ return _minutes;
+ }
+
+ /** Returns the seconds component. */
+ @Override
+ public long getSeconds() {
+ return _seconds;
}
- /** Sets the byte order.
- */
- public void setByteOrder (String order)
- {
- if (order.substring (0, 3).toLowerCase ().equals ("big")) {
- _byteOrder = BIG_ENDIAN;
- }
- else if (order.substring (0, 6).toLowerCase ().equals ("little")) {
- _byteOrder = LITTLE_ENDIAN;
- }
- }
-
- /** Sets the audio data encoding. */
- public void setAudioDataEncoding (String audioDataEncoding)
- {
- _audioDataEncoding = audioDataEncoding;
- }
-
- /** Set the application-specific data. For present purposes,
- * we assume this is representable as a text string. */
- public void setAppSpecificData (String data)
- {
- _appSpecificData = data;
- }
-
- /** Sets the bit depth. */
- public void setBitDepth (int bitDepth)
- {
- _curFormatRegion.setBitDepth (bitDepth);
- }
-
- /** Sets the disposition. */
- public void setDisposition (String disposition)
- {
- _disposition = disposition;
- }
-
- /** Sets the direction.
- * This must be one of the values
- * FORWARD, REVERSE, A_WIND, B_WIND, C_WIND, D_WIND,
- * FRONT, BACK. FORWARD may be the only one that
- * makes sense for digital formats.
+ /**
+ * Returns the frames component of the fraction of a second. We always consider frames to be
+ * thirtieths of a second.
*/
- public void setDirection (String direction)
- {
- _curFace.setDirection (direction);
+ @Override
+ public long getFrames() {
+ return _frames;
}
-
- /** Sets the duration in samples.
- * This affects the current face and its first FaceRegion.
- */
- public void setDuration (long duration)
- {
- _curFace.setDuration (duration);
- _curFace.getFaceRegion(0).setDuration (duration);
+
+ /** Returns the samples remaining after the frames part of the fractional second. */
+ @Override
+ public long getSamples() {
+ return _samples;
}
- /** Sets the offset of the first byte of sample data. */
- public void setFirstSampleOffset (long offset)
- {
- _firstSampleOffset = offset;
+ /** Returns the sample rate on which the samples remainder is based. */
+ @Override
+ public double getSampleRate() {
+ return _sampleRate;
}
+ } /* End of TimeDescImpl */
- /** Sets the format name. */
- public void setFormat (String format)
- {
- _format = format;
+ /**
+ * The implementation of the Face interface. The combination of a public interface and a private
+ * implementation is suggested in _Java in a Nutshell_.
+ */
+ class FaceImpl implements Face {
+ private List
+ *
+ */
+ public String[] getBitrateReduction() {
+ return _curFormatRegion.getBitrateReduction();
+ }
+
+ /* Returns the sample rate. */
+ public double getSampleRate() {
+ return _curFormatRegion.getSampleRate();
+ }
+
+ /** Return the byte order: 0 = big-endian; 1 = little-endian. */
+ public int getByteOrder() {
+ return _byteOrder;
+ }
+
+ /** Returns disposition. */
+ public String getDisposition() {
+ return _disposition;
+ }
+
+ /** Gets the list of Faces. Normally there will be only one face in a digital file. */
+ public Listdate[0]
is the year,
- * date[1]
the month, and date[2]
the
- * day.
- * @param usage
- * String summarizing command line usage, to output when app name
- * is typed with no arguments or flags.
- * @param rights
- * Copyright or other rights statement.
- */
- public App(String name, String release, int[] date, String usage,
- String rights) {
- Calendar calendar = new GregorianCalendar();
- calendar.set(date[0], date[1] - 1, date[2]);
-
- _name = name;
- _release = release;
- _date = calendar.getTime();
- _usage = usage;
- _rights = rights;
- }
-
- private App(final String name, final ReleaseDetails details) {
- _name = name;
- _release = details.getVersion();
- _date = details.getBuildDate();
- _usage = USAGE;
- _rights = details.getRights();
- }
-
- public static App newAppWithName(final String name) {
- return new App(name, ReleaseDetails.getInstance());
- }
-
- /******************************************************************
- * PUBLIC INSTANCE METHODS.
- *
- * Accessor methods.
- ******************************************************************/
-
- /**
- * Returns application code creation date
- */
- public Date getDate() {
- return _date;
- }
-
- /**
- * Returns the name of this application
- */
- public String getName() {
- return _name;
- }
-
- /**
- * Returns the release identifier for this application.
- */
- public String getRelease() {
- return _release;
- }
-
- /**
- * Returns the rights string.
- */
- public String getRights() {
- return _rights;
- }
-
- /**
- * Returns the usage string, which should be output when the user enters a
- * command line with only the application name.
- */
- public String getUsage() {
- return _usage;
- }
-
- /******************************************************************
- * Serialization methods.
- ******************************************************************/
-
- /**
- * Outputs detailed information about the application, including
- * configuration, available modules and handlers, etc.
- */
- public void show(OutputHandler handler) {
- handler.show(this);
- }
+ private static final String NAME = "JHOVE";
+
+ /** Application invocation syntax. */
+ private static final String USAGE =
+ "java "
+ + NAME
+ + " [-c config] "
+ + "[-m module] [-h handler] [-e encoding] [-H handler] [-o output] "
+ + "[-x saxclass] [-t tempdir] [-b bufsize] [-l loglevel] [[-krs] "
+ + "dir-file-or-uri [...]]";
+
+ /**
+ * **************************************************************** PRIVATE INSTANCE FIELDS.
+ * ****************************************************************
+ */
+
+ /** Application build date. */
+ private final Date _date;
+
+ /** Application name. */
+ private final String _name;
+
+ /** Application release identifier. */
+ private String _release;
+
+ /** Application rights statement. */
+ private final String _rights;
+
+ /** Application invocation syntax. */
+ private final String _usage;
+
+ /**
+ * **************************************************************** CLASS CONSTRUCTOR.
+ * ****************************************************************
+ */
+
+ /**
+ * Creates an App object.
+ *
+ * @param name Name of the application.
+ * @param release Release identifier.
+ * @param date Last modification date of the application code, in the form of an array of three
+ * numbers. date[0]
is the year, date[1]
the month, and
+ * date[2]
the day.
+ * @param usage String summarizing command line usage, to output when app name is typed with no
+ * arguments or flags.
+ * @param rights Copyright or other rights statement.
+ */
+ public App(String name, String release, int[] date, String usage, String rights) {
+ Calendar calendar = new GregorianCalendar();
+ calendar.set(date[0], date[1] - 1, date[2]);
+
+ _name = name;
+ _release = release;
+ _date = calendar.getTime();
+ _usage = usage;
+ _rights = rights;
+ }
+
+ private App(final String name, final ReleaseDetails details) {
+ _name = name;
+ _release = details.getVersion();
+ _date = details.getBuildDate();
+ _usage = USAGE;
+ _rights = details.getRights();
+ }
+
+ public static App newAppWithName(final String name) {
+ return new App(name, ReleaseDetails.getInstance());
+ }
+
+ /**
+ * **************************************************************** PUBLIC INSTANCE METHODS.
+ *
+ * > _handlerParams;
- private String _init;
- private List
> _modParams;
-
- /******************************************************************
- * CLASS CONSTRUCTOR.
- ******************************************************************/
-
- /**
- * Creates a ConfigHandler.
- */
- public ConfigHandler ()
- {
- _module = new ArrayList<> ();
- _handler = new ArrayList<> ();
- _modParams = new ArrayList<> ();
- _handlerParams = new ArrayList<> ();
-
- _isModule = false;
- _isHandler = false;
- _isTempDir = false;
- _isEncoding = false;
- _isBufferSize = false;
- _isJhoveHome = false;
- _isLogLevel = false;
-
- _bufferSize = -1;
- _encoding = null;
- _tempDir = null;
- _mixVsn = null;
- _sigBytes = 1024;
- _logLevel = null;
- }
+/** SAX Parser for the configuration file. */
+public class ConfigHandler extends org.xml.sax.helpers.DefaultHandler {
+ /**
+ * **************************************************************** PRIVATE INSTANCE FIELDS.
+ * ****************************************************************
+ */
+ private String _class;
- /******************************************************************
- * PUBLIC INSTANCE METHODS.
- *
- * Accessor methods.
- ******************************************************************/
-
- /**
- * Returns the List of Modules specified by the config file.
- * Each element of the List is a String[2] whose elements are
- * the module class name and initialization value.
- *
- * @see Module
- */
- public List
getModuleParams()
are in
- * one-to-one correspondence with those return by getModule()
.
- */
- public List> getModuleParams ()
- {
- return _modParams;
- }
+ protected StringBuffer _content;
- /**
- * Returns the List of handler parameters specified by the config file.
- * Each element of the List is a List (possibly empty) of Strings
- * whose elements are parameters to pass to the output handler. The
- * values returned by
getHandlerParams()
are in
- * one-to-one correspondence with those return by getHandler()
.
- */
- public List> getHandlerParams ()
- {
- return _handlerParams;
- }
+ /** The schema name */
+ private static final String configSchemaName = "jhoveConfig.xsd";
- /**
- * Returns the List of OutputHandlers specified by the config file.
- *
- * @see OutputHandler
- */
- public List
> _handlerParams;
- /**
- * Returns the character encoding specified by the config file.
- */
- public String getEncoding ()
- {
- return _encoding;
- }
+ private String _init;
+ private List
> _modParams;
+
+ /**
+ * **************************************************************** CLASS CONSTRUCTOR.
+ * ****************************************************************
+ */
- /**
- * SAX parser callback method.
- */
- @Override
- public void characters (char [] ch, int start, int length)
- {
- _content.append (ch, start, length);
+ /** Creates a ConfigHandler. */
+ public ConfigHandler() {
+ _module = new ArrayList<>();
+ _handler = new ArrayList<>();
+ _modParams = new ArrayList<>();
+ _handlerParams = new ArrayList<>();
+
+ _isModule = false;
+ _isHandler = false;
+ _isTempDir = false;
+ _isEncoding = false;
+ _isBufferSize = false;
+ _isJhoveHome = false;
+ _isLogLevel = false;
+
+ _bufferSize = -1;
+ _encoding = null;
+ _tempDir = null;
+ _mixVsn = null;
+ _sigBytes = 1024;
+ _logLevel = null;
+ }
+
+ /**
+ * **************************************************************** PUBLIC INSTANCE METHODS.
+ *
+ *
getModuleParams()
are in one-to-one correspondence with those
+ * return by getModule()
.
+ */
+ public List> getModuleParams() {
+ return _modParams;
+ }
+
+ /**
+ * Returns the List of handler parameters specified by the config file. Each element of the List
+ * is a List (possibly empty) of Strings whose elements are parameters to pass to the output
+ * handler. The values returned by
getHandlerParams()
are in one-to-one
+ * correspondence with those return by getHandler()
.
+ */
+ public List> getHandlerParams() {
+ return _handlerParams;
+ }
+
+ /**
+ * Returns the List of OutputHandlers specified by the config file.
+ *
+ * @see OutputHandler
+ */
+ public List
super
constructor.
- *
- * @param name Name of the handler
- * @param release Release identifier
- * @param date Last modification date of the handler code,
- * in the form of an array of three numbers.
- * date[0]
is the year,
- * date[1]
the month, and
- * date[2]
the day.
- * @param note Additional information about the handler
- * (may be null)
- * @param rights Copyright notice for the handler
- */
- protected HandlerBase (String name, String release, int [] date,
- String note, String rights)
- {
- // Though we're actually in the jhove package, all the related
- // action logically belongs in the handler package, so we name
- // this logger accordingly.
- _logger = Logger.getLogger ("edu.harvard.hul.ois.jhove.handler");
- _logger.info ("Initializing " + name);
- _name = name;
- _release = release;
- _encoding = "UTF-8";
-
- Calendar calendar = new GregorianCalendar ();
- calendar.set (date[0], date[1]-1, date[2]);
- _date = calendar.getTime ();
-
- _note = note;
- _rights = rights;
- _specification = new ArrayList<> ();
-
- _level = -1;
- }
-
- /******************************************************************
- * PUBLIC INSTANCE METHODS.
- *
- * Initialization methods.
- ******************************************************************/
-
- /**
- * Reset the handler. This needs to be called before each invocation.
- */
- @Override
- public void reset () {
- _level = -1;
- }
-
- /**
- * Set a a List of default parameters for the module.
- *
- * @param params A List whose elements are Strings.
- * May be empty.
- */
- @Override
- public void setDefaultParams (ListDocument
objects (one for each
- * specification document). The specification
- * list is generated by the OutputHandler, and specifications cannot
- * be added by callers.
- *
- * @see Document
- */
- @Override
- public final Listsuper
+ * constructor.
+ *
+ * @param name Name of the handler
+ * @param release Release identifier
+ * @param date Last modification date of the handler code, in the form of an array of three
+ * numbers. date[0]
is the year, date[1]
the month, and
+ * date[2]
the day.
+ * @param note Additional information about the handler (may be null)
+ * @param rights Copyright notice for the handler
+ */
+ protected HandlerBase(String name, String release, int[] date, String note, String rights) {
+ // Though we're actually in the jhove package, all the related
+ // action logically belongs in the handler package, so we name
+ // this logger accordingly.
+ _logger = Logger.getLogger("edu.harvard.hul.ois.jhove.handler");
+ _logger.info("Initializing " + name);
+ _name = name;
+ _release = release;
+ _encoding = "UTF-8";
+
+ Calendar calendar = new GregorianCalendar();
+ calendar.set(date[0], date[1] - 1, date[2]);
+ _date = calendar.getTime();
+
+ _note = note;
+ _rights = rights;
+ _specification = new ArrayList<>();
+
+ _level = -1;
+ }
+
+ /**
+ * **************************************************************** PUBLIC INSTANCE METHODS.
+ *
+ * Document
objects (one for each specification document). The
+ * specification list is generated by the OutputHandler, and specifications cannot be added by
+ * callers.
+ *
+ * @see Document
+ */
+ @Override
+ public final Listtrue
if this InternalSignature
- * has a fixed byte offset.
- */
- public boolean hasFixedOffset ()
- {
- return _hasFixedOffset;
- }
+ /** Returns true
if this InternalSignature has a fixed byte offset. */
+ public boolean hasFixedOffset() {
+ return _hasFixedOffset;
+ }
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/JhoveBase.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/JhoveBase.java
index ec07f59d2..bd01eb8cd 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/JhoveBase.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/JhoveBase.java
@@ -1,8 +1,8 @@
-/**********************************************************************
- * JHOVE - JSTOR/Harvard Object Validation Environment
- * Copyright 2005-2007 by the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** JHOVE - JSTOR/Harvard Object
+ * Validation Environment Copyright 2005-2007 by the President and Fellows of Harvard College
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
import edu.harvard.hul.ois.jhove.handler.AuditHandler;
@@ -10,12 +10,6 @@
import edu.harvard.hul.ois.jhove.handler.TextHandler;
import edu.harvard.hul.ois.jhove.handler.XmlHandler;
import edu.harvard.hul.ois.jhove.module.BytestreamModule;
-import org.openpreservation.jhove.ReleaseDetails;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-import javax.net.ssl.*;
-import javax.xml.parsers.SAXParserFactory;
import java.io.*;
import java.net.URI;
import java.net.URL;
@@ -30,6 +24,7 @@
import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.net.ssl.*;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
@@ -37,1218 +32,1115 @@
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
+import javax.xml.parsers.SAXParserFactory;
+import org.openpreservation.jhove.ReleaseDetails;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
/**
- * The JHOVE engine, providing all base services necessary to build an
- * application.
+ * The JHOVE engine, providing all base services necessary to build an application.
*
- * More than one JhoveBase may be instantiated and process files in concurrent
- * threads. Any one instance must not be multithreaded.
+ * JhoveBase
object.
- *
- * @throws JhoveException
- * if invoked with a JVM lower than 1.8
- */
- public JhoveBase() throws JhoveException {
-
- _logger = Logger.getLogger("edu.harvard.hul.ois.jhove");
- _logger.setLevel(Level.SEVERE); // May be changed by config file
-
- // Make sure we have a satisfactory version of Java.
- String version = System.getProperty("java.vm.version");
- if (version.compareTo("1.8.0") < 0) {
- _logger.severe(CoreMessageConstants.EXC_JAVA_VER_INCMPT);
- throw new JhoveException(CoreMessageConstants.EXC_JAVA_VER_INCMPT);
- }
+ public static final String _name = "JhoveBase";
+
+ private static final ReleaseDetails RELEASE_DETAILS = ReleaseDetails.getInstance();
+
+ private static final String JAVA_TEMP_DIR_PROP_KEY = "java.io.tmpdir";
+ private static final String HUL_PROPERTY_PREFIX = "edu.harvard.hul.ois.";
+ private static final String JHOVE_PROPERTY_PREFIX = HUL_PROPERTY_PREFIX + "jhove.";
+
+ /** JHOVE buffer size property. */
+ private static final String BUFFER_PROPERTY = JHOVE_PROPERTY_PREFIX + "bufferSize";
+
+ /** JHOVE home directory */
+ private static final String JHOVE_DIR = "jhove";
+
+ /** JHOVE configuration directory */
+ private static final String CONFIG_DIR = "conf";
+
+ /** JHOVE configuration file property. */
+ private static final String CONFIG_PROPERTY = JHOVE_PROPERTY_PREFIX + "config";
+
+ /** JHOVE default buffer size. */
+ private static final int DEFAULT_BUFFER = 131072;
+
+ /** JHOVE default character encoding. */
+ private static final String DEFAULT_ENCODING = "utf-8";
+
+ /** Default temporary directory. */
+ private static final String DEFAULT_TEMP = System.getProperty(JAVA_TEMP_DIR_PROP_KEY);
+
+ /** JHOVE encoding property. */
+ private static final String ENCODING_PROPERTY = JHOVE_PROPERTY_PREFIX + "encoding";
+
+ /** JHOVE SAX parser class property. */
+ private static final String SAX_PROPERTY = JHOVE_PROPERTY_PREFIX + "saxClass";
+
+ /** JHOVE temporary directory property. */
+ private static final String TEMPDIR_PROPERTY = JHOVE_PROPERTY_PREFIX + "tempDirectory";
+
+ /** Flag for aborting activity. */
+ protected boolean _abort;
+ /** Buffer size for buffered I/O. */
+ protected int _bufferSize;
+
+ protected boolean _checksum;
+ /** Configuration file pathname. */
+ protected String _configFile;
+ /** Selected encoding. */
+ protected String _encoding;
+ /** Ordered list of output handlers. */
+ protected ListJhoveBase
object.
+ *
+ * @throws JhoveException if invoked with a JVM lower than 1.8
+ */
+ public JhoveBase() throws JhoveException {
+
+ _logger = Logger.getLogger("edu.harvard.hul.ois.jhove");
+ _logger.setLevel(Level.SEVERE); // May be changed by config file
+
+ // Make sure we have a satisfactory version of Java.
+ String version = System.getProperty("java.vm.version");
+ if (version.compareTo("1.8.0") < 0) {
+ _logger.severe(CoreMessageConstants.EXC_JAVA_VER_INCMPT);
+ throw new JhoveException(CoreMessageConstants.EXC_JAVA_VER_INCMPT);
+ }
- // Tell any HTTPS connections to be accepted automatically.
- HttpsURLConnection.setDefaultHostnameVerifier(
- new NaiveHostnameVerifier());
+ // Tell any HTTPS connections to be accepted automatically.
+ HttpsURLConnection.setDefaultHostnameVerifier(new NaiveHostnameVerifier());
+
+ // Initialize the engine.
+ _moduleList = new ArrayList<>(20);
+ _moduleMap = new TreeMap<>();
+
+ _handlerList = new ArrayList<>();
+ _handlerMap = new TreeMap<>();
+
+ _abort = false;
+ _bufferSize = -1;
+ _checksum = false;
+ _showRaw = false;
+ _signature = false;
+ _callback = null;
+ }
+
+ /**
+ * Initializes the JHOVE engine.
+ *
+ * > params = configHandler.getModuleParams();
- for (int i = 0; i < modList.size(); i++) {
- ModuleInfo modInfo = modList.get(i);
- List
> params = configHandler.getModuleParams();
+ for (int i = 0; i < modList.size(); i++) {
+ ModuleInfo modInfo = modList.get(i);
+ List
null
.
- */
- public void setCallback(Callback callback) {
- _callback = callback;
+ // The Bytestream module and the Text, XML, and Audit output handlers
+ // are always statically loaded.
+
+ Module module = new BytestreamModule();
+ module.setDefaultParams(new ArrayListnull
.
+ */
+ public void setCallback(Callback callback) {
+ _callback = callback;
+ }
+
+ /**
+ * Processes a file or directory, or outputs information. If dirFileOrUri
is null,
+ * Does one of the following:
+ *
+ *
+ *
+ *
+ * @param app The App object for the application
+ * @param module The module to be used
+ * @param aboutHandler If specified, the handler about which info is requested
+ * @param handler The handler for processing the output
+ * @param outputFile Name of the file to which output should go
+ * @param dirFileOrUri One or more file names or URI's to be analyzed
+ */
+ public void dispatch(
+ App app,
+ Module module,
+ OutputHandler aboutHandler,
+ OutputHandler handler,
+ String outputFile,
+ String[] dirFileOrUri)
+ throws Exception {
+
+ _abort = false;
+
+ // If no handler is specified, use the default TEXT handler.
+ if (handler == null) {
+ handler = _handlerMap.get("text");
}
+ handler.reset();
+ _outputFile = outputFile;
- /**
- * Processes a file or directory, or outputs information. If
- * aboutHandler
is non-null, provides information about that
+ * handler.
+ * dirFileOrUri
is null, Does one of the following:
- *
- *
- *
- * @param app
- * The App object for the application
- * @param module
- * The module to be used
- * @param aboutHandler
- * If specified, the handler about which info is requested
- * @param handler
- * The handler for processing the output
- * @param outputFile
- * Name of the file to which output should go
- * @param dirFileOrUri
- * One or more file names or URI's to be analyzed
- */
- public void dispatch(App app, Module module, OutputHandler aboutHandler,
- OutputHandler handler, String outputFile, String[] dirFileOrUri)
- throws Exception {
-
- _abort = false;
-
- // If no handler is specified, use the default TEXT handler.
- if (handler == null) {
- handler = _handlerMap.get("text");
- }
- handler.reset();
- _outputFile = outputFile;
-
- handler.setApp(app);
- handler.setBase(this);
- _logger.info("Handler " + handler.getClass().getName()
- + " preparing to write to " + _outputFile);
- handler.setWriter(makeWriter(_outputFile, _encoding));
-
- handler.showHeader();
-
- if (dirFileOrUri == null) {
- if (module != null) {
- // Show info about module.
- module.applyDefaultParams();
- module.show(handler);
- } else if (aboutHandler != null) {
- // Show info about handler.
- handler.show(aboutHandler);
- } else {
- // Show info about application
- app.show(handler);
- }
- } else {
- for (String aDirFileOrUri : dirFileOrUri) {
- if (!process(app, module, handler, aDirFileOrUri)) {
- break;
- }
- }
- }
-
- handler.showFooter();
- handler.close();
- }
-
- /**
- * Returns aboutHandler
is non-null, provides
- * information about that handler.
- * false
if processing should be aborted.
- * Calls itself recursively for directories.
- */
- public boolean process(App app, Module module, OutputHandler handler,
- String dirFileOrUri) throws Exception {
-
- if (_abort) {
- return false;
- }
- _logger.info("Entering JhoveBase.process, file/uri = "
- + dirFileOrUri);
- File file = null;
- boolean isTemp = false;
- long lastModified = -1;
-
- // First see if we have a URI, if not it is a directory or a file.
- URI uri = null;
- try {
- uri = new URI(dirFileOrUri);
- } catch (Exception e) {
- // We may get an exception on Windows paths,
- // if so then fall through and try for a file.
- }
- RepInfo info = new RepInfo(dirFileOrUri);
- if (uri != null && uri.isAbsolute()) {
- URL url = null;
- try {
- url = uri.toURL();
- } catch (Exception e) {
- throw new JhoveException(CoreMessageConstants.EXC_URI_CONV_FAIL
- + dirFileOrUri);
- }
- URLConnection conn = url.openConnection();
- _conn = conn;
- if (conn instanceof HttpsURLConnection) {
- try {
- TrustManager[] tm = { new RelaxedX509TrustManager() };
- SSLContext sslContext = SSLContext.getInstance("SSL");
- sslContext.init(null, tm, new java.security.SecureRandom());
- SSLSocketFactory sf = sslContext.getSocketFactory();
- ((HttpsURLConnection) conn).setSSLSocketFactory(sf);
- int code = ((HttpsURLConnection) conn).getResponseCode();
- if (200 > code || code >= 300) {
- throw new JhoveException(CoreMessageConstants.EXC_URL_NOT_FND
- + dirFileOrUri);
- }
- } catch (Exception e) {
- throw new JhoveException(CoreMessageConstants.EXC_URL_NOT_FND + dirFileOrUri);
- }
- }
- lastModified = conn.getLastModified();
-
- // Convert the URI to a temporary file and use for the input stream.
- try {
- file = connToTempFile(conn, info);
- if (file == null) {
- // User aborted
- return false;
- }
- isTemp = true;
- } catch (IOException ioe) {
- _conn = null;
- String message = "Cannot read URL: " + dirFileOrUri;
- _logger.info(message);
- String ioeMessage = ioe.getMessage();
- if (ioeMessage != null) {
- message += " (" + ioeMessage + ")";
- }
- throw new JhoveException(message);
- }
- if (conn instanceof HttpsURLConnection) {
- ((HttpsURLConnection) conn).disconnect();
- }
- _conn = null;
- } else {
- file = new File(dirFileOrUri);
- }
-
- if (file.isDirectory()) {
- File[] files = file.listFiles();
- info = null; // Free up unused RepInfo before recursing
+ handler.setApp(app);
+ handler.setBase(this);
+ _logger.info(
+ "Handler " + handler.getClass().getName() + " preparing to write to " + _outputFile);
+ handler.setWriter(makeWriter(_outputFile, _encoding));
- // Sort the files in ascending order by filename.
- Arrays.sort(files);
+ handler.showHeader();
- handler.startDirectory(file.getCanonicalPath());
- for (int i = 0; i < files.length; i++) {
- if (!process(app, module, handler, files[i].getCanonicalPath())) {
- return false;
- }
- }
- handler.endDirectory();
- } else {
-
- if (!file.exists()) {
- _logger.info("File not found");
- info.setMessage(new ErrorMessage(CoreMessageConstants.ERR_FILE_NOT_FOUND));
- info.setWellFormed(RepInfo.UNDETERMINED);
- info.show(handler);
- } else if (!file.isFile() || !file.canRead()) {
- _logger.info("File cannot be read");
- info.setMessage(new ErrorMessage(CoreMessageConstants.ERR_FILE_READ));
- info.setWellFormed(RepInfo.UNDETERMINED);
- info.show(handler);
- } else if (handler.okToProcess(dirFileOrUri)) {
- info.setSize(file.length());
- if (lastModified < 0) {
- lastModified = file.lastModified();
- }
- info.setLastModified(new Date(lastModified));
-
- if (module != null) {
-
- // Invoke the specified module.
- _logger.info("Processing " + file.getName()
- + " with module " + module.getClass().getName());
- try {
- if (!processFile(app, module, false, file, info)) {
- return false;
- }
- } catch (Exception e) {
- info.setMessage(new ErrorMessage(CoreMessageConstants.EXC_UNEXPECTED));
- info.setWellFormed(RepInfo.UNDETERMINED);
- _logger.log(Level.SEVERE, CoreMessageConstants.EXC_UNEXPECTED, e);
- }
- } else {
-
- // Invoke all modules until one returns well-formed. If a
- // module doesn't know how to validate, we don't want to
- // throw arbitrary files at it, so we'll skip it.
- for (Module mod : _moduleList) {
- RepInfo infc = (RepInfo) info.clone();
-
- if (mod.hasFeature("edu.harvard.hul.ois.jhove.canValidate")) {
- try {
- if (!processFile(app, mod, false, file, infc)) {
- return false;
- }
- if (infc.getWellFormed() == RepInfo.TRUE) {
- info.copy(infc);
- break;
- }
- // We want to know what modules matched the
- // signature, so we force the sigMatch
- // property to be persistent.
- info.setSigMatch(infc.getSigMatch());
-
- } catch (Exception e) {
- // The assumption is that in trying to analyze
- // the wrong type of file, the module may go off
- // its track and throw an exception, so we just
- // continue on to the next module.
- _logger.info("JHOVE caught exception: "
- + e.getClass().getName());
- }
- }
- }
- }
- info.show(handler);
- }
- }
- if (file != null && isTemp) {
- file.delete();
+ if (dirFileOrUri == null) {
+ if (module != null) {
+ // Show info about module.
+ module.applyDefaultParams();
+ module.show(handler);
+ } else if (aboutHandler != null) {
+ // Show info about handler.
+ handler.show(aboutHandler);
+ } else {
+ // Show info about application
+ app.show(handler);
+ }
+ } else {
+ for (String aDirFileOrUri : dirFileOrUri) {
+ if (!process(app, module, handler, aDirFileOrUri)) {
+ break;
}
- return true;
+ }
}
- /**
- * Saves a URLConnection's data stream to a temporary file. This may be
- * interrupted asynchronously by calling abort
, in which
- * case it will delete the temporary file and return null
.
- */
- public File connToTempFile(URLConnection conn, RepInfo info)
- throws IOException {
+ handler.showFooter();
+ handler.close();
+ }
- File tempFile;
- try {
- tempFile = newTempFile();
- } catch (IOException ioe) {
- // Throw a more meaningful exception
- throw new IOException(CoreMessageConstants.EXC_TEMP_FILE_CRT);
- }
+ /**
+ * Returns false
if processing should be aborted. Calls itself recursively for
+ * directories.
+ */
+ public boolean process(App app, Module module, OutputHandler handler, String dirFileOrUri)
+ throws Exception {
- OutputStream outstrm = null;
- DataInputStream instrm = null;
- if (_bufferSize > 0) {
- outstrm = new BufferedOutputStream(new FileOutputStream(tempFile),
- _bufferSize);
- } else {
- outstrm = new BufferedOutputStream(new FileOutputStream(tempFile));
- }
+ if (_abort) {
+ return false;
+ }
+ _logger.info("Entering JhoveBase.process, file/uri = " + dirFileOrUri);
+ File file = null;
+ boolean isTemp = false;
+ long lastModified = -1;
+
+ // First see if we have a URI, if not it is a directory or a file.
+ URI uri = null;
+ try {
+ uri = new URI(dirFileOrUri);
+ } catch (Exception e) {
+ // We may get an exception on Windows paths,
+ // if so then fall through and try for a file.
+ }
+ RepInfo info = new RepInfo(dirFileOrUri);
+ if (uri != null && uri.isAbsolute()) {
+ URL url = null;
+ try {
+ url = uri.toURL();
+ } catch (Exception e) {
+ throw new JhoveException(CoreMessageConstants.EXC_URI_CONV_FAIL + dirFileOrUri);
+ }
+ URLConnection conn = url.openConnection();
+ _conn = conn;
+ if (conn instanceof HttpsURLConnection) {
try {
- if (_bufferSize > 0) {
- instrm = new DataInputStream(new BufferedInputStream(
- conn.getInputStream(), _bufferSize));
- } else {
- instrm = new DataInputStream(new BufferedInputStream(
- conn.getInputStream()));
- }
- } catch (UnknownHostException uhe) {
- tempFile.delete();
- throw new IOException(uhe.toString());
- } catch (IOException ioe) {
- // IOExceptions other than UnknownHostException
- tempFile.delete();
- throw ioe;
+ TrustManager[] tm = {new RelaxedX509TrustManager()};
+ SSLContext sslContext = SSLContext.getInstance("SSL");
+ sslContext.init(null, tm, new java.security.SecureRandom());
+ SSLSocketFactory sf = sslContext.getSocketFactory();
+ ((HttpsURLConnection) conn).setSSLSocketFactory(sf);
+ int code = ((HttpsURLConnection) conn).getResponseCode();
+ if (200 > code || code >= 300) {
+ throw new JhoveException(CoreMessageConstants.EXC_URL_NOT_FND + dirFileOrUri);
+ }
} catch (Exception e) {
- // Arbitrary URL's may throw unpredictable expressions;
- // treat them as IOExceptions
- tempFile.delete();
- throw new IOException(e.toString());
+ throw new JhoveException(CoreMessageConstants.EXC_URL_NOT_FND + dirFileOrUri);
}
-
- Checksummer ckSummer = null;
- if (_checksum) {
- ckSummer = new Checksummer();
+ }
+ lastModified = conn.getLastModified();
+
+ // Convert the URI to a temporary file and use for the input stream.
+ try {
+ file = connToTempFile(conn, info);
+ if (file == null) {
+ // User aborted
+ return false;
}
- _nByte = 0;
-
- int appModulo = 4000;
-
- // Copy the connection stream to the file.
- // While we're here, calculate the checksums.
- try {
- byte by;
- for (;;) {
- // Make sure other threads can get in occasionally to cancel
- if ((_nByte % appModulo) == 0) {
- Thread.yield();
- if (_callback != null) {
- _callback.callback(1, _nByte);
- }
- // In order to avoid doing too many callbacks, limit
- // the checking to a number of bytes at least 1/10 of
- // the bytes read so far.
- if (appModulo * 10 < _nByte) {
- appModulo = (int) (_nByte / 10);
- }
- }
- if (_abort) {
- // Asynchronous abort requested. Clean up.
- instrm.close();
- outstrm.close();
- tempFile.delete();
- return null;
- }
- int ch = instrm.readUnsignedByte();
- if (ckSummer != null) {
- ckSummer.update(ch);
- }
- by = Checksum.unsignedByteToByte(ch);
- _nByte++;
- outstrm.write(by);
- }
- } catch (EOFException eofe) {
- // This is the normal way for detecting we're done.
+ isTemp = true;
+ } catch (IOException ioe) {
+ _conn = null;
+ String message = "Cannot read URL: " + dirFileOrUri;
+ _logger.info(message);
+ String ioeMessage = ioe.getMessage();
+ if (ioeMessage != null) {
+ message += " (" + ioeMessage + ")";
}
+ throw new JhoveException(message);
+ }
+ if (conn instanceof HttpsURLConnection) {
+ ((HttpsURLConnection) conn).disconnect();
+ }
+ _conn = null;
+ } else {
+ file = new File(dirFileOrUri);
+ }
- // The caller is responsible for disconnecting conn.
- instrm.close();
- outstrm.close();
+ if (file.isDirectory()) {
+ File[] files = file.listFiles();
+ info = null; // Free up unused RepInfo before recursing
- // Update RepInfo
- info.setSize(_nByte);
- if (ckSummer != null) {
- info.setChecksum(new Checksum(ckSummer.getCRC32(),
- ChecksumType.CRC32));
- String value = ckSummer.getMD5();
- if (value != null) {
- info.setChecksum(new Checksum(value, ChecksumType.MD5));
- }
- value = ckSummer.getSHA1();
- if (value != null) {
- info.setChecksum(new Checksum(value, ChecksumType.SHA1));
- }
- value = ckSummer.getSHA256();
- if (value != null) {
- info.setChecksum(new Checksum(value, ChecksumType.SHA256));
- }
- }
- return tempFile;
- }
+ // Sort the files in ascending order by filename.
+ Arrays.sort(files);
- /**
- * Aborts an activity. This simply sets a flag; whether anything is aborted
- * depends on what activity is happening.
- */
- public void abort() {
- _abort = true;
- HttpsURLConnection conn = null;
- if (_conn instanceof HttpsURLConnection) {
- conn = (HttpsURLConnection) _conn;
- }
- // If we're stuck in socket I/O, then there is no way
- // to kill the thread cleanly. Wait a few seconds,
- // and if we're still not terminated, pull the plug on
- // the socket.
- try {
- Thread.sleep(4000);
- } catch (InterruptedException ie) {
+ handler.startDirectory(file.getCanonicalPath());
+ for (int i = 0; i < files.length; i++) {
+ if (!process(app, module, handler, files[i].getCanonicalPath())) {
+ return false;
}
- if (conn != null) {
- // This is a non-deprecated way of bringing the connection
- // to a screeching halt. disconnect will (we hope) close
- // the underlying socket, killing any hanging I/O.
- conn.disconnect();
+ }
+ handler.endDirectory();
+ } else {
+
+ if (!file.exists()) {
+ _logger.info("File not found");
+ info.setMessage(new ErrorMessage(CoreMessageConstants.ERR_FILE_NOT_FOUND));
+ info.setWellFormed(RepInfo.UNDETERMINED);
+ info.show(handler);
+ } else if (!file.isFile() || !file.canRead()) {
+ _logger.info("File cannot be read");
+ info.setMessage(new ErrorMessage(CoreMessageConstants.ERR_FILE_READ));
+ info.setWellFormed(RepInfo.UNDETERMINED);
+ info.show(handler);
+ } else if (handler.okToProcess(dirFileOrUri)) {
+ info.setSize(file.length());
+ if (lastModified < 0) {
+ lastModified = file.lastModified();
}
- }
+ info.setLastModified(new Date(lastModified));
- /**
- * Processes the file. Returns false
if aborted, or if
- * the module is incapable of validation. This shouldn't be called if
- * the module doesn't have the validation feature.
- */
- public boolean processFile(App app, Module module, boolean verbose,
- File file, RepInfo info) throws Exception {
+ if (module != null) {
- if (!module.hasFeature("edu.harvard.hul.ois.jhove.canValidate")) {
- return false;
- }
- if (_callback != null) {
- _callback.callback(2, info.getUri());
- }
- module.setApp(app);
- module.setBase(this);
- module.setVerbosity(verbose ? Module.MAXIMUM_VERBOSITY
- : Module.MINIMUM_VERBOSITY);
- module.applyDefaultParams();
- if (module.isRandomAccess()) {
-
- // Module needs random access input.
- RandomAccessFile raf = new RandomAccessFile(file, "r");
- try {
- if (_signature) {
- module.checkSignatures(file, raf, info);
- } else {
- module.parse(raf, info);
- }
- } finally {
- raf.close();
+ // Invoke the specified module.
+ _logger.info(
+ "Processing " + file.getName() + " with module " + module.getClass().getName());
+ try {
+ if (!processFile(app, module, false, file, info)) {
+ return false;
}
+ } catch (Exception e) {
+ info.setMessage(new ErrorMessage(CoreMessageConstants.EXC_UNEXPECTED));
+ info.setWellFormed(RepInfo.UNDETERMINED);
+ _logger.log(Level.SEVERE, CoreMessageConstants.EXC_UNEXPECTED, e);
+ }
} else {
- // Module accepts stream input.
- InputStream stream = new FileInputStream(file);
- try {
- if (_signature) {
- module.checkSignatures(file, stream, info);
- } else {
- int parseIndex = module.parse(stream, info, 0);
- // If parse returns non-zero, reparse with a fresh stream.
- while (parseIndex != 0) {
- stream.close();
- stream = new FileInputStream(file);
- parseIndex = module.parse(stream, info, parseIndex);
- }
+ // Invoke all modules until one returns well-formed. If a
+ // module doesn't know how to validate, we don't want to
+ // throw arbitrary files at it, so we'll skip it.
+ for (Module mod : _moduleList) {
+ RepInfo infc = (RepInfo) info.clone();
+
+ if (mod.hasFeature("edu.harvard.hul.ois.jhove.canValidate")) {
+ try {
+ if (!processFile(app, mod, false, file, infc)) {
+ return false;
}
- } finally {
- stream.close();
+ if (infc.getWellFormed() == RepInfo.TRUE) {
+ info.copy(infc);
+ break;
+ }
+ // We want to know what modules matched the
+ // signature, so we force the sigMatch
+ // property to be persistent.
+ info.setSigMatch(infc.getSigMatch());
+
+ } catch (Exception e) {
+ // The assumption is that in trying to analyze
+ // the wrong type of file, the module may go off
+ // its track and throw an exception, so we just
+ // continue on to the next module.
+ _logger.info("JHOVE caught exception: " + e.getClass().getName());
+ }
}
+ }
}
- return true; // Successful processing
- }
-
- /**
- * Creates a temporary file with a unique name. The file will be deleted
- * when the application exits.
- */
- public File tempFile() throws IOException {
- File file;
-
- // If no temporary directory has been specified,
- // use Java's default temporary directory.
- if (_tempDir == null) {
- file = File.createTempFile("JHOV", "");
- } else {
- File dir = new File(_tempDir);
- file = File.createTempFile("JHOV", "", dir);
- }
- file.deleteOnExit();
-
- return file;
+ info.show(handler);
+ }
}
-
- /**
- * Returns the abort flag.
- */
- public boolean getAbort() {
- return _abort;
+ if (file != null && isTemp) {
+ file.delete();
}
-
- /**
- * Returns buffer size. A value of -1 signifies that the invoking code
- * should assume the default buffer size.
- */
- public int getBufferSize() {
- return _bufferSize;
+ return true;
+ }
+
+ /**
+ * Saves a URLConnection's data stream to a temporary file. This may be interrupted asynchronously
+ * by calling abort
, in which case it will delete the temporary file and return
+ * null
.
+ */
+ public File connToTempFile(URLConnection conn, RepInfo info) throws IOException {
+
+ File tempFile;
+ try {
+ tempFile = newTempFile();
+ } catch (IOException ioe) {
+ // Throw a more meaningful exception
+ throw new IOException(CoreMessageConstants.EXC_TEMP_FILE_CRT);
}
- /**
- * Returns the configuration file.
- */
- public String getConfigFile() {
- return _configFile;
+ OutputStream outstrm = null;
+ DataInputStream instrm = null;
+ if (_bufferSize > 0) {
+ outstrm = new BufferedOutputStream(new FileOutputStream(tempFile), _bufferSize);
+ } else {
+ outstrm = new BufferedOutputStream(new FileOutputStream(tempFile));
}
-
- /**
- * Returns the engine date (the date at which this instance was created).
- */
- public Date getDate() {
- return RELEASE_DETAILS.getBuildDate();
+ try {
+ if (_bufferSize > 0) {
+ instrm = new DataInputStream(new BufferedInputStream(conn.getInputStream(), _bufferSize));
+ } else {
+ instrm = new DataInputStream(new BufferedInputStream(conn.getInputStream()));
+ }
+ } catch (UnknownHostException uhe) {
+ tempFile.delete();
+ throw new IOException(uhe.toString());
+ } catch (IOException ioe) {
+ // IOExceptions other than UnknownHostException
+ tempFile.delete();
+ throw ioe;
+ } catch (Exception e) {
+ // Arbitrary URL's may throw unpredictable expressions;
+ // treat them as IOExceptions
+ tempFile.delete();
+ throw new IOException(e.toString());
}
- /**
- * Returns the output encoding.
- */
- public String getEncoding() {
- return _encoding;
+ Checksummer ckSummer = null;
+ if (_checksum) {
+ ckSummer = new Checksummer();
}
-
- /**
- * Returns a handler by name.
- */
- public OutputHandler getHandler(String name) {
- OutputHandler handler = null;
- if (name != null) {
- handler = _handlerMap.get(name.toLowerCase());
+ _nByte = 0;
+
+ int appModulo = 4000;
+
+ // Copy the connection stream to the file.
+ // While we're here, calculate the checksums.
+ try {
+ byte by;
+ for (; ; ) {
+ // Make sure other threads can get in occasionally to cancel
+ if ((_nByte % appModulo) == 0) {
+ Thread.yield();
+ if (_callback != null) {
+ _callback.callback(1, _nByte);
+ }
+ // In order to avoid doing too many callbacks, limit
+ // the checking to a number of bytes at least 1/10 of
+ // the bytes read so far.
+ if (appModulo * 10 < _nByte) {
+ appModulo = (int) (_nByte / 10);
+ }
}
- return handler;
- }
-
- /**
- * Returns map of handler names to handlers.
- */
- public MapsetSaveDirectory
.
- */
- public File getSaveDirectory() {
- return _saveDir;
+ // If we're stuck in socket I/O, then there is no way
+ // to kill the thread cleanly. Wait a few seconds,
+ // and if we're still not terminated, pull the plug on
+ // the socket.
+ try {
+ Thread.sleep(4000);
+ } catch (InterruptedException ie) {
}
-
- /**
- * Returns true
if checksums are requested.
- */
- public boolean getChecksumFlag() {
- return _checksum;
+ if (conn != null) {
+ // This is a non-deprecated way of bringing the connection
+ // to a screeching halt. disconnect will (we hope) close
+ // the underlying socket, killing any hanging I/O.
+ conn.disconnect();
}
+ }
- /**
- * Returns true
if raw output is requested. Raw output means
- * numeric rather than symbolic output; its exact interpretation is up to
- * the module, but generally applies to named flags.
- */
- public boolean getShowRawFlag() {
- return _showRaw;
- }
+ /**
+ * Processes the file. Returns false
if aborted, or if the module is incapable of
+ * validation. This shouldn't be called if the module doesn't have the validation feature.
+ */
+ public boolean processFile(App app, Module module, boolean verbose, File file, RepInfo info)
+ throws Exception {
- /**
- * Returns the "check signature only" flag.
- */
- public boolean getSignatureFlag() {
- return _signature;
+ if (!module.hasFeature("edu.harvard.hul.ois.jhove.canValidate")) {
+ return false;
}
-
- /**
- * Returns the requested MIX schema version.
- */
- public String getMixVersion() {
- return _mixVsn;
+ if (_callback != null) {
+ _callback.callback(2, info.getUri());
}
-
- /**
- * Sets the buffer size. A value of -1 signifies that the invoking code will
- * assume the default buffer size.
- *
- * Any non-negative value less than 1024 will result in a buffer size of
- * 1024.
- */
- public void setBufferSize(int bufferSize) {
- if (bufferSize >= 0 && bufferSize < 1024) {
- _bufferSize = 1024;
+ module.setApp(app);
+ module.setBase(this);
+ module.setVerbosity(verbose ? Module.MAXIMUM_VERBOSITY : Module.MINIMUM_VERBOSITY);
+ module.applyDefaultParams();
+ if (module.isRandomAccess()) {
+
+ // Module needs random access input.
+ RandomAccessFile raf = new RandomAccessFile(file, "r");
+ try {
+ if (_signature) {
+ module.checkSignatures(file, raf, info);
} else {
- _bufferSize = bufferSize;
+ module.parse(raf, info);
}
- }
-
- /**
- * Sets the output encoding.
- */
- public void setEncoding(String encoding) {
- _encoding = encoding;
- }
-
- /**
- * Sets the temporary directory path.
- */
- public void setTempDirectory(String tempDir) {
- _tempDir = tempDir;
- }
-
- /**
- * Sets the log level. The value should be the name of a predefined instance
- * of java.util.logging.Level, e.g., "WARNING", "INFO", "ALL". This will
- * override the config file setting.
- */
- public void setLogLevel(String level) {
- _logLevel = level;
- if (level != null) {
- try {
- _logger.setLevel(Level.parse(_logLevel));
- } catch (Exception e) {
- }
+ } finally {
+ raf.close();
+ }
+ } else {
+
+ // Module accepts stream input.
+ InputStream stream = new FileInputStream(file);
+ try {
+ if (_signature) {
+ module.checkSignatures(file, stream, info);
+ } else {
+ int parseIndex = module.parse(stream, info, 0);
+ // If parse returns non-zero, reparse with a fresh stream.
+ while (parseIndex != 0) {
+ stream.close();
+ stream = new FileInputStream(file);
+ parseIndex = module.parse(stream, info, parseIndex);
+ }
}
+ } finally {
+ stream.close();
+ }
}
-
- /**
- * Sets the value to be returned by doChecksum
.
- */
- public void setChecksumFlag(boolean checksum) {
- _checksum = checksum;
+ return true; // Successful processing
+ }
+
+ /**
+ * Creates a temporary file with a unique name. The file will be deleted when the application
+ * exits.
+ */
+ public File tempFile() throws IOException {
+ File file;
+
+ // If no temporary directory has been specified,
+ // use Java's default temporary directory.
+ if (_tempDir == null) {
+ file = File.createTempFile("JHOV", "");
+ } else {
+ File dir = new File(_tempDir);
+ file = File.createTempFile("JHOV", "", dir);
}
-
- /**
- * Sets the value to be returned by getShowRawFlag
, which
- * determines if only raw numeric values should be output.
- */
- public void setShowRawFlag(boolean raw) {
- _showRaw = raw;
+ file.deleteOnExit();
+
+ return file;
+ }
+
+ /** Returns the abort flag. */
+ public boolean getAbort() {
+ return _abort;
+ }
+
+ /**
+ * Returns buffer size. A value of -1 signifies that the invoking code should assume the default
+ * buffer size.
+ */
+ public int getBufferSize() {
+ return _bufferSize;
+ }
+
+ /** Returns the configuration file. */
+ public String getConfigFile() {
+ return _configFile;
+ }
+
+ /** Returns the engine date (the date at which this instance was created). */
+ public Date getDate() {
+ return RELEASE_DETAILS.getBuildDate();
+ }
+
+ /** Returns the output encoding. */
+ public String getEncoding() {
+ return _encoding;
+ }
+
+ /** Returns a handler by name. */
+ public OutputHandler getHandler(String name) {
+ OutputHandler handler = null;
+ if (name != null) {
+ handler = _handlerMap.get(name.toLowerCase());
}
-
- /**
- * Sets the "check signature only" flag.
- */
- public void setSignatureFlag(boolean signature) {
- _signature = signature;
+ return handler;
+ }
+
+ /** Returns map of handler names to handlers. */
+ public MapsetSaveDirectory
.
+ */
+ public File getSaveDirectory() {
+ return _saveDir;
+ }
+
+ /** Returns true
if checksums are requested. */
+ public boolean getChecksumFlag() {
+ return _checksum;
+ }
+
+ /**
+ * Returns true
if raw output is requested. Raw output means numeric rather than
+ * symbolic output; its exact interpretation is up to the module, but generally applies to named
+ * flags.
+ */
+ public boolean getShowRawFlag() {
+ return _showRaw;
+ }
+
+ /** Returns the "check signature only" flag. */
+ public boolean getSignatureFlag() {
+ return _signature;
+ }
+
+ /** Returns the requested MIX schema version. */
+ public String getMixVersion() {
+ return _mixVsn;
+ }
+
+ /**
+ * Sets the buffer size. A value of -1 signifies that the invoking code will assume the default
+ * buffer size.
+ *
+ * doChecksum
. */
+ public void setChecksumFlag(boolean checksum) {
+ _checksum = checksum;
+ }
+
+ /**
+ * Sets the value to be returned by getShowRawFlag
, which determines if only raw
+ * numeric values should be output.
+ */
+ public void setShowRawFlag(boolean raw) {
+ _showRaw = raw;
+ }
+
+ /** Sets the "check signature only" flag. */
+ public void setSignatureFlag(boolean signature) {
+ _signature = signature;
+ }
+
+ /** Sets the default directory for subsequent save operations. */
+ public void setSaveDirectory(File dir) {
+ _saveDir = dir;
+ }
+
+ /** Sets the current thread for parsing. */
+ public void setCurrentThread(Thread t) {
+ _currentThread = t;
+ }
+
+ /**
+ * Resets the abort flag. This must be called at the beginning of any activity for which the abort
+ * flag may subsequently be set.
+ */
+ public void resetAbort() {
+ _abort = false;
+ }
+
+ /**
+ * Uses the user.home property to locate the configuration file. The file is expected to be in the
+ * subdirectory named by CONFIG_DIR under the home directory, and to be named jhove.conf
+ *
. Returns null
if no such file is found.
+ */
+ public static String getConfigFileFromProperties() {
+ String configFile = getFromProperties(CONFIG_PROPERTY);
+ if (configFile == null) {
+ try {
+ String fs = System.getProperty("file.separator");
+ configFile =
+ System.getProperty("user.home") + fs + JHOVE_DIR + fs + CONFIG_DIR + fs + "jhove.conf";
+ } catch (Exception e) {
+ }
}
-
- /**
- * Uses the user.home property to locate the configuration file. The file is
- * expected to be in the subdirectory named by CONFIG_DIR under the home
- * directory, and to be named jhove.conf
. Returns
- * null
if no such file is found.
- */
- public static String getConfigFileFromProperties() {
- String configFile = getFromProperties(CONFIG_PROPERTY);
- if (configFile == null) {
- try {
- String fs = System.getProperty("file.separator");
- configFile = System.getProperty("user.home") + fs + JHOVE_DIR
- + fs + CONFIG_DIR + fs + "jhove.conf";
- } catch (Exception e) {
- }
- }
- return configFile;
+ return configFile;
+ }
+
+ /**
+ * Returns the value of the property edu.harvard.hul.ois.jhove.saxClass
, which should
+ * be the name of the main SAX class. Returns null
if no such property has been set
+ * up.
+ */
+ public static String getSaxClassFromProperties() {
+ return getFromProperties(SAX_PROPERTY);
+ }
+
+ /** Returns a named value from the properties file. */
+ public static String getFromProperties(String name) {
+ String value = null;
+ try {
+ String fs = System.getProperty("file.separator");
+ Properties props = new Properties();
+ String propsFile = System.getProperty("user.home") + fs + JHOVE_DIR + fs + "jhove.properties";
+ FileInputStream stream = new FileInputStream(propsFile);
+ props.load(stream);
+ stream.close();
+
+ value = props.getProperty(name);
+ } catch (Exception e) {
}
-
- /**
- * Returns the value of the property
- * edu.harvard.hul.ois.jhove.saxClass
, which should be the name
- * of the main SAX class. Returns null
if no such property has
- * been set up.
- */
- public static String getSaxClassFromProperties() {
- return getFromProperties(SAX_PROPERTY);
+ return value;
+ }
+
+ /**
+ * Creates an output PrintWriter.
+ *
+ * @param outputFile Output filepath. If null, writer goes to System.out.
+ * @param encoding Character encoding. Must not be null.
+ */
+ protected static PrintWriter makeWriter(String outputFile, String encoding)
+ throws JhoveException {
+
+ PrintWriter output = null;
+ OutputStreamWriter osw = null;
+ if (outputFile != null) {
+ try {
+ FileOutputStream stream = new FileOutputStream(outputFile);
+ osw = new OutputStreamWriter(stream, encoding);
+ output = new PrintWriter(osw);
+ } catch (UnsupportedEncodingException uee) {
+ throw new JhoveException(CoreMessageConstants.EXC_CHAR_ENC_UNSPPTD + encoding);
+ } catch (FileNotFoundException fnfe) {
+ throw new JhoveException(CoreMessageConstants.EXC_FILE_OPEN + outputFile);
+ }
}
-
- /**
- * Returns a named value from the properties file.
- */
- public static String getFromProperties(String name) {
- String value = null;
- try {
- String fs = System.getProperty("file.separator");
- Properties props = new Properties();
- String propsFile = System.getProperty("user.home") + fs + JHOVE_DIR
- + fs + "jhove.properties";
- FileInputStream stream = new FileInputStream(propsFile);
- props.load(stream);
- stream.close();
-
- value = props.getProperty(name);
- } catch (Exception e) {
- }
- return value;
+ if (output == null) {
+ try {
+ osw = new OutputStreamWriter(System.out, encoding);
+ } catch (UnsupportedEncodingException uee) {
+ throw new JhoveException(CoreMessageConstants.EXC_CHAR_ENC_UNSPPTD + encoding);
+ }
+ output = new PrintWriter(osw);
}
-
- /**
- * Creates an output PrintWriter.
- *
- * @param outputFile
- * Output filepath. If null, writer goes to System.out.
- * @param encoding
- * Character encoding. Must not be null.
- */
- protected static PrintWriter makeWriter(String outputFile, String encoding)
- throws JhoveException {
-
- PrintWriter output = null;
- OutputStreamWriter osw = null;
- if (outputFile != null) {
- try {
- FileOutputStream stream = new FileOutputStream(outputFile);
- osw = new OutputStreamWriter(stream, encoding);
- output = new PrintWriter(osw);
- } catch (UnsupportedEncodingException uee) {
- throw new JhoveException(CoreMessageConstants.EXC_CHAR_ENC_UNSPPTD
- + encoding);
- } catch (FileNotFoundException fnfe) {
- throw new JhoveException(CoreMessageConstants.EXC_FILE_OPEN
- + outputFile);
- }
- }
- if (output == null) {
- try {
- osw = new OutputStreamWriter(System.out, encoding);
- } catch (UnsupportedEncodingException uee) {
- throw new JhoveException(CoreMessageConstants.EXC_CHAR_ENC_UNSPPTD
- + encoding);
- }
- output = new PrintWriter(osw);
- }
- return output;
+ return output;
+ }
+
+ /**
+ * Creates a temporary file with a unique name. The file will be deleted when the application
+ * exits.
+ */
+ public File newTempFile() throws IOException {
+ return tempFile();
+ }
+
+ /** A HostnameVerifier for HTTPS connections that will never ask for certificates. */
+ private class NaiveHostnameVerifier implements HostnameVerifier {
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
}
+ }
- /**
- * Creates a temporary file with a unique name. The file will be deleted
- * when the application exits.
- */
- public File newTempFile() throws IOException {
- return tempFile();
+ /** A TrustManager which should accept all certificates. */
+ private class RelaxedX509TrustManager implements X509TrustManager {
+ public boolean isClientTrusted(java.security.cert.X509Certificate[] chain) {
+ return true;
}
- /**
- * A HostnameVerifier for HTTPS connections that will never ask for
- * certificates.
- */
- private class NaiveHostnameVerifier implements HostnameVerifier {
- public boolean verify(String hostname, SSLSession session) {
- return true;
- }
+ public boolean isServerTrusted(java.security.cert.X509Certificate[] chain) {
+ return true;
}
- /**
- * A TrustManager which should accept all certificates.
- */
- private class RelaxedX509TrustManager implements X509TrustManager {
- public boolean isClientTrusted(
- java.security.cert.X509Certificate[] chain) {
- return true;
- }
-
- public boolean isServerTrusted(
- java.security.cert.X509Certificate[] chain) {
- return true;
- }
-
- public java.security.cert.X509Certificate[] getAcceptedIssuers() {
- return null;
- }
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
- public void checkClientTrusted(
- java.security.cert.X509Certificate[] chain) {
- }
+ public void checkClientTrusted(java.security.cert.X509Certificate[] chain) {}
- public void checkClientTrusted(
- java.security.cert.X509Certificate[] chain, String s) {
- }
+ public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String s) {}
- public void checkServerTrusted(
- java.security.cert.X509Certificate[] chain) {
- }
+ public void checkServerTrusted(java.security.cert.X509Certificate[] chain) {}
- public void checkServerTrusted(
- java.security.cert.X509Certificate[] chain, String s) {
- }
- }
+ public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String s) {}
+ }
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/JhoveException.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/JhoveException.java
index 9f6a0e71d..965a2230a 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/JhoveException.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/JhoveException.java
@@ -1,20 +1,20 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment Copyright 2004 by JSTOR
- * and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2004 by JSTOR and the President and Fellows of Harvard College
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
public class JhoveException extends Exception {
- public JhoveException() {
- super();
- }
+ public JhoveException() {
+ super();
+ }
- public JhoveException(String message) {
- super(message);
- }
+ public JhoveException(String message) {
+ super(message);
+ }
- public JhoveException(String message, Throwable cause) {
- super(message, cause);
- }
+ public JhoveException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/MacStuff.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/MacStuff.java
index d6a40d7b3..fdaf0f8b5 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/MacStuff.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/MacStuff.java
@@ -1,88 +1,77 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003 by JSTOR and the President and Fellows of Harvard College
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
import java.io.*;
import java.lang.reflect.*;
-//import com.apple.eio.FileManager;
+// import com.apple.eio.FileManager;
/**
- * Code specific to Macintosh Java. This class consists of static
- * methods, and should not be instantiated. Its methods should be
- * called only on the Macintosh OS X platform. It requires the
+ * Code specific to Macintosh Java. This class consists of static methods, and should not be
+ * instantiated. Its methods should be called only on the Macintosh OS X platform. It requires the
* package {@code com.apple.eio.FileManager}.
*
* @author Gary McGath
*/
public class MacStuff {
- /** Private constructor to prevent instantiation.*/
- private MacStuff() {
- }
+ /** Private constructor to prevent instantiation. */
+ private MacStuff() {}
- /**
- * Determines if we're running on a Macintosh, so appropriate UI
- * adjustments can be made. In accordance with Apple's recommendations,
- * this checks for the existence of the {@code mrj.version} property
- * rather than checking the {@code os.name} property.
- */
- public static boolean isMacintosh() {
- return (System.getProperty("mrj.version") != null);
- }
+ /**
+ * Determines if we're running on a Macintosh, so appropriate UI adjustments can be made. In
+ * accordance with Apple's recommendations, this checks for the existence of the {@code
+ * mrj.version} property rather than checking the {@code os.name} property.
+ */
+ public static boolean isMacintosh() {
+ return (System.getProperty("mrj.version") != null);
+ }
- /**
- * Returns {@code true} if a file has the given file type.
- * This method uses {@code FileManager} in a dynamic way, so
- * that it will merely throw a {@code ClassNotFound} exception
- * if it fails.
- *
- * {@code
- * try {
- * if (sig.getType() == SignatureType.FILETYPE &&
- * MacStuff.isMacintosh()) {
- * if (!MacStuff.fileHasType(file, sig.getValueString())) {
- * info.setConsistent(false);
- * }
- * }
- * }
- * catch (ClassNotFoundException cnfe) {
- * // Mac classes missing -- can't check filetype.
- * }
- * }
- *
- */
- public static boolean fileHasType(File file, String type)
- throws ClassNotFoundException
- {
- // Need to make this completely dynamic.
- //return type.equals (FileManager.getFileType (file));
- try {
- if (type == null) {
- return false;
- }
- Class> fmClass = Class.forName("com.apple.eio.FileManager");
- Class>[] params = new Class[1];
- params[0] = Class.forName("java.io.File");
- Object[] args = new Object[1];
- args[0] = file;
- Method method = fmClass.getMethod("getFileType", params);
- String fType = (String) method.invoke(null, args);
- return (type.equals(fType));
- }
- catch (ClassNotFoundException cnfe) {
- throw cnfe;
- }
- catch (Exception e) {
- return false;
- }
+ /**
+ * Returns {@code true} if a file has the given file type. This method uses {@code FileManager} in
+ * a dynamic way, so that it will merely throw a {@code ClassNotFound} exception if it fails.
+ *
+ * {@code
+ * try {
+ * if (sig.getType() == SignatureType.FILETYPE &&
+ * MacStuff.isMacintosh()) {
+ * if (!MacStuff.fileHasType(file, sig.getValueString())) {
+ * info.setConsistent(false);
+ * }
+ * }
+ * }
+ * catch (ClassNotFoundException cnfe) {
+ * // Mac classes missing -- can't check filetype.
+ * }
+ * }
+ */
+ public static boolean fileHasType(File file, String type) throws ClassNotFoundException {
+ // Need to make this completely dynamic.
+ // return type.equals (FileManager.getFileType (file));
+ try {
+ if (type == null) {
+ return false;
+ }
+ Class> fmClass = Class.forName("com.apple.eio.FileManager");
+ Class>[] params = new Class[1];
+ params[0] = Class.forName("java.io.File");
+ Object[] args = new Object[1];
+ args[0] = file;
+ Method method = fmClass.getMethod("getFileType", params);
+ String fType = (String) method.invoke(null, args);
+ return (type.equals(fType));
+ } catch (ClassNotFoundException cnfe) {
+ throw cnfe;
+ } catch (Exception e) {
+ return false;
}
+ }
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Message.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Message.java
index 8e8f13090..cba3476d4 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Message.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/Message.java
@@ -1,217 +1,170 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003 by JSTOR and the President and Fellows of Harvard College
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
import edu.harvard.hul.ois.jhove.messages.JhoveMessage;
import edu.harvard.hul.ois.jhove.messages.JhoveMessages;
-/**
- * This class encapsulates a message to be displayed.
- */
+/** This class encapsulates a message to be displayed. */
public abstract class Message {
- /******************************************************************
- * PUBLIC CLASS FIELDS.
- ******************************************************************/
-
- /** Value indicating a null offset. */
- public static final long NULL = -1;
-
- /******************************************************************
- * PRIVATE INSTANCE FIELDS.
- ******************************************************************/
-
- protected final JhoveMessage message;
-
- /** Additional information. */
- protected final String _subMessage;
-
- /** Byte offset to which message applies. */
- protected final long _offset;
-
- /******************************************************************
- * CLASS CONSTRUCTOR.
- ******************************************************************/
-
- /**
- * Creates a Message with an unknown identifier for backward compatibility.
- * This constructor cannot be invoked directly, since Message is abstract.
- *
- * @param message
- * Human-readable message text.
- */
- protected Message(final String message) {
- this(JhoveMessages.getMessageInstance(JhoveMessages.NO_ID, message));
- }
-
- /**
- * Creates a Message with an identifier.
- * This constructor cannot be invoked directly, since Message is abstract.
- *
- * @param message
- * The message text and its identifier.
- */
- protected Message(final JhoveMessage message) {
- this(message, message.getSubMessage(), NULL);
- }
-
- /**
- * Creates a Message.
- * This constructor cannot be invoked directly,
- * since Message is abstract. The second argument
- * adds secondary details to the primary message;
- * the message will typically be displayed in the
- * form "message: subMessage".
- *
- * @param message
- * Human-readable message text.
- * @param subMessage
- * Human-readable additional information.
- */
- protected Message(final String message, final String subMessage) {
- this(JhoveMessages.getMessageInstance(JhoveMessages.NO_ID, message),
- subMessage);
- }
-
- /**
- * Creates a Message with an identifier.
- * This constructor cannot be invoked directly,
- * since Message is abstract. The second argument
- * adds secondary details to the primary message;
- * the message will typically be displayed in the
- * form "message: subMessage".
- *
- * @param message
- * The message text and its identifier.
- * @param subMessage
- * Human-readable additional information.
- */
- protected Message(final JhoveMessage message, final String subMessage) {
- this(message, subMessage, NULL);
- }
-
- /**
- * Creates a Message.
- * This constructor cannot be invoked directly,
- * since Message is abstract. The second argument
- * adds secondary details to the primary message;
- * the message will typically be displayed in the
- * form "message: subMessage".
- *
- * @param message
- * Human-readable message text.
- * @param offset
- * Byte offset associated with the message.
- */
- protected Message(final String message, final long offset) {
- this(JhoveMessages.getMessageInstance(JhoveMessages.NO_ID, message),
- offset);
- }
-
- /**
- * Creates a Message with an identifier.
- * This constructor cannot be invoked directly,
- * since Message is abstract. The second argument
- * adds secondary details to the primary message;
- * the message will typically be displayed in the
- * form "message: subMessage".
- *
- * @param message
- * The message text and its identifier.
- * @param offset
- * Byte offset associated with the message.
- */
- protected Message(final JhoveMessage message, final long offset) {
- this(message, message.getSubMessage(), offset);
- }
-
- /**
- * Creates a Message.
- * This constructor cannot be invoked directly,
- * since Message is abstract. The second argument
- * adds secondary details to the primary message;
- * the message will typically be displayed in the
- * form "message: subMessage".
- *
- * @param message
- * Human-readable message text.
- * @param subMessage
- * Human-readable additional information.
- * @param offset
- * Byte offset associated with the message.
- */
- protected Message(final String message, final String subMessage,
- final long offset) {
- this(JhoveMessages.getMessageInstance(JhoveMessages.NO_ID, message),
- subMessage, offset);
- }
-
- /**
- * Creates a Message with an identifier.
- * This constructor cannot be invoked directly,
- * since Message is abstract. The second argument
- * adds secondary details to the primary message;
- * the message will typically be displayed in the
- * form "message: subMessage".
- *
- * @param message
- * The message text and its identifier.
- * @param subMessage
- * Human-readable additional information.
- * @param offset
- * Byte offset associated with the message.
- */
- protected Message(final JhoveMessage message, String subMessage,
- long offset) {
- super();
- this.message = message;
- this._subMessage = (subMessage.isEmpty()) ? null : subMessage;
- this._offset = offset;
- }
-
- /******************************************************************
- * PUBLIC INSTANCE METHODS.
- *
- * Accessor methods.
- ******************************************************************/
-
- /**
- * Returns the message text.
- */
- public String getMessage() {
- return this.message.getMessage();
- }
-
- /**
- * Returns the submessage text.
- */
- public String getSubMessage() {
- return this._subMessage;
- }
-
- /**
- * Returns the offset to which this message is related.
- */
- public long getOffset() {
- return this._offset;
- }
-
- /**
- * Returns the message's identifier.
- */
- public String getId() {
- return this.message.getId();
- }
-
- public JhoveMessage getJhoveMessage() {
- return this.message;
- }
-
- @SuppressWarnings("static-method")
- public String getPrefix() {
- return "";
- }
+ /**
+ * **************************************************************** PUBLIC CLASS FIELDS.
+ * ****************************************************************
+ */
+
+ /** Value indicating a null offset. */
+ public static final long NULL = -1;
+
+ /**
+ * **************************************************************** PRIVATE INSTANCE FIELDS.
+ * ****************************************************************
+ */
+ protected final JhoveMessage message;
+
+ /** Additional information. */
+ protected final String _subMessage;
+
+ /** Byte offset to which message applies. */
+ protected final long _offset;
+
+ /**
+ * **************************************************************** CLASS CONSTRUCTOR.
+ * ****************************************************************
+ */
+
+ /**
+ * Creates a Message with an unknown identifier for backward compatibility. This constructor
+ * cannot be invoked directly, since Message is abstract.
+ *
+ * @param message Human-readable message text.
+ */
+ protected Message(final String message) {
+ this(JhoveMessages.getMessageInstance(JhoveMessages.NO_ID, message));
+ }
+
+ /**
+ * Creates a Message with an identifier. This constructor cannot be invoked directly, since
+ * Message is abstract.
+ *
+ * @param message The message text and its identifier.
+ */
+ protected Message(final JhoveMessage message) {
+ this(message, message.getSubMessage(), NULL);
+ }
+
+ /**
+ * Creates a Message. This constructor cannot be invoked directly, since Message is abstract. The
+ * second argument adds secondary details to the primary message; the message will typically be
+ * displayed in the form "message: subMessage".
+ *
+ * @param message Human-readable message text.
+ * @param subMessage Human-readable additional information.
+ */
+ protected Message(final String message, final String subMessage) {
+ this(JhoveMessages.getMessageInstance(JhoveMessages.NO_ID, message), subMessage);
+ }
+
+ /**
+ * Creates a Message with an identifier. This constructor cannot be invoked directly, since
+ * Message is abstract. The second argument adds secondary details to the primary message; the
+ * message will typically be displayed in the form "message: subMessage".
+ *
+ * @param message The message text and its identifier.
+ * @param subMessage Human-readable additional information.
+ */
+ protected Message(final JhoveMessage message, final String subMessage) {
+ this(message, subMessage, NULL);
+ }
+
+ /**
+ * Creates a Message. This constructor cannot be invoked directly, since Message is abstract. The
+ * second argument adds secondary details to the primary message; the message will typically be
+ * displayed in the form "message: subMessage".
+ *
+ * @param message Human-readable message text.
+ * @param offset Byte offset associated with the message.
+ */
+ protected Message(final String message, final long offset) {
+ this(JhoveMessages.getMessageInstance(JhoveMessages.NO_ID, message), offset);
+ }
+
+ /**
+ * Creates a Message with an identifier. This constructor cannot be invoked directly, since
+ * Message is abstract. The second argument adds secondary details to the primary message; the
+ * message will typically be displayed in the form "message: subMessage".
+ *
+ * @param message The message text and its identifier.
+ * @param offset Byte offset associated with the message.
+ */
+ protected Message(final JhoveMessage message, final long offset) {
+ this(message, message.getSubMessage(), offset);
+ }
+
+ /**
+ * Creates a Message. This constructor cannot be invoked directly, since Message is abstract. The
+ * second argument adds secondary details to the primary message; the message will typically be
+ * displayed in the form "message: subMessage".
+ *
+ * @param message Human-readable message text.
+ * @param subMessage Human-readable additional information.
+ * @param offset Byte offset associated with the message.
+ */
+ protected Message(final String message, final String subMessage, final long offset) {
+ this(JhoveMessages.getMessageInstance(JhoveMessages.NO_ID, message), subMessage, offset);
+ }
+
+ /**
+ * Creates a Message with an identifier. This constructor cannot be invoked directly, since
+ * Message is abstract. The second argument adds secondary details to the primary message; the
+ * message will typically be displayed in the form "message: subMessage".
+ *
+ * @param message The message text and its identifier.
+ * @param subMessage Human-readable additional information.
+ * @param offset Byte offset associated with the message.
+ */
+ protected Message(final JhoveMessage message, String subMessage, long offset) {
+ super();
+ this.message = message;
+ this._subMessage = (subMessage.isEmpty()) ? null : subMessage;
+ this._offset = offset;
+ }
+
+ /**
+ * **************************************************************** PUBLIC INSTANCE METHODS.
+ *
+ * Document
objects (one for each
- * specification document of the format). The specification
- * list is generated by the Module, and specifications cannot
- * be added by callers.
- *
- * @see Document
- */
- public Listtrue
if the module supports a given
- * named feature, and false
if the feature is
- * unsupported or unknown.
- */
- public boolean hasFeature (String feature);
-
- /**
- * Returns the full list of features.
- */
- public Listparse
are made
- * on the basis of a nonzero value being returned,
- * a new InputStream must be provided each time.
- *
- * @param info A fresh (on the first call) RepInfo object
- * which will be modified
- * to reflect the results of the parsing
- * If multiple calls to parse
are made
- * on the basis of a nonzero value being returned,
- * the same RepInfo object should be passed with each
- * call.
- *
- * @param parseIndex Must be 0 in first call to parse
. If
- * parse
returns a nonzero value, it must be
- * called again with parseIndex
- * equal to that return value.
- */
- public int parse (InputStream stream, RepInfo info, int parseIndex)
- throws IOException;
-
- /**
- * Parse the content of a random access digital object and store the
- * results in RepInfo.
- * A given Module will normally implement only one of the two
- * parse methods, leaving the other as a stub.
- *
- * @param file A RandomAccessFile, positioned at its beginning,
- * which is generated from the object to be parsed
- * @param info A fresh RepInfo object which will be modified
- * to reflect the results of the parsing
- */
- public void parse (RandomAccessFile file, RepInfo info)
- throws IOException;
-
- /**
- * Check if the digital object conforms to this Module's
- * internal signature information.
- *
- * @param file A File object for the object being parsed
- * @param stream An InputStream, positioned at its beginning,
- * which is generated from the object to be parsed
- * @param info A fresh RepInfo object which will be modified
- * to reflect the results of the test
- */
- public void checkSignatures (File file,
- InputStream stream,
- RepInfo info)
- throws IOException;
-
- /**
- * Check if the digital object conforms to this Module's
- * internal signature information.
- *
- * @param file A File object for the object being parsed
- * @param raf A RandomAccessFile, positioned at its beginning,
- * which is generated from the object to be parsed
- * @param info A fresh RepInfo object which will be modified
- * to reflect the results of the test
- */
- public void checkSignatures (File file,
- RandomAccessFile raf,
- RepInfo info)
- throws IOException;
-
- /**
- * Generates information about this Module.
- * The format of the output depends on the OutputHandler.
- */
- public void show (OutputHandler handler);
+public interface Module {
+ public static final int MAXIMUM_VERBOSITY = 1, MINIMUM_VERBOSITY = 2;
+
+ /**
+ * Per-instantiation initialization.
+ *
+ * @param init Initialization parameter. This is typically obtained from the configuration file.
+ */
+ public void init(String init) throws Exception;
+
+ /**
+ * Sets list of default parameters.
+ *
+ * @param params A List whose elements are Strings. May be empty.
+ */
+ public void setDefaultParams(ListDocument
objects (one for each specification document of the
+ * format). The specification list is generated by the Module, and specifications cannot be added
+ * by callers.
+ *
+ * @see Document
+ */
+ public Listtrue
if the module supports a given named feature, and false
+ * if the feature is unsupported or unknown.
+ */
+ public boolean hasFeature(String feature);
+
+ /** Returns the full list of features. */
+ public Listparse
are made on the basis of a nonzero
+ * value being returned, a new InputStream must be provided each time.
+ * @param info A fresh (on the first call) RepInfo object which will be modified to reflect the
+ * results of the parsing If multiple calls to parse
are made on the basis of a
+ * nonzero value being returned, the same RepInfo object should be passed with each call.
+ * @param parseIndex Must be 0 in first call to parse
. If parse
returns
+ * a nonzero value, it must be called again with parseIndex
equal to that return
+ * value.
+ */
+ public int parse(InputStream stream, RepInfo info, int parseIndex) throws IOException;
+
+ /**
+ * Parse the content of a random access digital object and store the results in RepInfo. A given
+ * Module will normally implement only one of the two parse methods, leaving the other as a stub.
+ *
+ * @param file A RandomAccessFile, positioned at its beginning, which is generated from the object
+ * to be parsed
+ * @param info A fresh RepInfo object which will be modified to reflect the results of the parsing
+ */
+ public void parse(RandomAccessFile file, RepInfo info) throws IOException;
+
+ /**
+ * Check if the digital object conforms to this Module's internal signature information.
+ *
+ * @param file A File object for the object being parsed
+ * @param stream An InputStream, positioned at its beginning, which is generated from the object
+ * to be parsed
+ * @param info A fresh RepInfo object which will be modified to reflect the results of the test
+ */
+ public void checkSignatures(File file, InputStream stream, RepInfo info) throws IOException;
+
+ /**
+ * Check if the digital object conforms to this Module's internal signature information.
+ *
+ * @param file A File object for the object being parsed
+ * @param raf A RandomAccessFile, positioned at its beginning, which is generated from the object
+ * to be parsed
+ * @param info A fresh RepInfo object which will be modified to reflect the results of the test
+ */
+ public void checkSignatures(File file, RandomAccessFile raf, RepInfo info) throws IOException;
+
+ /**
+ * Generates information about this Module. The format of the output depends on the OutputHandler.
+ */
+ public void show(OutputHandler handler);
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ModuleBase.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ModuleBase.java
index a9268d0e2..9a68a0e33 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ModuleBase.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ModuleBase.java
@@ -1,1478 +1,1286 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003-4 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003-4 by JSTOR and the President and Fellows of Harvard College
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
import java.io.*;
import java.security.*;
import java.util.*;
-import java.util.zip.*;
-
import java.util.logging.*;
+import java.util.zip.*;
/**
- * This class is an abstract implementation of the Module interface.
- * It contains all the methods required for a Module, but doesn't
- * do anything by itself. A subclass should provide a functional
- * implementation of {@code parse(InputStream, RepInfo, int)}
- * if it is not random access, or {@code parse(RandomAccessFile, RepInfo)}
- * if it is random access.
+ * This class is an abstract implementation of the Module interface. It contains all the methods
+ * required for a Module, but doesn't do anything by itself. A subclass should provide a functional
+ * implementation of {@code parse(InputStream, RepInfo, int)} if it is not random access, or {@code
+ * parse(RandomAccessFile, RepInfo)} if it is random access.
*/
public abstract class ModuleBase implements Module {
- /******************************************************************
- * PROTECTED INSTANCE FIELDS.
- ******************************************************************/
-
- /** The application object */
- protected App _app;
- /** Coverage information */
- protected String _coverage;
- /** Module last modification date */
- protected Date _date;
- /** Formats recognized by this Module */
- protected String[] _format;
- /** Initialization value. */
- protected String _init;
- /** List of default parameters. */
- protected final List
- *
- */
- public void initFeatures() {
- _features = new ArrayList<>(2);
- _features.add("edu.harvard.hul.ois.jhove.canValidate");
- _features.add("edu.harvard.hul.ois.jhove.canCharacterize");
- }
-
- /**
- * Per-instantiation initialization.
- * The default method does nothing but save its parameter.
- */
- @Override
- public void init(String init) {
- _init = init;
- }
-
- /**
- * Set a a List of default parameters for the module.
- *
- * @param params
- * A List whose elements are Strings.
- * May be empty.
- */
- @Override
- public void setDefaultParams(Listtrue
if the dominant "endianness" of the
- * module, or the current file being processed,
- * is big-endian, otherwise false. This does not guarantee
- * that all numbers in the module follow the dominant endianness,
- * particularly as formats sometimes incorporate data stored in
- * a previously defined format. For some formats, e.g., TIFF, the
- * endianness depends on the file being processed.
- *
- * Every module must initialize the value of _bigEndian for this
- * function, or else assign its value when parsing a file,
- * to return a meaningful result. For some modules (e.g.,
- * ASCII, endianness has no meaning.
- */
- public boolean isBigEndian() {
- return _bigEndian;
- }
-
- /**
- * Return details as to the specific format versions or
- * variants that are supported by this module
- */
- @Override
- public final String getCoverage() {
- return _coverage;
- }
-
- /**
- * Return the last modification date of this Module, as a
- * Java Date object
- */
- @Override
- public final Date getDate() {
- return _date;
- }
-
- /**
- * Return the array of format names supported by this Module
- */
- @Override
- public final String[] getFormat() {
- return _format;
- }
-
- /**
- * Return the array of MIME type strings for formats supported
- * by this Module
- */
- @Override
- public final String[] getMimeType() {
- return _mimeType;
- }
-
- /**
- * Return the module name
- */
- @Override
- public final String getName() {
- return _name;
- }
-
- /**
- * Return the module note
- */
- @Override
- public final String getNote() {
- return _note;
- }
-
- /**
- * Return the release identifier
- */
- @Override
- public final String getRelease() {
- return _release;
- }
-
- /**
- * Return the RepInfo note
- */
- @Override
- public final String getRepInfoNote() {
- return _repInfoNote;
- }
-
- /**
- * Return the copyright information string
- */
- @Override
- public final String getRights() {
- return _rights;
- }
-
- /**
- * Return the List of Signatures recognized by this Module
- */
- @Override
- public final ListDocument
objects (one for each
- * specification document of the format). The specification
- * list is generated by the Module, and specifications cannot
- * be added by callers.
- *
- * @see Document
- */
- @Override
- public final Listtrue
if the module supports a given
- * named feature, and false
if the feature is
- * unsupported or unknown. Feature names are case sensitive.
- *
- * It is recommended that features be named using package
- * nomenclature. The following features are, by default,
- * supported by the modules developed by OIS:
- *
- *
- *
- */
- @Override
- public boolean hasFeature(String feature) {
- if (_features == null) {
- // dubious, but check it
- return false;
- }
- Iteratorparam
can override the verbosity setting.
- * It does not affect whether raw data are reported or not, only
- * which data are reported.
- *
- *
- * @param verbosity
- * The requested verbosity value. Recognized
- * values are Module.MINIMUM_VERBOSITY and
- * Module.MAXIMUM_VERBOSITY.
- * The interpretation of the value depends on the module, and
- * the module may choose not to use this setting. However,
- * modules should treat MAXIMUM_VERBOSITY as a request for
- * all the data available from the module.
- */
- @Override
- public void setVerbosity(int verbosity) {
- _verbosity = verbosity;
- }
-
- /**
- * Sets the byte count for the content object, and sets
- * the checksumFinished flag.
- */
- public final void setNByte(long nByte) {
- _nByte = nByte;
- _checksumFinished = true;
- }
-
- /**
- * Sets the MD5 calculated digest for the content object, and sets
- * the checksumFinished flag.
- */
- public final void setMD5(MessageDigest md5) {
- _md5 = md5;
- _checksumFinished = true;
- }
-
- /**
- * Sets the SHA-1 calculated digest for the content object, and sets
- * the checksumFinished flag.
- */
- public final void setSHA1(MessageDigest sha1) {
- _sha1 = sha1;
- _checksumFinished = true;
- }
-
-
- /**
- * Sets the SHA-256 calculated digest for the content object, and sets
- * the checksumFinished flag.
- */
- public final void setSHA256(MessageDigest sha256) {
- _sha256 = sha256;
- _checksumFinished = true;
- }
-
- /******************************************************************
- * Parsing methods.
- ******************************************************************/
-
- /**
- * Parse the content of a stream digital object and store the
- * results in RepInfo.
- * A given Module will normally override only one of the two
- * parse methods; the default method does nothing.
- *
- * @param stream
- * An InputStream, positioned at its beginning,
- * which is generated from the object to be parsed.
- * If multiple calls to parse
are made
- * on the basis of a nonzero value being returned,
- * a new InputStream must be provided each time.
- *
- * @param info
- * A fresh (on the first call) RepInfo object
- * which will be modified
- * to reflect the results of the parsing
- * If multiple calls to parse
are made
- * on the basis of a nonzero value being returned,
- * the same RepInfo object should be passed with each
- * call.
- *
- * @param parseIndex
- * Must be 0 in first call to parse
. If
- * parse
returns a nonzero value, it must be
- * called again with parseIndex
- * equal to that return value.
- */
- @SuppressWarnings("unused")
- @Override
- public int parse(InputStream stream, RepInfo info, int parseIndex)
- throws IOException {
- return 0;
- }
-
- /**
- * Parse the content of a random access digital object and store the
- * results in RepInfo.
- * A given Module will normally override only one of the two
- * parse methods; the default method does nothing.
- *
- * @param file
- * A RandomAccessFile, positioned at its beginning,
- * which is generated from the object to be parsed
- * @param info
- * A fresh RepInfo object which will be modified
- * to reflect the results of the parsing
- */
- @SuppressWarnings("unused")
- @Override
- public void parse(RandomAccessFile file, RepInfo info) throws IOException {
- }
-
- /**
- * Check if the digital object conforms to this Module's
- * internal signature information.
- * This function checks the file against the list of predefined
- * signatures for the module. If there are no predefined
- * signatures, it calls parse with the arguments passed to it.
- * Override this for modules that check digital signatures in
- * some other way. Any module for which the signature may be located
- * other than at the beginning of the file must override.
- *
- * @param file
- * A File object for the object being parsed
- * @param stream
- * An InputStream, positioned at its beginning,
- * which is generated from the object to be parsed
- * @param info
- * A fresh RepInfo object which will be modified
- * to reflect the results of the test
- */
- @Override
- public void checkSignatures(File file, InputStream stream, RepInfo info)
- throws IOException {
- info.setFormat(_format[0]);
- info.setMimeType(_mimeType[0]);
- info.setModule(this);
- int sigsChecked = 0;
- if (_signature.size() > 0) {
- /*
- * Get each of the internal sigs defined for the module
- * and test it. All sigs must be present. If there are
- * no internal signatures, this test is meaningless.
- */
- byte[] sigBuf = new byte[1024];
- stream.read(sigBuf);
- stream.close();
- ListIteratorlabels
and
- * index
are unused. Otherwise,
- * returns a STRING property, with the
- * string being the element of labels
- * whose index is the index of
- * value
in index
.
- */
- public Property addIntegerProperty(String name, int value, String[] labels,
- int[] index) {
- boolean rawOutput = _je.getShowRawFlag();
- Property prop = null;
- if (!rawOutput) {
- int n = -1;
- for (int i = 0; i < index.length; i++) {
- if (value == index[i]) {
- n = i;
- break;
- }
- }
- if (n > -1) {
- prop = new Property(name, PropertyType.STRING, labels[n]);
- }
- }
- if (prop == null) {
- prop = new Property(name, PropertyType.INTEGER, new Integer(value));
- }
-
- return prop;
- }
-
- /**
- * Returns a Property representing an integer value.
- * If raw output is specified for the module, returns
- * an INTEGER property, and labels
and
- * index
are unused. Otherwise,
- * returns a STRING property, with the
- * string being the element of labels
- * whose index is value
.
- */
- public Property addIntegerProperty(String name, int value,
- String[] labels) {
- if (!_je.getShowRawFlag()) {
- try {
- return new Property(name, PropertyType.STRING, labels[value]);
- } catch (Exception e) {
- // fall through
- }
- }
- return new Property(name, PropertyType.INTEGER, new Integer(value));
- }
-
- /**
- * Reads an unsigned byte from a DataInputStream.
- *
- * @param stream
- * Stream to read
- */
- public static int readUnsignedByte(DataInputStream stream)
- throws IOException {
- return readUnsignedByte(stream, null);
- }
-
- /**
- * Reads an unsigned byte from a DataInputStream.
- *
- * @param stream
- * Stream to read
- * @param counted
- * If non-null, module for which value of _nByte
- * shall be incremented appropriately
- */
- public static int readUnsignedByte(DataInputStream stream,
- ModuleBase counted) throws IOException {
- int val = stream.readUnsignedByte();
- if (counted != null) {
- counted._nByte++;
- }
- return val;
- }
-
- /**
- * Reads an unsigned byte from a RandomAccessFile.
- */
- public static int readUnsignedByte(RandomAccessFile file)
- throws IOException {
- return file.readUnsignedByte();
- }
-
- /**
- * Reads into a byte buffer from a DataInputStream.
- *
- * @param stream
- * Stream to read from
- * @param buf
- * Byte buffer to fill up
- * @param counted
- * If non-null, module for which value of _nByte
- * shall be incremented appropriately
- */
- public static int readByteBuf(DataInputStream stream, byte[] buf,
- ModuleBase counted) throws IOException {
- int bytesRead = stream.read(buf);
- if (counted != null && bytesRead > 0) {
- counted._nByte += bytesRead;
- }
- return bytesRead;
- }
-
- /**
- * Reads two bytes as an unsigned short value from a DataInputStream.
- *
- * @param stream
- * The stream to read from.
- * @param bigEndian
- * If true, interpret the first byte as the high
- * byte, otherwise interpret the first byte as
- * the low byte.
- */
- public static int readUnsignedShort(DataInputStream stream,
- boolean bigEndian) throws IOException {
- return readUnsignedShort(stream, bigEndian, null);
- }
-
- /**
- * Reads two bytes as an unsigned short value from a DataInputStream.
- *
- * @param stream
- * The stream to read from.
- * @param bigEndian
- * If true, interpret the first byte as the high
- * byte, otherwise interpret the first byte as
- * the low byte.
- */
- public static int readUnsignedShort(DataInputStream stream,
- boolean bigEndian, ModuleBase counted) throws IOException {
- int n = 0;
- if (bigEndian) {
- n = stream.readUnsignedShort();
- } else {
- int b1 = stream.readUnsignedByte();
- int b0 = stream.readUnsignedByte();
- n = (b0 << 8) | b1;
- }
- if (counted != null) {
- counted._nByte += 2;
- }
- return n;
- }
-
- /**
- * Reads two bytes as an unsigned short value from a
- * RandomAccessFile.
- *
- * @param file
- * The file to read from.
- * @param bigEndian
- * If true, interpret the first byte as the high
- * byte, otherwise interpret the first byte as
- * the low byte.
- */
- public static int readUnsignedShort(RandomAccessFile file,
- boolean bigEndian) throws IOException {
- int n = 0;
- if (bigEndian) {
- n = file.readUnsignedShort();
- } else {
- int b1 = file.readUnsignedByte();
- int b0 = file.readUnsignedByte();
- n = (b0 << 8) | b1;
- }
- return n;
- }
-
- /**
- * Reads four bytes as an unsigned 32-bit value from a
- * DataInputStream.
- *
- * @param stream
- * The stream to read from.
- * @param bigEndian
- * If true, interpret the first byte as the high
- * byte, otherwise interpret the first byte as
- * the low byte.
- */
- public static long readUnsignedInt(DataInputStream stream,
- boolean bigEndian) throws IOException {
- return readUnsignedInt(stream, bigEndian, null);
- }
-
- /**
- * Reads four bytes as an unsigned 32-bit value from a
- * DataInputStream.
- *
- * @param stream
- * The stream to read from.
- * @param bigEndian
- * If true, interpret the first byte as the high
- * byte, otherwise interpret the first byte as
- * the low byte.
- */
- public static long readUnsignedInt(DataInputStream stream,
- boolean bigEndian, ModuleBase counted) throws IOException {
- long n = 0;
- if (bigEndian) {
- n = stream.readInt(); /* This is a signed value. */
- if (n < 0) {
- // n = 2147483648L + n;
- n = n & 0XFFFFFFFFL;
- }
- } else {
- long b3 = stream.readUnsignedByte();
- long b2 = stream.readUnsignedByte();
- long b1 = stream.readUnsignedByte();
- long b0 = stream.readUnsignedByte();
- n = (b0 << 24) | (b1 << 16) | (b2 << 8) | b3;
- }
- if (counted != null) {
- counted._nByte += 4;
- }
- return n;
- }
-
- /**
- * Reads four bytes as an unsigned 32-bit value from a
- * RandomAccessFile.
- *
- * @param file
- * The file to read from.
- * @param bigEndian
- * If true, interpret the first byte as the high
- * byte, otherwise interpret the first byte as
- * the low byte.
- */
- public static long readUnsignedInt(RandomAccessFile file, boolean bigEndian)
- throws IOException {
- long n = 0;
- if (bigEndian) {
- n = file.readInt(); /* This is a signed value. */
- if (n < 0) {
- // n = 2147483648L + n;
- n = n & 0XFFFFFFFFL;
- }
- } else {
- // For efficiency, do one read rather than four
- byte buf[] = new byte[4];
- file.read(buf);
- long b3 = buf[0] & 0XFFL;
- long b2 = buf[1] & 0XFFL;
- long b1 = buf[2] & 0XFFL;
- long b0 = buf[3] & 0XFFL;
- n = (b0 << 24) | (b1 << 16) | (b2 << 8) | b3;
- }
- return n;
- }
-
- /**
- * Reads eight bytes as a signed 64-bit value from a DataInputStream.
- *
- * @param stream
- * The stream to read from.
- * @param bigEndian
- * If true, interpret the first byte as the high
- * byte, otherwise interpret the first byte as
- * the low byte.
- */
- public static long readSignedLong(DataInputStream stream, boolean bigEndian,
- ModuleBase counted) throws IOException {
- long n = 0;
- if (bigEndian) {
- n = stream.readLong(); /* This is a signed value. */
- } else {
- long b7 = stream.readUnsignedByte();
- long b6 = stream.readUnsignedByte();
- long b5 = stream.readUnsignedByte();
- long b4 = stream.readUnsignedByte();
- long b3 = stream.readUnsignedByte();
- long b2 = stream.readUnsignedByte();
- long b1 = stream.readUnsignedByte();
- long b0 = stream.readUnsignedByte();
- n = (b0 << 56) | (b1 << 48) | (b2 << 40) | (b3 << 32) | (b4 << 24)
- | (b5 << 16) | (b6 << 8) | b7;
- }
- if (counted != null) {
- counted._nByte += 8;
- }
- return n;
- }
-
- public static Rational readUnsignedRational(DataInputStream stream,
- boolean endian) throws IOException {
- return readUnsignedRational(stream, endian, null);
- }
-
- public static Rational readUnsignedRational(DataInputStream stream,
- boolean endian, ModuleBase counted) throws IOException {
- long n = readUnsignedInt(stream, endian, counted);
- long d = readUnsignedInt(stream, endian, counted);
- return new Rational(n, d);
- }
-
- public static Rational readUnsignedRational(RandomAccessFile file,
- boolean endian) throws IOException {
- long n = readUnsignedInt(file, endian);
- long d = readUnsignedInt(file, endian);
- return new Rational(n, d);
- }
-
- public static Rational readSignedRational(DataInputStream stream,
- boolean endian, ModuleBase counted) throws IOException {
- long n = readSignedInt(stream, endian, counted);
- long d = readSignedInt(stream, endian, counted);
- return new Rational(n, d);
- }
-
- public static Rational readSignedRational(RandomAccessFile file,
- boolean endian) throws IOException {
- long n = readSignedInt(file, endian);
- long d = readSignedInt(file, endian);
- return new Rational(n, d);
- }
-
- public static int readSignedByte(RandomAccessFile file) throws IOException {
- return file.readByte();
- }
-
- public static int readSignedShort(RandomAccessFile file, boolean endian)
- throws IOException {
- int b = readUnsignedShort(file, endian);
- if ((b & 0X8000) != 0) {
- b |= ~0XFFFF;
- }
- return b;
- }
-
- public static int readSignedInt(RandomAccessFile file, boolean endian)
- throws IOException {
- long b = readUnsignedInt(file, endian);
- if ((b & 0X80000000L) != 0) {
- b |= ~0XFFFFFFFFL;
- }
- return (int) b;
- }
-
- public static int readSignedByte(DataInputStream stream)
- throws IOException {
- return readSignedByte(stream, null);
- }
-
- public static int readSignedByte(DataInputStream stream, ModuleBase counted)
- throws IOException {
- int val = stream.readByte();
- if (counted != null) {
- counted._nByte++;
- }
- return val;
- }
-
- public static int readSignedShort(DataInputStream stream, boolean endian)
- throws IOException {
- return readSignedShort(stream, endian, null);
- }
-
- public static int readSignedShort(DataInputStream stream, boolean endian,
- ModuleBase counted) throws IOException {
- int b = readUnsignedShort(stream, endian, counted);
- if ((b & 0X8000) != 0) {
- b |= ~0XFFFF;
- }
- return b;
- }
-
- public static int readSignedInt(DataInputStream stream, boolean endian)
- throws IOException {
- return readSignedInt(stream, endian, null);
- }
-
- public static int readSignedInt(DataInputStream stream, boolean endian,
- ModuleBase counted) throws IOException {
- long b = readUnsignedInt(stream, endian, counted);
- if ((b & 0X80000000L) != 0) {
- b |= ~0XFFFFFFFFL;
- }
- return (int) b;
- }
-
- public static float readFloat(RandomAccessFile file, boolean endian)
- throws IOException {
- float f = 0.0F;
- if (endian) {
- f = file.readFloat();
- } else {
- // For efficiency, do one read rather than four
- byte buf[] = new byte[4];
- file.read(buf);
- int b3 = buf[0] & 0XFF;
- int b2 = buf[1] & 0XFF;
- int b1 = buf[2] & 0XFF;
- int b0 = buf[3] & 0XFF;
- f = Float.intBitsToFloat(b0 << 24 | b1 << 16 | b2 << 8 | b3);
- }
- return f;
- }
-
- public static float readFloat(DataInputStream stream, boolean endian,
- ModuleBase counted) throws IOException {
- float f = 0.0F;
- if (endian) {
- f = stream.readFloat();
- } else {
- int b3 = stream.readUnsignedByte();
- int b2 = stream.readUnsignedByte();
- int b1 = stream.readUnsignedByte();
- int b0 = stream.readUnsignedByte();
- f = Float.intBitsToFloat(b0 << 24 | b1 << 16 | b2 << 8 | b3);
- }
- if (counted != null) {
- counted._nByte += 4;
- }
- return f;
- }
-
- public static double readDouble(RandomAccessFile file, boolean endian)
- throws IOException {
- double f = 0.0F;
- if (endian) {
- f = file.readDouble();
- } else {
- // For efficiency, do one read rather than eight
- byte buf[] = new byte[8];
- file.read(buf);
- long b7 = buf[0] & 0XFFL;
- long b6 = buf[1] & 0XFFL;
- long b5 = buf[2] & 0XFFL;
- long b4 = buf[3] & 0XFFL;
- long b3 = buf[4] & 0XFFL;
- long b2 = buf[5] & 0XFFL;
- long b1 = buf[6] & 0XFFL;
- long b0 = buf[7] & 0XFFL;
-
- f = Double.longBitsToDouble(b0 << 56 | b1 << 48 | b2 << 40
- | b3 << 32 | b4 << 24 | b5 << 16 | b6 << 8 | b7);
- }
- return f;
- }
-
- public static double readDouble(DataInputStream stream, boolean endian)
- throws IOException {
- return readDouble(stream, endian, null);
- }
-
- public static double readDouble(DataInputStream stream, boolean endian,
- ModuleBase counted) throws IOException {
- double f = 0.0F;
- if (endian) {
- f = stream.readDouble();
- } else {
- long b7 = stream.readUnsignedByte();
- long b6 = stream.readUnsignedByte();
- long b5 = stream.readUnsignedByte();
- long b4 = stream.readUnsignedByte();
- long b3 = stream.readUnsignedByte();
- long b2 = stream.readUnsignedByte();
- long b1 = stream.readUnsignedByte();
- long b0 = stream.readUnsignedByte();
- f = Double.longBitsToDouble(b0 << 56 | b1 << 48 | b2 << 40
- | b3 << 32 | b4 << 24 | b5 << 16 | b6 << 8 | b7);
- }
- if (counted != null) {
- counted._nByte += 8;
- }
- return f;
- }
-
- /** Skip over some bytes. Return number of bytes skipped. */
- public long skipBytes(DataInputStream stream, long bytesToSkip)
- throws IOException {
- return skipBytes(stream, bytesToSkip, null);
- }
-
- /** Skip over some bytes. Return number of bytes skipped. */
- public long skipBytes(DataInputStream stream, long bytesToSkip,
- ModuleBase counted) throws IOException {
- long totalBytesSkipped = 0;
- while (bytesToSkip > 0) {
- long bytesSkipped;
- long availableBytes = stream.available();
- if (availableBytes == 0)
- break;
- // The count of skipped bytes returned by FileInputStream's 'skip'
- // method is unreliable and may be greater than what was available
- // to skip. So we need to monitor and correct any discrepancies
- // ourselves. Luckily the 'available' method seems to accurately
- // report the number of bytes available to be skipped, but because
- // it returns an int, we're limited to skipping Integer.MAX_VALUE
- // each call lest we skip more bytes than we can verify.
- if (bytesToSkip > availableBytes) {
- bytesSkipped = stream.skip(availableBytes);
- } else {
- bytesSkipped = stream.skip(bytesToSkip);
- }
- // If it reports skipping more bytes than were available,
- // correct it to the most it could have skipped.
- if (bytesSkipped > availableBytes) {
- bytesSkipped = availableBytes;
- }
- totalBytesSkipped += bytesSkipped;
- bytesToSkip -= bytesSkipped;
- }
- if (counted != null) {
- counted._nByte += totalBytesSkipped;
- }
- return totalBytesSkipped;
- }
-
- /**
- * A convenience method for getting a buffered DataInputStream
- * from a module's InputStream. If the size specified is 0 or
- * less, the default buffer size is used.
- */
- public static DataInputStream getBufferedDataStream(InputStream stream,
- int size) {
- BufferedInputStream bis;
- if (size <= 0) {
- bis = new BufferedInputStream(stream);
- } else {
- bis = new BufferedInputStream(stream, size);
- }
- return new DataInputStream(bis);
- }
-
- /**
- * A utility for converting a Vector of Properties to an
- * Array. It can be simpler to build a Vector and then
- * call VectorToPropArray than to allocate an array and
- * drop all the Properites into the correct indices.
- * All the members of the Vector must be of type Property,
- * or a ClassCastException will be thrown.
- */
- protected Property[] vectorToPropArray(Vector vec) {
- Property[] prop = new Property[vec.size()];
- for (int i = 0; i < vec.size(); i++) {
- prop[i] = (Property) vec.elementAt(i);
- }
- return prop;
- }
-
- protected void setupDataStream(final InputStream stream,
- final RepInfo info) {
- /*
- * Are checksums requested and ensure they're not already calculated
- * when handling a temp file.
- */
- if (_je.getChecksumFlag() && info.getChecksum().isEmpty()) {
- _ckSummer = new Checksummer();
- _cstream = new ChecksumInputStream(stream, _ckSummer);
- _dstream = getBufferedDataStream(_cstream,
- _app != null ? _je.getBufferSize() : 0);
- } else {
- _dstream = getBufferedDataStream(stream,
- _app != null ? _je.getBufferSize() : 0);
- }
- }
-
- protected void checksumIfRafNotCopied(final RepInfo info,
- final RandomAccessFile raf) throws IOException {
- /*
- * We may have already done the checksums while converting a
- * temporary file.
- */
- _ckSummer = null;
- if (_je != null && _je.getChecksumFlag()
- && info.getChecksum().isEmpty()) {
- _ckSummer = new Checksummer();
- calcRAChecksum(_ckSummer, raf);
- setChecksums(_ckSummer, info);
- }
- }
-
- protected boolean isParamInDefaults(final String paramVal) {
- if (paramVal == null)
- return false;
- for (String param : _defaultParams) {
- if (paramVal.equalsIgnoreCase(param)) {
- return true;
- }
- }
- return false;
- }
-
- protected void skipDstreamToEnd(final RepInfo info) {
- /*
- * We may not have actually hit the end of file. If we're calculating
- * checksums on the fly, we have to read and discard whatever is
- * left, so it will get checksummed.
- */
- for (;;) {
- try {
- long n = skipBytes(_dstream, 2048, this);
- if (n == 0) {
- break;
- }
- } catch (Exception e) {
- break;
- }
- }
- info.setSize(_cstream.getNBytes());
- }
+ /**
+ * **************************************************************** PROTECTED INSTANCE FIELDS.
+ * ****************************************************************
+ */
+
+ /** The application object */
+ protected App _app;
+ /** Coverage information */
+ protected String _coverage;
+ /** Module last modification date */
+ protected Date _date;
+ /** Formats recognized by this Module */
+ protected String[] _format;
+ /** Initialization value. */
+ protected String _init;
+ /** List of default parameters. */
+ protected final List
+ *
+ */
+ public void initFeatures() {
+ _features = new ArrayList<>(2);
+ _features.add("edu.harvard.hul.ois.jhove.canValidate");
+ _features.add("edu.harvard.hul.ois.jhove.canCharacterize");
+ }
+
+ /** Per-instantiation initialization. The default method does nothing but save its parameter. */
+ @Override
+ public void init(String init) {
+ _init = init;
+ }
+
+ /**
+ * Set a a List of default parameters for the module.
+ *
+ * @param params A List whose elements are Strings. May be empty.
+ */
+ @Override
+ public void setDefaultParams(Listtrue
if the dominant "endianness" of the module, or the current file being
+ * processed, is big-endian, otherwise false. This does not guarantee that all numbers in the
+ * module follow the dominant endianness, particularly as formats sometimes incorporate data
+ * stored in a previously defined format. For some formats, e.g., TIFF, the endianness depends on
+ * the file being processed.
+ *
+ * Document
objects (one for each specification document of the
+ * format). The specification list is generated by the Module, and specifications cannot be added
+ * by callers.
+ *
+ * @see Document
+ */
+ @Override
+ public final Listtrue
if the module supports a given named feature, and false
+ * if the feature is unsupported or unknown. Feature names are case sensitive.
+ *
+ *
+ *
+ */
+ @Override
+ public boolean hasFeature(String feature) {
+ if (_features == null) {
+ // dubious, but check it
+ return false;
+ }
+ Iteratorparam
can
+ * override the verbosity setting. It does not affect whether raw data are reported or not, only
+ * which data are reported.
+ *
+ * @param verbosity The requested verbosity value. Recognized values are Module.MINIMUM_VERBOSITY
+ * and Module.MAXIMUM_VERBOSITY. The interpretation of the value depends on the module, and
+ * the module may choose not to use this setting. However, modules should treat
+ * MAXIMUM_VERBOSITY as a request for all the data available from the module.
+ */
+ @Override
+ public void setVerbosity(int verbosity) {
+ _verbosity = verbosity;
+ }
+
+ /** Sets the byte count for the content object, and sets the checksumFinished flag. */
+ public final void setNByte(long nByte) {
+ _nByte = nByte;
+ _checksumFinished = true;
+ }
+
+ /** Sets the MD5 calculated digest for the content object, and sets the checksumFinished flag. */
+ public final void setMD5(MessageDigest md5) {
+ _md5 = md5;
+ _checksumFinished = true;
+ }
+
+ /**
+ * Sets the SHA-1 calculated digest for the content object, and sets the checksumFinished flag.
+ */
+ public final void setSHA1(MessageDigest sha1) {
+ _sha1 = sha1;
+ _checksumFinished = true;
+ }
+
+ /**
+ * Sets the SHA-256 calculated digest for the content object, and sets the checksumFinished flag.
+ */
+ public final void setSHA256(MessageDigest sha256) {
+ _sha256 = sha256;
+ _checksumFinished = true;
+ }
+
+ /**
+ * **************************************************************** Parsing methods.
+ * ****************************************************************
+ */
+
+ /**
+ * Parse the content of a stream digital object and store the results in RepInfo. A given Module
+ * will normally override only one of the two parse methods; the default method does nothing.
+ *
+ * @param stream An InputStream, positioned at its beginning, which is generated from the object
+ * to be parsed. If multiple calls to parse
are made on the basis of a nonzero
+ * value being returned, a new InputStream must be provided each time.
+ * @param info A fresh (on the first call) RepInfo object which will be modified to reflect the
+ * results of the parsing If multiple calls to parse
are made on the basis of a
+ * nonzero value being returned, the same RepInfo object should be passed with each call.
+ * @param parseIndex Must be 0 in first call to parse
. If parse
returns
+ * a nonzero value, it must be called again with parseIndex
equal to that return
+ * value.
+ */
+ @SuppressWarnings("unused")
+ @Override
+ public int parse(InputStream stream, RepInfo info, int parseIndex) throws IOException {
+ return 0;
+ }
+
+ /**
+ * Parse the content of a random access digital object and store the results in RepInfo. A given
+ * Module will normally override only one of the two parse methods; the default method does
+ * nothing.
+ *
+ * @param file A RandomAccessFile, positioned at its beginning, which is generated from the object
+ * to be parsed
+ * @param info A fresh RepInfo object which will be modified to reflect the results of the parsing
+ */
+ @SuppressWarnings("unused")
+ @Override
+ public void parse(RandomAccessFile file, RepInfo info) throws IOException {}
+
+ /**
+ * Check if the digital object conforms to this Module's internal signature information. This
+ * function checks the file against the list of predefined signatures for the module. If there are
+ * no predefined signatures, it calls parse with the arguments passed to it. Override this for
+ * modules that check digital signatures in some other way. Any module for which the signature may
+ * be located other than at the beginning of the file must override.
+ *
+ * @param file A File object for the object being parsed
+ * @param stream An InputStream, positioned at its beginning, which is generated from the object
+ * to be parsed
+ * @param info A fresh RepInfo object which will be modified to reflect the results of the test
+ */
+ @Override
+ public void checkSignatures(File file, InputStream stream, RepInfo info) throws IOException {
+ info.setFormat(_format[0]);
+ info.setMimeType(_mimeType[0]);
+ info.setModule(this);
+ int sigsChecked = 0;
+ if (_signature.size() > 0) {
+ /*
+ * Get each of the internal sigs defined for the module
+ * and test it. All sigs must be present. If there are
+ * no internal signatures, this test is meaningless.
+ */
+ byte[] sigBuf = new byte[1024];
+ stream.read(sigBuf);
+ stream.close();
+ ListIteratorlabels
and index
are unused.
+ * Otherwise, returns a STRING property, with the string being the element of labels
+ * whose index is the index of value
in index
.
+ */
+ public Property addIntegerProperty(String name, int value, String[] labels, int[] index) {
+ boolean rawOutput = _je.getShowRawFlag();
+ Property prop = null;
+ if (!rawOutput) {
+ int n = -1;
+ for (int i = 0; i < index.length; i++) {
+ if (value == index[i]) {
+ n = i;
+ break;
+ }
+ }
+ if (n > -1) {
+ prop = new Property(name, PropertyType.STRING, labels[n]);
+ }
+ }
+ if (prop == null) {
+ prop = new Property(name, PropertyType.INTEGER, new Integer(value));
+ }
+
+ return prop;
+ }
+
+ /**
+ * Returns a Property representing an integer value. If raw output is specified for the module,
+ * returns an INTEGER property, and labels
and index
are unused.
+ * Otherwise, returns a STRING property, with the string being the element of labels
+ * whose index is value
.
+ */
+ public Property addIntegerProperty(String name, int value, String[] labels) {
+ if (!_je.getShowRawFlag()) {
+ try {
+ return new Property(name, PropertyType.STRING, labels[value]);
+ } catch (Exception e) {
+ // fall through
+ }
+ }
+ return new Property(name, PropertyType.INTEGER, new Integer(value));
+ }
+
+ /**
+ * Reads an unsigned byte from a DataInputStream.
+ *
+ * @param stream Stream to read
+ */
+ public static int readUnsignedByte(DataInputStream stream) throws IOException {
+ return readUnsignedByte(stream, null);
+ }
+
+ /**
+ * Reads an unsigned byte from a DataInputStream.
+ *
+ * @param stream Stream to read
+ * @param counted If non-null, module for which value of _nByte shall be incremented appropriately
+ */
+ public static int readUnsignedByte(DataInputStream stream, ModuleBase counted)
+ throws IOException {
+ int val = stream.readUnsignedByte();
+ if (counted != null) {
+ counted._nByte++;
+ }
+ return val;
+ }
+
+ /** Reads an unsigned byte from a RandomAccessFile. */
+ public static int readUnsignedByte(RandomAccessFile file) throws IOException {
+ return file.readUnsignedByte();
+ }
+
+ /**
+ * Reads into a byte buffer from a DataInputStream.
+ *
+ * @param stream Stream to read from
+ * @param buf Byte buffer to fill up
+ * @param counted If non-null, module for which value of _nByte shall be incremented appropriately
+ */
+ public static int readByteBuf(DataInputStream stream, byte[] buf, ModuleBase counted)
+ throws IOException {
+ int bytesRead = stream.read(buf);
+ if (counted != null && bytesRead > 0) {
+ counted._nByte += bytesRead;
+ }
+ return bytesRead;
+ }
+
+ /**
+ * Reads two bytes as an unsigned short value from a DataInputStream.
+ *
+ * @param stream The stream to read from.
+ * @param bigEndian If true, interpret the first byte as the high byte, otherwise interpret the
+ * first byte as the low byte.
+ */
+ public static int readUnsignedShort(DataInputStream stream, boolean bigEndian)
+ throws IOException {
+ return readUnsignedShort(stream, bigEndian, null);
+ }
+
+ /**
+ * Reads two bytes as an unsigned short value from a DataInputStream.
+ *
+ * @param stream The stream to read from.
+ * @param bigEndian If true, interpret the first byte as the high byte, otherwise interpret the
+ * first byte as the low byte.
+ */
+ public static int readUnsignedShort(DataInputStream stream, boolean bigEndian, ModuleBase counted)
+ throws IOException {
+ int n = 0;
+ if (bigEndian) {
+ n = stream.readUnsignedShort();
+ } else {
+ int b1 = stream.readUnsignedByte();
+ int b0 = stream.readUnsignedByte();
+ n = (b0 << 8) | b1;
+ }
+ if (counted != null) {
+ counted._nByte += 2;
+ }
+ return n;
+ }
+
+ /**
+ * Reads two bytes as an unsigned short value from a RandomAccessFile.
+ *
+ * @param file The file to read from.
+ * @param bigEndian If true, interpret the first byte as the high byte, otherwise interpret the
+ * first byte as the low byte.
+ */
+ public static int readUnsignedShort(RandomAccessFile file, boolean bigEndian) throws IOException {
+ int n = 0;
+ if (bigEndian) {
+ n = file.readUnsignedShort();
+ } else {
+ int b1 = file.readUnsignedByte();
+ int b0 = file.readUnsignedByte();
+ n = (b0 << 8) | b1;
+ }
+ return n;
+ }
+
+ /**
+ * Reads four bytes as an unsigned 32-bit value from a DataInputStream.
+ *
+ * @param stream The stream to read from.
+ * @param bigEndian If true, interpret the first byte as the high byte, otherwise interpret the
+ * first byte as the low byte.
+ */
+ public static long readUnsignedInt(DataInputStream stream, boolean bigEndian) throws IOException {
+ return readUnsignedInt(stream, bigEndian, null);
+ }
+
+ /**
+ * Reads four bytes as an unsigned 32-bit value from a DataInputStream.
+ *
+ * @param stream The stream to read from.
+ * @param bigEndian If true, interpret the first byte as the high byte, otherwise interpret the
+ * first byte as the low byte.
+ */
+ public static long readUnsignedInt(DataInputStream stream, boolean bigEndian, ModuleBase counted)
+ throws IOException {
+ long n = 0;
+ if (bigEndian) {
+ n = stream.readInt(); /* This is a signed value. */
+ if (n < 0) {
+ // n = 2147483648L + n;
+ n = n & 0XFFFFFFFFL;
+ }
+ } else {
+ long b3 = stream.readUnsignedByte();
+ long b2 = stream.readUnsignedByte();
+ long b1 = stream.readUnsignedByte();
+ long b0 = stream.readUnsignedByte();
+ n = (b0 << 24) | (b1 << 16) | (b2 << 8) | b3;
+ }
+ if (counted != null) {
+ counted._nByte += 4;
+ }
+ return n;
+ }
+
+ /**
+ * Reads four bytes as an unsigned 32-bit value from a RandomAccessFile.
+ *
+ * @param file The file to read from.
+ * @param bigEndian If true, interpret the first byte as the high byte, otherwise interpret the
+ * first byte as the low byte.
+ */
+ public static long readUnsignedInt(RandomAccessFile file, boolean bigEndian) throws IOException {
+ long n = 0;
+ if (bigEndian) {
+ n = file.readInt(); /* This is a signed value. */
+ if (n < 0) {
+ // n = 2147483648L + n;
+ n = n & 0XFFFFFFFFL;
+ }
+ } else {
+ // For efficiency, do one read rather than four
+ byte buf[] = new byte[4];
+ file.read(buf);
+ long b3 = buf[0] & 0XFFL;
+ long b2 = buf[1] & 0XFFL;
+ long b1 = buf[2] & 0XFFL;
+ long b0 = buf[3] & 0XFFL;
+ n = (b0 << 24) | (b1 << 16) | (b2 << 8) | b3;
+ }
+ return n;
+ }
+
+ /**
+ * Reads eight bytes as a signed 64-bit value from a DataInputStream.
+ *
+ * @param stream The stream to read from.
+ * @param bigEndian If true, interpret the first byte as the high byte, otherwise interpret the
+ * first byte as the low byte.
+ */
+ public static long readSignedLong(DataInputStream stream, boolean bigEndian, ModuleBase counted)
+ throws IOException {
+ long n = 0;
+ if (bigEndian) {
+ n = stream.readLong(); /* This is a signed value. */
+ } else {
+ long b7 = stream.readUnsignedByte();
+ long b6 = stream.readUnsignedByte();
+ long b5 = stream.readUnsignedByte();
+ long b4 = stream.readUnsignedByte();
+ long b3 = stream.readUnsignedByte();
+ long b2 = stream.readUnsignedByte();
+ long b1 = stream.readUnsignedByte();
+ long b0 = stream.readUnsignedByte();
+ n =
+ (b0 << 56)
+ | (b1 << 48)
+ | (b2 << 40)
+ | (b3 << 32)
+ | (b4 << 24)
+ | (b5 << 16)
+ | (b6 << 8)
+ | b7;
+ }
+ if (counted != null) {
+ counted._nByte += 8;
+ }
+ return n;
+ }
+
+ public static Rational readUnsignedRational(DataInputStream stream, boolean endian)
+ throws IOException {
+ return readUnsignedRational(stream, endian, null);
+ }
+
+ public static Rational readUnsignedRational(
+ DataInputStream stream, boolean endian, ModuleBase counted) throws IOException {
+ long n = readUnsignedInt(stream, endian, counted);
+ long d = readUnsignedInt(stream, endian, counted);
+ return new Rational(n, d);
+ }
+
+ public static Rational readUnsignedRational(RandomAccessFile file, boolean endian)
+ throws IOException {
+ long n = readUnsignedInt(file, endian);
+ long d = readUnsignedInt(file, endian);
+ return new Rational(n, d);
+ }
+
+ public static Rational readSignedRational(
+ DataInputStream stream, boolean endian, ModuleBase counted) throws IOException {
+ long n = readSignedInt(stream, endian, counted);
+ long d = readSignedInt(stream, endian, counted);
+ return new Rational(n, d);
+ }
+
+ public static Rational readSignedRational(RandomAccessFile file, boolean endian)
+ throws IOException {
+ long n = readSignedInt(file, endian);
+ long d = readSignedInt(file, endian);
+ return new Rational(n, d);
+ }
+
+ public static int readSignedByte(RandomAccessFile file) throws IOException {
+ return file.readByte();
+ }
+
+ public static int readSignedShort(RandomAccessFile file, boolean endian) throws IOException {
+ int b = readUnsignedShort(file, endian);
+ if ((b & 0X8000) != 0) {
+ b |= ~0XFFFF;
+ }
+ return b;
+ }
+
+ public static int readSignedInt(RandomAccessFile file, boolean endian) throws IOException {
+ long b = readUnsignedInt(file, endian);
+ if ((b & 0X80000000L) != 0) {
+ b |= ~0XFFFFFFFFL;
+ }
+ return (int) b;
+ }
+
+ public static int readSignedByte(DataInputStream stream) throws IOException {
+ return readSignedByte(stream, null);
+ }
+
+ public static int readSignedByte(DataInputStream stream, ModuleBase counted) throws IOException {
+ int val = stream.readByte();
+ if (counted != null) {
+ counted._nByte++;
+ }
+ return val;
+ }
+
+ public static int readSignedShort(DataInputStream stream, boolean endian) throws IOException {
+ return readSignedShort(stream, endian, null);
+ }
+
+ public static int readSignedShort(DataInputStream stream, boolean endian, ModuleBase counted)
+ throws IOException {
+ int b = readUnsignedShort(stream, endian, counted);
+ if ((b & 0X8000) != 0) {
+ b |= ~0XFFFF;
+ }
+ return b;
+ }
+
+ public static int readSignedInt(DataInputStream stream, boolean endian) throws IOException {
+ return readSignedInt(stream, endian, null);
+ }
+
+ public static int readSignedInt(DataInputStream stream, boolean endian, ModuleBase counted)
+ throws IOException {
+ long b = readUnsignedInt(stream, endian, counted);
+ if ((b & 0X80000000L) != 0) {
+ b |= ~0XFFFFFFFFL;
+ }
+ return (int) b;
+ }
+
+ public static float readFloat(RandomAccessFile file, boolean endian) throws IOException {
+ float f = 0.0F;
+ if (endian) {
+ f = file.readFloat();
+ } else {
+ // For efficiency, do one read rather than four
+ byte buf[] = new byte[4];
+ file.read(buf);
+ int b3 = buf[0] & 0XFF;
+ int b2 = buf[1] & 0XFF;
+ int b1 = buf[2] & 0XFF;
+ int b0 = buf[3] & 0XFF;
+ f = Float.intBitsToFloat(b0 << 24 | b1 << 16 | b2 << 8 | b3);
+ }
+ return f;
+ }
+
+ public static float readFloat(DataInputStream stream, boolean endian, ModuleBase counted)
+ throws IOException {
+ float f = 0.0F;
+ if (endian) {
+ f = stream.readFloat();
+ } else {
+ int b3 = stream.readUnsignedByte();
+ int b2 = stream.readUnsignedByte();
+ int b1 = stream.readUnsignedByte();
+ int b0 = stream.readUnsignedByte();
+ f = Float.intBitsToFloat(b0 << 24 | b1 << 16 | b2 << 8 | b3);
+ }
+ if (counted != null) {
+ counted._nByte += 4;
+ }
+ return f;
+ }
+
+ public static double readDouble(RandomAccessFile file, boolean endian) throws IOException {
+ double f = 0.0F;
+ if (endian) {
+ f = file.readDouble();
+ } else {
+ // For efficiency, do one read rather than eight
+ byte buf[] = new byte[8];
+ file.read(buf);
+ long b7 = buf[0] & 0XFFL;
+ long b6 = buf[1] & 0XFFL;
+ long b5 = buf[2] & 0XFFL;
+ long b4 = buf[3] & 0XFFL;
+ long b3 = buf[4] & 0XFFL;
+ long b2 = buf[5] & 0XFFL;
+ long b1 = buf[6] & 0XFFL;
+ long b0 = buf[7] & 0XFFL;
+
+ f =
+ Double.longBitsToDouble(
+ b0 << 56 | b1 << 48 | b2 << 40 | b3 << 32 | b4 << 24 | b5 << 16 | b6 << 8 | b7);
+ }
+ return f;
+ }
+
+ public static double readDouble(DataInputStream stream, boolean endian) throws IOException {
+ return readDouble(stream, endian, null);
+ }
+
+ public static double readDouble(DataInputStream stream, boolean endian, ModuleBase counted)
+ throws IOException {
+ double f = 0.0F;
+ if (endian) {
+ f = stream.readDouble();
+ } else {
+ long b7 = stream.readUnsignedByte();
+ long b6 = stream.readUnsignedByte();
+ long b5 = stream.readUnsignedByte();
+ long b4 = stream.readUnsignedByte();
+ long b3 = stream.readUnsignedByte();
+ long b2 = stream.readUnsignedByte();
+ long b1 = stream.readUnsignedByte();
+ long b0 = stream.readUnsignedByte();
+ f =
+ Double.longBitsToDouble(
+ b0 << 56 | b1 << 48 | b2 << 40 | b3 << 32 | b4 << 24 | b5 << 16 | b6 << 8 | b7);
+ }
+ if (counted != null) {
+ counted._nByte += 8;
+ }
+ return f;
+ }
+
+ /** Skip over some bytes. Return number of bytes skipped. */
+ public long skipBytes(DataInputStream stream, long bytesToSkip) throws IOException {
+ return skipBytes(stream, bytesToSkip, null);
+ }
+
+ /** Skip over some bytes. Return number of bytes skipped. */
+ public long skipBytes(DataInputStream stream, long bytesToSkip, ModuleBase counted)
+ throws IOException {
+ long totalBytesSkipped = 0;
+ while (bytesToSkip > 0) {
+ long bytesSkipped;
+ long availableBytes = stream.available();
+ if (availableBytes == 0) break;
+ // The count of skipped bytes returned by FileInputStream's 'skip'
+ // method is unreliable and may be greater than what was available
+ // to skip. So we need to monitor and correct any discrepancies
+ // ourselves. Luckily the 'available' method seems to accurately
+ // report the number of bytes available to be skipped, but because
+ // it returns an int, we're limited to skipping Integer.MAX_VALUE
+ // each call lest we skip more bytes than we can verify.
+ if (bytesToSkip > availableBytes) {
+ bytesSkipped = stream.skip(availableBytes);
+ } else {
+ bytesSkipped = stream.skip(bytesToSkip);
+ }
+ // If it reports skipping more bytes than were available,
+ // correct it to the most it could have skipped.
+ if (bytesSkipped > availableBytes) {
+ bytesSkipped = availableBytes;
+ }
+ totalBytesSkipped += bytesSkipped;
+ bytesToSkip -= bytesSkipped;
+ }
+ if (counted != null) {
+ counted._nByte += totalBytesSkipped;
+ }
+ return totalBytesSkipped;
+ }
+
+ /**
+ * A convenience method for getting a buffered DataInputStream from a module's InputStream. If the
+ * size specified is 0 or less, the default buffer size is used.
+ */
+ public static DataInputStream getBufferedDataStream(InputStream stream, int size) {
+ BufferedInputStream bis;
+ if (size <= 0) {
+ bis = new BufferedInputStream(stream);
+ } else {
+ bis = new BufferedInputStream(stream, size);
+ }
+ return new DataInputStream(bis);
+ }
+
+ /**
+ * A utility for converting a Vector of Properties to an Array. It can be simpler to build a
+ * Vector and then call VectorToPropArray than to allocate an array and drop all the Properites
+ * into the correct indices. All the members of the Vector must be of type Property, or a
+ * ClassCastException will be thrown.
+ */
+ protected Property[] vectorToPropArray(Vector vec) {
+ Property[] prop = new Property[vec.size()];
+ for (int i = 0; i < vec.size(); i++) {
+ prop[i] = (Property) vec.elementAt(i);
+ }
+ return prop;
+ }
+
+ protected void setupDataStream(final InputStream stream, final RepInfo info) {
+ /*
+ * Are checksums requested and ensure they're not already calculated
+ * when handling a temp file.
+ */
+ if (_je.getChecksumFlag() && info.getChecksum().isEmpty()) {
+ _ckSummer = new Checksummer();
+ _cstream = new ChecksumInputStream(stream, _ckSummer);
+ _dstream = getBufferedDataStream(_cstream, _app != null ? _je.getBufferSize() : 0);
+ } else {
+ _dstream = getBufferedDataStream(stream, _app != null ? _je.getBufferSize() : 0);
+ }
+ }
+
+ protected void checksumIfRafNotCopied(final RepInfo info, final RandomAccessFile raf)
+ throws IOException {
+ /*
+ * We may have already done the checksums while converting a
+ * temporary file.
+ */
+ _ckSummer = null;
+ if (_je != null && _je.getChecksumFlag() && info.getChecksum().isEmpty()) {
+ _ckSummer = new Checksummer();
+ calcRAChecksum(_ckSummer, raf);
+ setChecksums(_ckSummer, info);
+ }
+ }
+
+ protected boolean isParamInDefaults(final String paramVal) {
+ if (paramVal == null) return false;
+ for (String param : _defaultParams) {
+ if (paramVal.equalsIgnoreCase(param)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected void skipDstreamToEnd(final RepInfo info) {
+ /*
+ * We may not have actually hit the end of file. If we're calculating
+ * checksums on the fly, we have to read and discard whatever is
+ * left, so it will get checksummed.
+ */
+ for (; ; ) {
+ try {
+ long n = skipBytes(_dstream, 2048, this);
+ if (n == 0) {
+ break;
+ }
+ } catch (Exception e) {
+ break;
+ }
+ }
+ info.setSize(_cstream.getNBytes());
+ }
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ModuleInfo.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ModuleInfo.java
index f286b3d9b..c74458286 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ModuleInfo.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ModuleInfo.java
@@ -2,16 +2,16 @@
/** A small class to hold information about a module. */
public class ModuleInfo {
- public String clas;
- public String init;
- public String[] params;
-
- public ModuleInfo (String className) {
- clas = className;
- }
-
- public ModuleInfo (String className, String init) {
- clas = className;
- this.init = init;
- }
+ public String clas;
+ public String init;
+ public String[] params;
+
+ public ModuleInfo(String className) {
+ clas = className;
+ }
+
+ public ModuleInfo(String className, String init) {
+ clas = className;
+ this.init = init;
+ }
}
diff --git a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/NisoImageMetadata.java b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/NisoImageMetadata.java
index 2d86d3d65..4bc9b2e25 100644
--- a/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/NisoImageMetadata.java
+++ b/jhove-core/src/main/java/edu/harvard/hul/ois/jhove/NisoImageMetadata.java
@@ -1,8 +1,8 @@
-/**********************************************************************
- * Jhove - JSTOR/Harvard Object Validation Environment
- * Copyright 2003 by JSTOR and the President and Fellows of Harvard College
- **********************************************************************/
-
+/**
+ * ******************************************************************** Jhove - JSTOR/Harvard Object
+ * Validation Environment Copyright 2003 by JSTOR and the President and Fellows of Harvard College
+ * ********************************************************************
+ */
package edu.harvard.hul.ois.jhove;
import java.awt.color.ICC_Profile;
@@ -10,2311 +10,2280 @@
import java.nio.charset.StandardCharsets;
import java.util.logging.Logger;
-
/**
- * Encapsulation of the NISO Z39.87-2002 / AIIM 20-2002 Data Dictionary --
- * Technical Metadata for Digital Still Images
+ * Encapsulation of the NISO Z39.87-2002 / AIIM 20-2002 Data Dictionary -- Technical Metadata for
+ * Digital Still Images
*/
-public class NisoImageMetadata
-{
- /** Logger for this class. */
- private static final Logger LOGGER = Logger.getLogger(NisoImageMetadata.class.getCanonicalName());
-
- /** private String constants. */
- private static final String YES = "Yes";
- private static final String NO = "No";
- private static final String TIME_SEP = ":";
-
- /******************************************************************
- * PUBLIC CLASS FIELDS.
- ******************************************************************/
-
- /** 7.7.3.15 auto focus value labels. */
- public static final String [] AUTOFOCUS = {
- "unidentified", "auto focus used", "auto focus interrupted",
- "near focused", "soft focus", "manual"
- };
-
- /** 7.7.3.13 back light value labels. */
- public static final String [] BACKLIGHT = {
- "front light", "backlight 1", "backlight 2"
- };
-
- /** 6.1.2 byte order value labels. */
- public static final String [] BYTEORDER = {
- "big-endian", "little-endian"
- };
-
- /** 6.2.3.1 Checksum method value labels. */
- public static final String [] CHECKSUM_METHOD = {
- "CRC32", "MD5", "SHA-1", "SHA-256"
- };
-
- /** 6.1.4.1 Color space value labels. */
- public static final String [] COLORSPACE = {
- "white is zero", "black is zero", "RGB", "palette color",
- "transparency mask", "CMYK", "YCbCr", "CIE L*a*b*", "ICC L*a*b*",
+public class NisoImageMetadata {
+ /** Logger for this class. */
+ private static final Logger LOGGER = Logger.getLogger(NisoImageMetadata.class.getCanonicalName());
+
+ /** private String constants. */
+ private static final String YES = "Yes";
+
+ private static final String NO = "No";
+ private static final String TIME_SEP = ":";
+
+ /**
+ * **************************************************************** PUBLIC CLASS FIELDS.
+ * ****************************************************************
+ */
+
+ /** 7.7.3.15 auto focus value labels. */
+ public static final String[] AUTOFOCUS = {
+ "unidentified", "auto focus used", "auto focus interrupted",
+ "near focused", "soft focus", "manual"
+ };
+
+ /** 7.7.3.13 back light value labels. */
+ public static final String[] BACKLIGHT = {"front light", "backlight 1", "backlight 2"};
+
+ /** 6.1.2 byte order value labels. */
+ public static final String[] BYTEORDER = {"big-endian", "little-endian"};
+
+ /** 6.2.3.1 Checksum method value labels. */
+ public static final String[] CHECKSUM_METHOD = {"CRC32", "MD5", "SHA-1", "SHA-256"};
+
+ /** 6.1.4.1 Color space value labels. */
+ public static final String[] COLORSPACE = {
+ "white is zero",
+ "black is zero",
+ "RGB",
+ "palette color",
+ "transparency mask",
+ "CMYK",
+ "YCbCr",
+ "CIE L*a*b*",
+ "ICC L*a*b*",
"ITU L*a*b*",
"CFA",
"CIE Log2(L)",
"CIE Log2(L)(u',v')",
"LinearRaw",
"YCCK"
- };
-
- /** Index for 6.1.4.1 color space value labels. */
- public static final int [] COLORSPACE_INDEX = {
- 0, 1, 2, 3,
- 4, 5, 6, 8, 9,
- 10,
- 32803,
- 32844,
- 32845,
- 34892,
- 65535
- };
-
- /** 6.1.3.1 Compression scheme value labels. */
- /* Taken from the TIFFTAG_COMPRESSION */
- public static final String [] COMPRESSION_SCHEME = {
- "uncompressed", "CCITT 1D", "CCITT Group 3", "CCITT Group 4", /* 1-4 */
- "LZW", "JPEG", "ISO JPEG", "Deflate", /* 5-8 */
- "JBIG", /* 32661 */
- "RLE with word alignment", /* 32771 */
- "PackBits", "NeXT 2-bit encoding", "ThunderScan 4-bit encoding", /* 32773- */
- "RasterPadding in CT or MP", /* 32895 */
- "RLE for LW", "RLE for HC", "RLE for BL", /* 32896-8 */
- "Pixar 10-bit LZW", /* 32908 */
- "Pixar companded 11-bit ZIP encoding", /* 32909 */
- "PKZIP-style Deflate encoding", /* 32946 */
- "Kodak DCS", /* 32947 */
- "SGI 32-bit Log Luminance encoding", /* 34676 */
- "SGI 24-bit Log Luminance encoding", /* 34677 */
- "JPEG 2000", /* 34712 */
- "JPEG2000 Lossy", /* 34713 non standard !!! */
- "JPEG2000 Lossless", /* 34714 non standard !!! */
- "LZMA" /* 34925 */
- };
- /** Index for 6.1.3.1 compression scheme value labels. */
- public static final int COMPRESSION_JPEG2000_LOSSY = 34713;
- public static final int COMPRESSION_JPEG2000_LOSSLESS = 34714;
- public static final int [] COMPRESSION_SCHEME_INDEX = {
- 1, 2, 3, 4,
- 5, 6, 7, 8,
- 32661,
- 32771,
- 32773, 32766, 32809,
- 32895,
- 32896, 32897, 32898,
- 32908,
- 32909,
- 32946,
- 32947,
- 34676,
- 34677,
- 34712,
- 34713, /* non standard !!! */
- 34714, /* non standard !!! */
- 34925
- };
-
- /** 6.2.5 display orientation value labels. */
- public static final String [] DISPLAY_ORIENTATION = {
- "portrait", "landscape"
- };
-
- public static final String [] EXTRA_SAMPLES = {
- "unspecified", "associated alpha", "unassociated alpha",
- "range or depth"
- };
-
- public static final String [] EXPOSURE_PROGRAM = {
- "Not defined", " Manual", "Normal program", "Aperture priority",
- "Shutter priority", "Creative program (biased toward depth of field)",
- "Action program (biased toward fast shutter speed)",
- "Portrait mode (for closeup photos with the background out of focus)",
- "Landscape mode (for landscape photos with the background in focus)"
- };
-
- /** 7.7.3.10 flash value labels. */
- public static final String [] FLASH = {
- NO, YES
- };
- public static final String [] FLASH_20 = {
- "Flash did not fire", "Flash fired"
- };
-
- /** 7.7.3.12 flash return value labels. */
- public static final String [] FLASH_RETURN = {
- YES, NO
- };
-
- /** 8.2.6 gray response unit value labels for version 0.2. */
- public static final String [] GRAY_RESPONSE_UNIT_02 = {
- "", "tenths of a unit", "hundredths of a unit",
- "thousandths of a unit", "ten-thousandths of a unit",
- "hundred-thousandths of a unit"
- };
-
- /** Gray response unit value for version 2.0 of MIX, corresponding
- * to NISO values of 1-5 */
- public static final String [] GRAY_RESPONSE_UNIT_20 = {
- "Number represents tenths of a unit",
- "Number represents hundredths of a unit",
- "Number represents thousandths of a unit",
- "Number represents ten-thousandths of a unit",
- "Number represents hundred-thousandths of a unit"
- };
-
- /** extra sample value for version 2.0 of MIX, corresponding
- * to NISO values of 0-3 **/
- public static final String [] EXTRA_SAMPLE_20 = {
- "unspecified data",
- "associated alpha data (with pre-multiplied color)",
- "unassociated alpha data",
- "range or depth data"
- };
-
- /** 7.7.3.6 metering mode value labels. */
- public static final String [] METERING_MODE = {
- "unidentified", "average", "center weighted average", "spot",
- "multispot", "pattern", "partial"
- };
-
- /** 6.2.4 orientation value labels. */
- public static final String [] ORIENTATION = {
- "", "normal", "reflected horiz", "rotated 180 deg", "reflected vert",
- "left top", "rotated cw 90 deg", "Right bottom", "Rotated ccw 90 deg",
- "Unknown"
- };
-
- /** 6.1.6 planar configuration value labels. */
- public static final String [] PLANAR_CONFIGURATION = {
- "", "chunky", "planar"
- };
-
- /** 8.1.1 sampling frequency plane value labels. */
- public static final String [] SAMPLING_FREQUENCY_PLANE = {
- "", "camera/scanner focal plane", "object plane", "source object plane"
- };
-
- /** 8.1.2 sampling frequency unit value labels. */
- public static final String [] SAMPLING_FREQUENCY_UNIT = {
- "", "no absolute unit", "inch", "centimeter"
- };
-
- /** 7.7.3.7 scene illuminant value labels. */
- public static final String [] SCENE_ILLUMINANT = {
- "unidentified", "daylight", "fluorescent", "tungsten lamp",
- "flash", "standard illuminant A", "standard illuminat B",
- "standard illuminant C", "D55 illuminant", "D65 illuminant",
- "D75 illuminant"
- };
- /** Index for 7.7.3.7 scene illuminant value labels. */
- public static final int [] SCENE_ILLUMINANT_INDEX = {
- 0, 1, 2, 3, 10, 17, 18, 19, 20, 21, 22
- };
-
- /** 6.1.5.1 segment type value labels. */
- public static final String [] SEGMENT_TYPE = {
- "strips", "tiles"
- };
-
- /** 7.8 sensor value labels. */
- public static final String [] SENSOR = {
- "Undefined", "MonochromeArea", "OneChipColorArea", "TwoChipColorArea",
- "ThreeChipColorArea", "ColorSequentialArea", "MonochromeLinear",
- "ColorTriLinear", "ColorSequentialLinear"
- };
-
- /** 8.1.7.1 (8.1.8.1) source dimension unit. */
- public static final String [] SOURCE_DIMENSION_UNIT = {
- "inches", "mm"
- };
-
- /** 6.1.4.4 YCbCr positioning value labels. */
- public static final String [] YCBCR_POSITIONING = {
- "", "centered", "cosited"
- };
-
- /** 8.3.1 TargetType. */
- public static final String [] TARGET_TYPE = {
- "external", "internal"
- };
-
- /** Undefined value. */
- public static final int NULL = -1;
- public static final double NILL = -1.0;
-
- /******************************************************************
- * PRIVATE INSTANCE FIELDS.
- *
- * 6 Basic image parameters
- ******************************************************************/
-
- /** 6.1.1 MIME type */
- private String _mimeType;
-
- /** 6.1.2 Byte order */
- private String _byteOrder;
-
- /** 6.1.3.1 Compression scheme */
- private int _compressionScheme;
- /** 6.1.3.2 Compression level */
- private int _compressionLevel;
-
- /** 6.1.4.1 Color space */
- private int _colorSpace;
-
- /** 6.1.4.2.1 ICC profile name */
- private String _profileName;
- /** 6.1.4.2.2 ICC profile url */
- private String _profileURL;
-
- /** 6.1.4.3 YCbCr sub-sampling */
- private int [] _yCbCrSubSampling;
- /** 6.1.4.4 YCbCr positioning */
- private int _yCbCrPositioning;
- /** 6.1.4.5 YCbCr coefficients */
- private Rational [] _yCbCrCoefficients;
- /** 6.1.4.6 Reference black and white */
- private Rational [] _referenceBlackWhite;
-
- /** 6.1.5.1 Segment type */
- private int _segmentType;
- /** 6.1.5.2 Strip offsets */
- private long [] _stripOffsets;
- /** 6.1.5.3 Rows per strip */
- private long _rowsPerStrip;
- /** 6.1.5.4 Strip byte counts */
- private long [] _stripByteCounts;
- /** 6.1.5.5 Tile width */
- private long _tileWidth;
- /** 6.1.5.6 Tile length */
- private long _tileLength;
- /** 6.1.5.7 Tile offsets */
- private long [] _tileOffsets;
- /** 6.1.5.8 Tile byte counts */
- private long [] _tileByteCounts;
-
- /** 6.1.6 Planar configuration */
- private int _planarConfiguration;
-
- /** 6.2.1 Image identifier */
- private String _imageIdentifier;
- /** 6.2.1.1 Image identifier location */
- private String _imageIdentifierLocation;
-
- /** 6.2.2 File size */
- private long _fileSize;
- /** 6.2.3.1 Checksum method */
- private int _checksumMethod;
- /** 6.2.3.2 Checksum value */
- private String _checksumValue;
-
- /** 6.2.4 orientation */
- private int _orientation;
-
- /** 6.2.5 Display orientation */
- private int _displayOrientation;
-
- /** 6.2.6.1 X targeted display aspect ratio */
- private long _xTargetedDisplayAR;
- /** 6.2.6.2 Y targeted display aspect ratio */
- private long _yTargetedDisplayAR;
-
- /** 6.3 Preferred presentation */
- private String _preferredPresentation;
-
- /******************************************************************
- * Special Format Characteristics
- * From Data Dictionary - Technical Metadata for Digital Still Images
- * (ANSI/NISO Z39.87-2006)
- * Only used for JPEG2000 format
- ******************************************************************/
- /** 7.2.1.2.1 tiles */
- private String _jp2Tiles;
- /** 7.2.1.2.2 qualityLayers */
- private int _jp2Layers;
- /** 7.2.1.2.3resolutionLevels */
- private int _jp2ResolutionLevels;
-
- /******************************************************************
- * 7 Image creation
- ******************************************************************/
-
- /** 7.1 Source type */
- private String _sourceType;
-
- /** 7.2 Source ID */
- private String _sourceID;
-
- /** 7.3 Image producer */
- private String _imageProducer;
-
- /** 7.4 Host computer */
- private String _hostComputer;
- /** 7.4.1 Operating system */
- private String _os;
- /** 7.4.2 OS version */
- private String _osVersion;
-
- /** 7.5 Device source */
- private String _deviceSource;
-
- /** 7.6.1.1 Scanner system manufacturer */
- private String _scannerManufacturer;
- /** 7.6.1.2.1 Scanner model name */
- private String _scannerModelName;
- /** 7.6.1.2.2 Scanner model number */
- private String _scannerModelNumber;
- /** 7.6.1.2.3 Scanner model serial number */
- private String _scannerModelSerialNo;
- /** 7.6.2.1 Scanning software */
- private String _scanningSoftware;
- /** 7.6.2.2 Scanning software version number */
- private String _scanningSoftwareVersionNo;
-
- /** 7.6.3 Pixel size (in meters) */
- private double _pixelSize;
-
- /** 7.6.3.2.1 X physical scan resolution */
- private double _xPhysScanResolution;
- /** 7.6.3.2.2 Y physical scan resolution */
- private double _yPhysScanResolution;
-
- /** 7.7.1 Digital camera manufacturer */
- private String _digitalCameraManufacturer;
- /** 7.7.2 Digital camera model name */
- private String _digitalCameraModelName;
- /** 7.7.2 Digital camera model number */
- private String _digitalCameraModelNumber;
- /** 7.7.2 Digital camera model serial number*/
- private String _digitalCameraModelSerialNo;
-
- /** 7.7.3.1 F number */
- private double _fNumber;
- /** 7.7.3.2 Exposure time */
- private double _exposureTime;
-
- private int _exposureProgram;
- private String _exifVersion;
- private Rational _maxApertureValue;
-
- /** 7.7.3.3 Brightness */
- private Rational _brightness;
- /** 7.7.3.4 Exposure bias */
- private Rational _exposureBias;
- /** 7.7.3.5 Subject distance */
- private double [] _subjectDistance;
- /** 7.7.3.6 Metering mode */
- private int _meteringMode;
- /** 7.7.3.7 Scene illuminant */
- private int _sceneIlluminant;
- /** 7.7.3.8 Color temperature */
- private double _colorTemp;
- /** 7.7.3.9 Focal length (in meters) */
- private double _focalLength;
- /** 7.7.3.10 Flash */
- private int _flash;
- /** 7.7.3.11 Flash energy */
- private Rational _flashEnergy;
- /** 7.7.3.12 Flash return */
- private int _flashReturn;
- /** 7.7.3.13 Back light */
- private int _backLight;
- /** 7.7.3.14 Exposure index */
- private double _exposureIndex;
- /** 7.7.3.15 Auto focus */
- private int _autoFocus;
- /** 7.7.3.16.1 X print aspect ratio */
- private double _xPrintAspectRatio;
- /** 7.7.3.16.2 Y print aspect ratio */
- private double _yPrintAspectRatio;
-
- /** 7.8 Sensor */
- private int _sensor;
-
- /** 7.9 Date/time created */
- private String _dateTimeCreated;
-
- /** 7.10 Methodology */
- private String _methodology;
-
- /******************************************************************
- * Imaging performance assessment
- ******************************************************************/
-
- /** 8.1.1 Sampling frequency plane */
- private int _samplingFrequencyPlane;
- /** 8.1.2 Sampling frequency unit */
- private int _samplingFrequencyUnit;
- /** 8.1.3 X sampling frequency */
- private Rational _xSamplingFrequency;
- /** 8.1.4 Y sampling frequency */
- private Rational _ySamplingFrequency;
- /** 8.1.5 Image width */
- private long _imageWidth;
- /** 8.1.6 Image Length */
- private long _imageLength;
- /** 8.1.7 Source X dimension */
- private double _sourceXDimension;
- /** 8.1.8 Source X dimension unit */
- private int _sourceXDimensionUnit;
- /** 8.1.9 Source Y dimension */
- private double _sourceYDimension;
- /** 8.1.10 Source Y dimension unit */
- private int _sourceYDimensionUnit;
-
- /** 8.2.1 Bits per sample */
- private int [] _bitsPerSample;
- /** 8.2.2 Samples per pixel */
- private int _samplesPerPixel;
- /** 8.2.3 Extra samples */
- private int [] _extraSamples;
-
- /** 8.2.4.1 Colormap reference */
- private String _colormapReference;
- /** 8.2.4.2 Colormap bit code value */
- private int [] _colormapBitCodeValue;
- /** 8.2.4.3 Colormap red value */
- private int [] _colormapRedValue;
- /** 8.2.4.4 Colormap green value */
- private int [] _colormapGreenValue;
- /** 8.2.4.5 Colormap blue value */
- private int [] _colormapBlueValue;
-
- /** 8.2.5 Gray response curve */
- private int [] _grayResponseCurve;
- /** 8.2.6 Gray response unit */
- private int _grayResponseUnit;
-
- /** 8.2.7.1 Whitepoint X value */
- private Rational _whitePointXValue;
- /** 8.2.7.2 Whitepoint Y value */
- private Rational _whitePointYValue;
-
- /** 8.2.8.1 Primary chromaticities Red X */
- private Rational _primaryChromaticitiesRedX;
- /** 8.2.8.2 Primary chromaticities Red Y */
- private Rational _primaryChromaticitiesRedY;
- /** 8.2.8.3 Primary chromaticities Green X */
- private Rational _primaryChromaticitiesGreenX;
- /** 8.2.8.4 Primary chromaticities Green Y */
- private Rational _primaryChromaticitiesGreenY;
- /** 8.2.8.5 Primary chromaticities Blue X */
- private Rational _primaryChromaticitiesBlueX;
- /** 8.2.8.6 Primary chromaticities Blue Y */
- private Rational _primaryChromaticitiesBlueY;
-
- /* 8.3 Target data */
- /** 8.3.1 Target Type */
- private int _targetType;
- /** 8.3.2.1 TargetIDManufacturer */
- private String _targetIDManufacturer;
- /** 8.3.2.2 TargetIDName */
- private String _targetIDName;
- /** 8.3.2.3 TargetIDNo */
- private String _targetIDNo;
- /** 8.3.2.4 TargetIDMedia */
- private String _targetIDMedia;
- /** 8.3.3 ImageData */
- private String _imageData;
- /** 8.3.4 PerformanceData */
- private String _performanceData;
- /** 8.3.5 Profiles */
- private String _profiles;
-
- /* 9 Change history */
- /** 9.1.1 DateTimeProcessed */
- private String _dateTimeProcessed;
- /** 9.1.2 SourceData */
- private String _sourceData;
- /** 9.1.3 ProcessingAgency */
- private String _processingAgency;
- /** 9.1.4.1 ProcessingSoftwareName */
- private String _processingSoftwareName;
- /** 9.1.4.2 ProcessingSoftwareVersion */
- private String _processingSoftwareVersion;
- /** 9.1.5 ProcessingActions */
- private String[] _processingActions;
-
- /* 9.2 PreviousImageMetadata -- not currently supported */
-
- /* Data for Swing-based viewer. */
- private Property _viewerData;
-
- /******************************************************************
- * CLASS CONSTRUCTOR.
- ******************************************************************/
-
- /** Instantiate a NisoImageMetadata
object.
- */
- public NisoImageMetadata ()
- {
- _autoFocus = NULL;
- _backLight = NULL;
- _brightness = null;
- _checksumMethod = NULL;
- _colorSpace = NULL;
- _colorTemp = NILL;
- _compressionLevel = NULL;
- _compressionScheme = NULL;
- _dateTimeProcessed = null;
- _digitalCameraManufacturer = null;
- _digitalCameraModelName = null;
- _digitalCameraModelNumber = null;
- _digitalCameraModelSerialNo = null;
- _displayOrientation = NULL;
- _exifVersion = null;
- _exposureBias = null;
- _exposureIndex = NILL;
- _exposureProgram = NULL;
- _exposureTime = NILL;
- _fileSize = NULL;
- _flash = NULL;
- _flashEnergy = null;
- _flashReturn = NULL;
- _fNumber = NILL;
- _focalLength = NILL;
- _grayResponseUnit = NULL;
- _imageData = null;
- _imageLength = NULL;
- _imageWidth = NULL;
- _jp2Layers = NULL;
- _jp2ResolutionLevels = NULL;
- _jp2Tiles = null;
- _maxApertureValue = null;
- _meteringMode = NULL;
- _orientation = NULL;
- _performanceData = null;
- _pixelSize = NILL;
- _planarConfiguration = NULL;
- _processingActions = null;
- _processingAgency = null;
- _processingSoftwareName = null;
- _processingSoftwareVersion = null;
- _profiles = null;
- _rowsPerStrip = NULL;
- _scannerManufacturer = null;
- _scannerModelName = null;
- _scannerModelNumber = null;
- _scannerModelSerialNo = null;
- _samplesPerPixel = NULL;
- _samplingFrequencyPlane = NULL;
- _samplingFrequencyUnit = NULL;
- _sceneIlluminant = NULL;
- _segmentType = NULL;
- _sensor = NULL;
- _sourceData = null;
- _sourceXDimension = NILL;
- _sourceXDimensionUnit = NULL;
- _sourceYDimension = NILL;
- _sourceYDimensionUnit = NULL;
- _tileLength = NULL;
- _tileWidth = NULL;
- _targetIDManufacturer = null;
- _targetIDMedia = null;
- _targetIDName = null;
- _targetIDNo = null;
- _targetType = NULL;
- _xPhysScanResolution = NILL;
- _xPrintAspectRatio = NILL;
- _xSamplingFrequency = null;
- _xTargetedDisplayAR = NULL;
- _yCbCrPositioning = NULL;
- _yPhysScanResolution = NILL;
- _yPrintAspectRatio = NILL;
- _ySamplingFrequency = null;
- _yTargetedDisplayAR = NULL;
- _viewerData = null;
- }
-
- /******************************************************************
- * PUBLIC INSTANCE METHODS.
- *
- * Accessor methods.
- ******************************************************************/
-
- /** Get 7.7.3.15 auto focus. */
- public int getAutoFocus ()
- {
- return _autoFocus;
- }
-
- /** Get 7.7.3.13 back light. */
- public int getBackLight ()
- {
- return _backLight;
- }
-
- /** Get 8.2.1 bits per sample. */
- public int [] getBitsPerSample ()
- {
- return _bitsPerSample;
- }
-
- /** Get 7.7.3.3 Brightness. */
- public Rational getBrightness ()
- {
- return _brightness;
- }
-
- /** Get 6.1.2 byte order. */
- public String getByteOrder ()
- {
- return _byteOrder;
- }
-
- /** Get 6.2.3.1 Checksum method. */
- public int getChecksumMethod ()
- {
- return _checksumMethod;
- }
-
- /** Get 6.2.3.2 Checksum value. */
- public String getChecksumValue ()
- {
- return _checksumValue;
- }
-
- /** Get 8.2.4.2 colormap bit code value. */
- public int [] getColormapBitCodeValue ()
- {
- return _colormapBitCodeValue;
- }
-
- /** Get 8.2.4.5 colormap blue value. */
- public int [] getColormapBlueValue ()
- {
- return _colormapBlueValue;
- }
-
- /** Get 8.2.4.4 colormap green value. */
- public int [] getColormapGreenValue ()
- {
- return _colormapGreenValue;
- }
-
- /** Get 8.2.4.3 colormap red value. */
- public int [] getColormapRedValue ()
- {
- return _colormapRedValue;
- }
-
- /** Get 8.2.4.1 colormap reference. */
- public String getColormapReference ()
- {
- return _colormapReference;
- }
-
- /** Get 6.1.4.1 color space. */
- public int getColorSpace ()
- {
- return _colorSpace;
- }
-
- /** Get 7.7.3.8 color temperature. */
- public double getColorTemp ()
- {
- return _colorTemp;
- }
-
- /** Get 6.1.3.2 compression level. */
- public int getCompressionLevel ()
- {
- return _compressionLevel;
- }
-
- /** Get 6.1.3.1 compression scheme. */
- public int getCompressionScheme ()
- {
- return _compressionScheme;
- }
-
- /** Get 7.9 date/time created. */
- public String getDateTimeCreated ()
- {
- return _dateTimeCreated;
- }
-
- /** Get 9.1.1 DateTimeProcessed */
- public String getDateTimeProcessed ()
- {
- return _dateTimeProcessed;
- }
-
- /** Get 7.5 device source. */
- public String getDeviceSource ()
- {
- return _deviceSource;
- }
-
- /** Get 7.7.1 digital camera manufacturer. */
- public String getDigitalCameraManufacturer ()
- {
- return _digitalCameraManufacturer;
- }
-
- /** Get 7.7.2 digital camera model. */
- public String getDigitalCameraModelName ()
- {
- return _digitalCameraModelName;
- }
- public String getDigitalCameraModelNumber ()
- {
- return _digitalCameraModelNumber;
- }
- public String getDigitalCameraModelSerialNo()
- {
- return _digitalCameraModelSerialNo;
- }
-
- /** Get 6.2.5 Display orientation. */
- public int getDisplayOrientation ()
- {
- return _displayOrientation;
- }
-
- public String getExifVersion ()
- {
- return _exifVersion;
- }
-
- /** Get 7.7.3.4 exposure bias. */
- public Rational getExposureBias ()
- {
- return _exposureBias;
- }
-
- /** Get 7.7.3.14 exposure index. */
- public double getExposureIndex ()
- {
- return _exposureIndex;
- }
-
- public int getExposureProgram ()
- {
- return _exposureProgram;
- }
-
- /** Get 7.7.3.2 exposure time. */
- public double getExposureTime ()
- {
- return _exposureTime;
- }
-
- /** Get 8.2.3 extra samples. */
- public int [] getExtraSamples ()
- {
- return _extraSamples;
- }
-
- /** Get 6.2.2 file size. */
- public long getFileSize ()
- {
- return _fileSize;
- }
-
- /** Get 7.7.3.10 flash. */
- public int getFlash ()
- {
- return _flash;
- }
-
- /** Get 7.7.3.11 flash energy. */
- public Rational getFlashEnergy ()
- {
- return _flashEnergy;
- }
-
- /** Get 7.7.3.12 flash return. */
- public int getFlashReturn ()
- {
- return _flashReturn;
- }
-
- /** Get 7.7.3.1 F number. */
- public double getFNumber ()
- {
- return _fNumber;
- }
-
- /** Get 7.7.3.9 focal length. */
- public double getFocalLength ()
- {
- return _focalLength;
- }
-
- /** Get 8.2.5 gray response curve. */
- public int [] getGrayResponseCurve ()
- {
- return _grayResponseCurve;
- }
-
- /** Get 8.2.6 gray response unit. */
- public int getGrayResponseUnit ()
- {
- return _grayResponseUnit;
- }
-
- /** Get 7.4 host computer. */
- public String getHostComputer ()
- {
- return _hostComputer;
- }
-
- /** Get 8.3.3 ImageData */
- public String getImageData ()
- {
- return _imageData;
- }
-
- /** Get 6.2.1 Image identifier. */
- public String getImageIdentifier ()
- {
- return _imageIdentifier;
- }
-
- /** Get 6.2.1.1 Image identifier location. */
- public String getImageIdentifierLocation ()
- {
- return _imageIdentifierLocation;
- }
-
- /** Get 8.1.6 image length. */
- public long getImageLength ()
- {
- return _imageLength;
- }
-
- /** Get 7.3 Image producer. */
- public String getImageProducer ()
- {
- return _imageProducer;
- }
-
- /** Get 8.1.5 image width. */
- public long getImageWidth ()
- {
- return _imageWidth;
- }
-
- public Rational getMaxApertureValue ()
- {
- return _maxApertureValue;
- }
-
- /** Get 7.7.3.6 metering mode. */
- public int getMeteringMode ()
- {
- return _meteringMode;
- }
-
- /** Get 7.10 methodology. */
- public String getMethodology ()
- {
- return _methodology;
- }
-
- /** Get 6.1.1 MIME type. */
- public String getMimeType ()
- {
- return _mimeType;
- }
-
- /** Get 6.2.4 Orientation. */
- public int getOrientation ()
- {
- return _orientation;
- }
-
- /** Get 7.4.1 OS (operating system). */
- public String getOS ()
- {
- return _os;
- }
-
- /** Get 7.4.2 OS version. */
- public String getOSVersion ()
- {
- return _osVersion;
- }
-
- /** Get 8.3.4 PerformanceData. */
- public String getPerformanceData ()
- {
- return _performanceData;
- }
-
- /** Get 7.6.3.1 pixel size. */
- public double getPixelSize ()
- {
- return _pixelSize;
- }
-
- /** Get 6.1.6 Planar configuration. */
- public int getPlanarConfiguration ()
- {
- return _planarConfiguration;
- }
-
- /** Get 6.3 preferred presentation. */
- public String getPreferredPresentation ()
- {
- return _preferredPresentation;
- }
-
- public String getJp2Tiles() {
- return _jp2Tiles;
- }
-
- public void setJp2Tiles(String jp2Tiles) {
- this._jp2Tiles = jp2Tiles;
- }
-
- public int getJp2Layers() {
- return _jp2Layers;
- }
-
- public void setJp2Layers(int jp2Layers) {
- this._jp2Layers = jp2Layers;
- }
-
- public int getJp2ResolutionLevels() {
- return _jp2ResolutionLevels;
- }
-
- public void setJp2ResolutionLevels(int jp2ResolutionLevels) {
- this._jp2ResolutionLevels = jp2ResolutionLevels;
- }
-
- /** Get 8.2.8.5 primary chromaticities blue X. */
- public Rational getPrimaryChromaticitiesBlueX ()
- {
- return _primaryChromaticitiesBlueX;
- }
-
- /** Get 8.2.8.6 primary chromaticities blue Y. */
- public Rational getPrimaryChromaticitiesBlueY ()
- {
- return _primaryChromaticitiesBlueY;
- }
-
- /** Get 8.2.8.3 primary chromaticities green X. */
- public Rational getPrimaryChromaticitiesGreenX ()
- {
- return _primaryChromaticitiesGreenX;
- }
-
- /** Get 8.2.8.4 primary chromaticities green Y. */
- public Rational getPrimaryChromaticitiesGreenY ()
- {
- return _primaryChromaticitiesGreenY;
- }
-
- /** Get 8.2.8.1 primary chromaticities red X. */
- public Rational getPrimaryChromaticitiesRedX ()
- {
- return _primaryChromaticitiesRedX;
- }
-
- /** Get 8.2.8.2 primary chromaticities red Y. */
- public Rational getPrimaryChromaticitiesRedY ()
- {
- return _primaryChromaticitiesRedY;
- }
-
- /** Get 9.1.5 ProcessingActions. */
- public String[] getProcessingActions ()
- {
- return _processingActions;
- }
-
- /** Get 9.1.3 ProcessingAgency. */
- public String getProcessingAgency ()
- {
- return _processingAgency;
- }
-
- /** Get 9.1.4.1 ProcessingSoftwareName */
- public String getProcessingSoftwareName ()
- {
- return _processingSoftwareName;
- }
-
- /** Get 9.1.4.2 ProcessingSoftwareVersion */
- public String getProcessingSoftwareVersion ()
- {
- return _processingSoftwareVersion;
- }
-
- /** Get 6.1.4.2.1 ICC profile name. */
- public String getProfileName ()
- {
- return _profileName;
- }
-
- /** Get 8.3.5 Profiles */
- public String getProfiles ()
- {
- return _profiles;
- }
-
- /** Get 6.1.4.2.2 ICC profile URL. */
- public String getProfileURL ()
- {
- return _profileURL;
- }
-
- /** Get 6.1.4.6 Reference black and white. */
- public Rational [] getReferenceBlackWhite ()
- {
- return _referenceBlackWhite;
- }
-
- /** Get 6.1.5.3 Rows per strip. */
- public long getRowsPerStrip ()
- {
- return _rowsPerStrip;
- }
-
- /** Get 8.2.2 samples per pixel. */
- public int getSamplesPerPixel ()
- {
- return _samplesPerPixel;
- }
-
- /** Get 8.1.1 sampling frequency plane. */
- public int getSamplingFrequencyPlane ()
- {
- return _samplingFrequencyPlane;
- }
-
- /** Get 8.1.2 sampling frequency unit. */
- public int getSamplingFrequencyUnit ()
- {
- return _samplingFrequencyUnit;
- }
-
- /** Get 7.6.1.1 scanner manufacturer. */
- public String getScannerManufacturer ()
- {
- return _scannerManufacturer;
- }
-
- /** Get 7.6.1.2.1 scanner model name. */
- public String getScannerModelName ()
- {
- return _scannerModelName;
- }
-
- /** Get 7.6.1.2.2 scanner model number. */
- public String getScannerModelNumber ()
- {
- return _scannerModelNumber;
- }
-
- /** Get 7.6.1.2.3 scanner model serial number. */
- public String getScannerModelSerialNo ()
- {
- return _scannerModelSerialNo;
- }
-
- /** Get 7.6.2.1 scanning software. */
- public String getScanningSoftware ()
- {
- return _scanningSoftware;
- }
-
- /** Get 7.6.2.2 scanning software version number. */
- public String getScanningSoftwareVersionNo ()
- {
- return _scanningSoftwareVersionNo;
- }
-
- /** Get 7.7.3.7 scene illuminant. */
- public int getSceneIlluminant ()
- {
- return _sceneIlluminant;
- }
-
- /** Get 6.1.5.1 segment type. */
- public int getSegmentType ()
- {
- return _segmentType;
- }
-
- /** Get 7.8 sensor. */
- public int getSensor ()
- {
- return _sensor;
- }
-
- /** Get 9.1.2 SourceData. */
- public String getSourceData ()
- {
- return _sourceData;
- }
-
- /** Get 7.2 source ID. */
- public String getSourceID ()
- {
- return _sourceID;
- }
-
- /** Get 7.1 Source type. */
- public String getSourceType ()
- {
- return _sourceType;
- }
-
- public double getSourceXDimension ()
- {
- return _sourceXDimension;
- }
-
- public int getSourceXDimensionUnit ()
- {
- return _sourceXDimensionUnit;
- }
-
- public double getSourceYDimension ()
- {
- return _sourceYDimension;
- }
-
- public int getSourceYDimensionUnit ()
- {
- return _sourceYDimensionUnit;
- }
-
- /** Get 6.1.5.4 Strip byte counts. */
- public long [] getStripByteCounts ()
- {
- return _stripByteCounts;
- }
-
- /** Get 6.1.5.2 Strip offsets. */
- public long [] getStripOffsets ()
- {
- return _stripOffsets;
- }
-
- /** Get 7.7.3.5 Subject distance. */
- public double [] getSubjectDistance ()
- {
- return _subjectDistance;
- }
-
- /** Get 8.3.2.1 TargetIDManufacturer */
- public String getTargetIDManufacturer ()
- {
- return _targetIDManufacturer;
- }
-
- /** Get 8.3.2.3 TargetIDMedia */
- public String getTargetIDMedia ()
- {
- return _targetIDMedia;
- }
-
- /** Get 8.3.2.2 TargetIDName */
- public String getTargetIDName ()
- {
- return _targetIDName;
- }
-
- /** Get 8.3.2.3 TargetIDNo */
- public String getTargetIDNo ()
- {
- return _targetIDNo;
- }
-
- /** Get 8.3.1 Target Type */
- public int getTargetType ()
- {
- return _targetType;
- }
-
- /** Get 6.1.5.8 Tile byte counts. */
- public long [] getTileByteCounts ()
- {
- return _tileByteCounts;
- }
-
- /** Get 6.1.5.6 Tile length. */
- public long getTileLength ()
- {
- return _tileLength;
- }
-
- /** Get 6.1.5.7 Tile offsets. */
- public long [] getTileOffsets ()
- {
- return _tileOffsets;
- }
-
- /** Get 6.1.5.5 Tile width. */
- public long getTileWidth ()
- {
- return _tileWidth;
- }
-
- /** Get 8.2.7.1 white point X value. */
- public Rational getWhitePointXValue ()
- {
- return _whitePointXValue;
- }
-
- /** Get 8.2.7.2 white point Y value. */
- public Rational getWhitePointYValue ()
- {
- return _whitePointYValue;
- }
-
- /** Get 7.7.3.16.1 X print aspect ratio. */
- public double getXPrintAspectRatio ()
- {
- return _xPrintAspectRatio;
- }
-
- /** Get 7.6.3.2.1 X physcal scanning resolution. */
- public double getXPhysScanResolution ()
- {
- return _xPhysScanResolution;
- }
-
- /** Get 8.1.3 X sampling frequency. */
- public Rational getXSamplingFrequency ()
- {
- return _xSamplingFrequency;
- }
-
- /** Get 6.2.6 X targeted display aspect ratio. */
- public long getXTargetedDisplayAR ()
- {
- return _xTargetedDisplayAR;
- }
-
- /** Get 6.1.4.5 YCbCr coefficients. */
- public Rational [] getYCbCrCoefficients ()
- {
- return _yCbCrCoefficients;
- }
-
- /** Get 6.1.4.4 YCbCr positioning. */
- public int getYCbCrPositioning ()
- {
- return _yCbCrPositioning;
- }
-
- /** Get 6.1.4.3 YCbCr subsampling. */
- public int [] getYCbCrSubSampling ()
- {
- return _yCbCrSubSampling;
- }
-
- /** Get 7.6.3.2.2 Y physcal scanning resolution. */
- public double getYPhysScanResolution ()
- {
- return _yPhysScanResolution;
- }
-
- /** Get 7.7.3.16.2 Y print aspect ratio. */
- public double getYPrintAspectRatio ()
- {
- return _yPrintAspectRatio;
- }
-
- /** Get 8.1.4 Y sampling frequency. */
- public Rational getYSamplingFrequency ()
- {
- return _ySamplingFrequency;
- }
-
- /** Get 6.2.7 Y targeted display aspect ratio. */
- public long getYTargetedDisplayAR ()
- {
- return _yTargetedDisplayAR;
- }
-
- /** Get data for Swing GUI viewer. */
- public Property getViewerData ()
- {
- return _viewerData;
- }
-
-
- /******************************************************************
- * Mutator methods.
- ******************************************************************/
-
- /** Set 7.7.3.15 auto focus.
- * @param focus Auto focus
- */
- public void setAutoFocus (int focus)
- {
- _autoFocus = focus;
- }
-
- /** Set 7.7.3.13 back light.
- * @param light Back light
- */
- public void setBackLight (int light)
- {
- _backLight = light;
- }
-
- /** Set 8.2.1 bits per sample.
- * @param bits Bits per sample
- */
- public void setBitsPerSample (int [] bits)
- {
- _bitsPerSample = bits;
- }
-
- /** Set 7.7.3.3 brightness.
- * @param brightness Brightness
- */
- public void setBrightness (Rational brightness)
- {
- _brightness = brightness;
- }
-
- /** Set 6.1.2 byte order.
- * @param order Byte order
- */
- public void setByteOrder (String order)
- {
- _byteOrder = order;
- }
-
- /** Set 8.2.4.2 colormap bit code value.
- * @param value Bit code value
- */
- public void setColormapBitCodeValue (int [] value)
- {
- _colormapBitCodeValue = value;
- }
-
- /** Set 8.2.4.4 colormap blue value.
- * @param value Blue value
- */
- public void setColormapBlueValue (int [] value)
- {
- _colormapBlueValue = value;
- }
-
- /** Set 8.2.4.3 colormap green value.
- * @param value Green value
- */
- public void setColormapGreenValue (int [] value)
- {
- _colormapGreenValue = value;
- }
-
- /** Set 8.2.4.2 colormap red value.
- * @param value Red value
- */
- public void setColormapRedValue (int [] value)
- {
- _colormapRedValue = value;
- }
-
- /** Set 8.2.4.1 colormap reference.
- * @param reference Colormap reference
- */
- public void setColormapReference (String reference)
- {
- _colormapReference = reference;
- }
-
- /** Set 6.1.4.1 color space
- * @param space Color space
- */
- public void setColorSpace (int space)
- {
- _colorSpace = space;
- }
-
- /** Set 7.7.3.8 color temperature.
- * @param temp Color temperature
- */
- public void setColorTemp (double temp)
- {
- _colorTemp = temp;
- }
-
- /** Set 6.1.3.2 compression level.
- * @param level Compression level
- */
- public void setCompressionLevel (int level)
- {
- _compressionLevel = level;
- }
-
- /** Set 6.1.3.1 compression scheme.
- * @param scheme Compression scheme
- */
- public void setCompressionScheme (int scheme)
- {
- _compressionScheme = scheme;
- }
-
- /** Set 7.9 date/time created.
- * TIFF dates get converted to ISO 8601 format.
- * @param date Date/time created
- */
- public void setDateTimeCreated (String date)
- {
- _dateTimeCreated = make8601Valid (date);
- }
-
- /** Set 9.1.1 DateTimeProcessed.
- * TIFF dates get converted to ISO 8601 format.
- * @param date Date/time processed
- */
- public void setDateTimeProcessed (String date)
- {
- _dateTimeProcessed = make8601Valid (date);
- }
-
- /** Set 7.5 Device source.
- * @param source Device source
- */
- public void setDeviceSource (String source)
- {
- _deviceSource = source;
- }
-
- /** Set 7.7.1 digital camera manufacturer.
- * @param manufacturer Camera manufacturer
- */
- public void setDigitalCameraManufacturer (String manufacturer)
- {
- _digitalCameraManufacturer = manufacturer;
- }
-
- /** Set 7.7.2 digital camera model.
- * @param modelName Camera model
- */
- public void setDigitalCameraModelName (String modelName)
- {
- _digitalCameraModelName = modelName;
- }
- public void setDigitalCameraModelNumber (String modelNumber)
- {
- _digitalCameraModelNumber = modelNumber;
- }
- public void setDigitalCameraModelSerialNo (String modelSerialNo)
- {
- _digitalCameraModelSerialNo = modelSerialNo;
- }
-
- /** Set 6.2.5 display orientation.
- * @param orientation Display orientation
- */
- public void setDisplayOrientation (int orientation)
- {
- _displayOrientation = orientation;
- }
-
- public void setExifVersion (String version)
- {
- _exifVersion = version;
- }
-
- /** Set 7.2.3.4 exposure bias.
- * @param bias Exposure bias
- */
- public void setExposureBias (Rational bias)
- {
- _exposureBias = bias;
- }
-
- /** Set 7.2.3.14 exposure index.
- * @param index Exposure index
- */
- public void setExposureIndex (double index)
- {
- _exposureIndex = index;
- }
-
- public void setExposureProgram (int program)
- {
- _exposureProgram = program;
- }
-
- /** Set 7.7.3.2 exposure time.
- * @param time Exposure time
- */
- public void setExposureTime (double time)
- {
- _exposureTime = time;
- }
-
- /** Set 8.2.3 extra samples.
- * @param extra Extra samples
- */
- public void setExtraSamples (int [] extra)
- {
- _extraSamples = extra;
- }
-
- /** Set 6.2.2 file size.
- * @param size File size
- */
- public void setFileSize (long size)
- {
- _fileSize = size;
- }
-
- /** Set 7.7.3.1 F number.
- * @param f F number
- */
- public void setFNumber (double f)
- {
- _fNumber = f;
- }
-
- /** Set 7.7.3.11 flash energy.
- * @param energy Flash energy
- */
- public void setFlashEnergy (Rational energy)
- {
- _flashEnergy = energy;
- }
-
- /** Set 7.7.3.12 flash return.
- * @param ret Flash return
- */
- public void setFlashReturn (int ret)
- {
- _flashReturn = ret;
- }
-
- /** Set 7.7.3.10 flash.
- * @param flash Flash
- */
- public void setFlash (int flash)
- {
- _flash = flash;
- }
-
- /** Set 7.7.3.9 focal length (double meters).
- * @param length Focal length
- */
- public void setFocalLength (double length)
- {
- _focalLength = length;
- }
-
- /** Set 8.2.5 gray response curve.
- * @param curve Gray response curve
- */
- public void setGrayResponseCurve (int [] curve)
- {
- _grayResponseCurve = curve;
- }
-
- /** Set 8.2.6 gray response unit.
- * @param unit Gray response unit
- */
- public void setGrayResponseUnit (int unit)
- {
- _grayResponseUnit = unit;
- }
-
- /** Set 7.4 host computer.
- * @param computer Host computer
- */
- public void setHostComputer (String computer)
- {
- _hostComputer = computer;
- }
-
- /** Set 8.3.3 ImageData.
- * @param imageData Image Data filename or URN
- */
- public void setImageData (String imageData)
- {
- _imageData = imageData;
- }
-
- /** Set 6.2.1 Image identifier.
- * @param identifier Image identifier
- */
- public void setImageIdentifier (String identifier)
- {
- _imageIdentifier = identifier;
- }
-
- /** Set 6.2.1 Image identifier location.
- * @param location identifier location
- */
- public void setImageIdentifierLocation (String location)
- {
- _imageIdentifierLocation = location;
- }
-
- /** Set 8.1.6 image length.
- * @param length Image length
- */
- public void setImageLength (long length)
- {
- _imageLength = length;
- }
-
- /** Set 7.3 image producer.
- * @param producer Image producer
- */
- public void setImageProducer (String producer)
- {
- _imageProducer = producer;
- }
-
- /** Set 8.1.5 image width.
- * @param width Image width
- */
- public void setImageWidth (long width)
- {
- _imageWidth = width;
- }
-
- public void setMaxApertureValue (Rational value)
- {
- _maxApertureValue = value;
- }
-
- /** Set 7.7.3.6 metering mode.
- * @param mode Metering mode
- */
- public void setMeteringMode (int mode)
- {
- _meteringMode = mode;
- }
-
- /** Set 7.10 methodology.
- * @param methodology Methodology
- */
- public void setMethodology (String methodology)
- {
- _methodology = methodology;
- }
-
- /** Set 6.1.1 MIME type.
- * @param type MIME type
- */
- public void setMimeType (String type)
- {
- _mimeType = type;
- }
-
- /** Set 6.2.4 orientation.
- * @param orientation Orientation
- */
- public void setOrientation (int orientation)
- {
- _orientation = orientation;
- }
-
- /* Set 7.4.1 OS (operating system).
- * @param os Operating system
- */
- public void setOS (String os)
- {
- _os = os;
- }
-
- /** Set 7.4.2 OS version.
- * @param version OS version
- */
- public void setOSVersion (String version)
- {
- _osVersion = version;
- }
-
- /** Set 8.3.4 PerformanceData.
- * @param performanceData Performance data filename or URN
- */
- public void setPerformanceData (String performanceData)
- {
- _performanceData = performanceData;
- }
-
- /** Set 7.6.3.1 pixel size.
- * @param size Pixel size
- */
- public void setPixelSize (double size)
- {
- _pixelSize = size;
- }
-
- /** Set 6.1.6 Planar configuration.
- * @param configuration Planar configuration
- */
- public void setPlanarConfiguration (int configuration)
- {
- _planarConfiguration = configuration;
- }
-
- /** Set 6.3 preferred presentation.
- * @param presentation Preferred presentation
- */
- public void setPreferredPresentation (String presentation)
- {
- _preferredPresentation = presentation;
- }
-
- /** Set 8.2.8.5 primary chromaticities blue X.
- * @param x Blue x
- */
- public void setPrimaryChromaticitiesBlueX (Rational x)
- {
- _primaryChromaticitiesBlueX = x;
- }
-
- /** Set 8.2.8.6 primary chromaticities blue Y.
- * @param y Blue y
- */
- public void setPrimaryChromaticitiesBlueY (Rational y)
- {
- _primaryChromaticitiesBlueY = y;
- }
-
- /** Set 8.2.8.3 primary chromaticities green X.
- * @param x Green x
- */
- public void setPrimaryChromaticitiesGreenX (Rational x)
- {
- _primaryChromaticitiesGreenX = x;
- }
-
- /** Set 8.2.8.4 primary chromaticities green Y.
- * @param y Green y
- */
- public void setPrimaryChromaticitiesGreenY (Rational y)
- {
- _primaryChromaticitiesGreenY = y;
- }
-
- /** Set 8.2.8.1 primary chromaticities red X.
- * @param x Red x
- */
- public void setPrimaryChromaticitiesRedX (Rational x)
- {
- _primaryChromaticitiesRedX = x;
- }
-
- /** Set 8.2.8.2 primary chromaticities red Y.
- * @param y Red y
- */
- public void setPrimaryChromaticitiesRedY (Rational y)
- {
- _primaryChromaticitiesRedY = y;
- }
-
- /** Set 9.1.5 ProcessingActions.
- * @param actions Array of strings giving image processing steps
- */
- public void setProcessingActions (String[] actions)
- {
- _processingActions = actions;
- }
-
- /** Set 9.1.3 ProcessingAgency.
- * @param processingAgency Identifier of producing organization
- */
- public void setProcessingAgency (String processingAgency)
- {
- _processingAgency = processingAgency;
- }
-
- /** Set 9.1.4.1 ProcessingSoftwareName
- * @param name Name of the image processing software
- */
- public void setProcessingSoftwareName (String name)
- {
- _processingSoftwareName = name;
- }
-
- /** Set 9.1.4.2 ProcessingSoftwareVersion
- * @param version Version number of the processing software
- */
- public void setProcessingSoftwareVersion (String version)
- {
- _processingSoftwareVersion = version;
- }
-
- /** Set 6.1.4.1 ICC profile name.
- * @param name Profile name
- */
- public void setProfileName (String name)
- {
- _profileName = name;
- }
-
- /** Set 8.3.5 Profiles.
- * @param profiles Color profile filename or URN
- */
- public void setProfiles (String profiles)
- {
- _profiles = profiles;
- }
-
- /** Set 6.1.4.2 ICC profile URL.
- * @param URL Profile URL
- */
- public void setProfileURL (String URL)
- {
- _profileURL = URL;
- }
-
- /** Set 6.1.4.6 reference black and white.
- * @param reference Reference
- */
- public void setReferenceBlackWhite (Rational [] reference)
- {
- _referenceBlackWhite = reference;
- }
-
- /** Set 6.1.5.3 Rows per strip.
- * @param rows Rows per strip
- */
- public void setRowsPerStrip (long rows)
- {
- _rowsPerStrip = rows;
- }
-
- /** Set 8.1.1 sampling frequency plane.
- * @param plane Sampling frequency plane
- */
- public void setSamplingFrequencyPlane (int plane)
- {
- _samplingFrequencyPlane = plane;
- }
-
- /** Set 8.2.2 samples per pixel.
- * @param samples Samples per pixel
- */
- public void setSamplesPerPixel (int samples)
- {
- _samplesPerPixel = samples;
- }
-
- /** Set 8.1.2 sampling frequency unit.
- * @param unit Sampling frequency unit
- */
- public void setSamplingFrequencyUnit (int unit)
- {
- _samplingFrequencyUnit = unit;
- }
-
- /** Set 7.6.1.1 scanner manufacturer.
- * @param manufacturer Scanner manufacturer
- */
- public void setScannerManufacturer (String manufacturer)
- {
- _scannerManufacturer = manufacturer;
- }
-
- /** Set 7.6.1.2.1 scanner model name.
- * @param name Scanner model name
- */
- public void setScannerModelName (String name)
- {
- _scannerModelName = name;
- }
-
- /** Set 7.6.1.2.2 scanner model number.
- * @param number Scanner model number
- */
- public void setScannerModelNumber (String number)
- {
- _scannerModelNumber = number;
- }
-
- /** Set 7.6.1.2.3 scanner model serial number.
- * @param number Scanner model serial number
- */
- public void setScannerModelSerialNo (String number)
- {
- _scannerModelSerialNo = number;
- }
-
- /** Set 7.6.2.1 scanning software.
- * @param software Scanning software
- */
- public void setScanningSoftware (String software)
- {
- _scanningSoftware = software;
- }
-
- /** Set 7.6.2.2 scanning software version number.
- * @param number Scanning software version number
- */
- public void setScanningSoftwareVersionNo (String number)
- {
- _scanningSoftwareVersionNo = number;
- }
-
- /** Set 7.7.3.7 scene illuminant.
- * @param illuminant Scene illuminant
- */
- public void setSceneIlluminant (int illuminant)
- {
- _sceneIlluminant = illuminant;
- }
-
- /** Set 7.8 sensor.
- * @param sensor Sensor
- */
- public void setSensor (int sensor)
- {
- _sensor = sensor;
- }
-
- /** Set 9.1.2 SourceData.
- * @param sourceData Source data identifier
- */
- public void setSourceData (String sourceData)
- {
- _sourceData = sourceData;
- }
-
- /** Set 7.2 source ID.
- * @param id Source ID
- */
- public void setSourceID (String id)
- {
- _sourceID = id;
- }
-
- /** Set 7.1 source type.
- * @param type Source type
- */
- public void setSourceType (String type)
- {
- _sourceType = type;
- }
-
- /** Set 8.1.7 source X dimension.
- * @param x X dimension
- */
- public void setSourceXDimension (double x)
- {
- _sourceXDimension = x;
- }
-
- /** Set 8.1.7.1 source X dimension unit.
- * @param unit X dimension unit
- */
- public void setSourceXDimensionUnit (int unit)
- {
- _sourceXDimensionUnit = unit;
- }
-
- /** Set 8.1.8 source Y dimension.
- * @param y Y dimension
- */
- public void setSourceYDimension (double y)
- {
- _sourceYDimension = y;
- }
-
- /** Set 8.1.8.1 source Y dimension unit.
- * @param unit Y dimension unit
- */
- public void setSourceYDimensionUnit (int unit)
- {
- _sourceYDimensionUnit = unit;
- }
-
- /** Set 6.1.5.4 Strip byte counts.
- * @param counts Byte counts
- */
- public void setStripByteCounts (long [] counts)
- {
- _stripByteCounts = counts;
- }
-
- /** Set 6.1.5.2 Strip offsets.
- * @param offsets Strip offsets
- */
- public void setStripOffsets (long [] offsets)
- {
- _stripOffsets = offsets;
- }
-
- /** Set 7.7.3.5 Subject distance
- * @param distance Subject distance
- */
- public void setSubjectDistance (double [] distance)
- {
- _subjectDistance = distance;
- }
-
- /** Set 8.3.2.1 TargetIDManufacturer */
- public void setTargetIDManufacturer (String targetIDManufacturer)
- {
- _targetIDManufacturer = targetIDManufacturer;
- }
-
- /** Set 8.3.2.4 TargetIDMedia */
- public void setTargetIDMedia (String targetIDMedia)
- {
- _targetIDMedia = targetIDMedia;
- }
-
- /** Set 8.3.2.2 TargetIDName */
- public void setTargetIDName (String targetIDName)
- {
- _targetIDName = targetIDName;
- }
-
- /** Set 8.3.2.3 TargetIDNo */
- public void setTargetIDNo (String targetIDNo)
- {
- _targetIDNo = targetIDNo;
- }
-
- /** Set 8.3.1 TargetType */
- public void setTargetType (int targetType)
- {
- _targetType = targetType;
- }
-
- /** Set 6.1.5.8 Tile byte counts.
- * @param counts Byte counts
- */
- public void setTileByteCounts (long [] counts)
- {
- _tileByteCounts = counts;
- }
-
- /** Set 6.1.5.6 Tile length.
- * @param length Tile length
- */
- public void setTileLength (long length)
- {
- _tileLength = length;
- }
-
- /** Set 6.1.5.7 Tile offsets.
- * @param offsets tile offsets
- */
- public void setTileOffsets (long [] offsets)
- {
- _tileOffsets = offsets;
- }
-
- /** Set 6.1.5.5 Tile width.
- * @param width Tile width
- */
- public void setTileWidth (long width)
- {
- _tileWidth = width;
- }
-
- /** Set 8.2.7.1 white point X value.
- * @param x White point X
- */
- public void setWhitePointXValue (Rational x)
- {
- _whitePointXValue = x;
- }
-
- /** Set 8.2.7.2 white point Y value.
- * @param y White point Y
- */
- public void setWhitePointYValue (Rational y)
- {
- _whitePointYValue = y;
- }
-
- /** Set 7.6.3.2.1 X physical scanning resolution.
- * @param x X physical scanning resolution
- */
- public void setXPhysScanResolution (double x)
- {
- _xPhysScanResolution = x;
- }
-
- /** Set 7.7.3.16.1 X print aspect ratio.
- * @param x X aspect ratio
- */
- public void setXPrintAspectRatio (double x)
- {
- _xPrintAspectRatio = x;
- }
-
- /** Set 8.1.3 X sampling frequency.
- * @param x X sampling frequency
- */
- public void setXSamplingFrequency (Rational x)
- {
- _xSamplingFrequency = x;
- }
-
- /** Set 6.2.6.1 X targeted display aspect ratio.
- * @param x X units
- */
- public void setXTargetedDisplayAspectRatio (long x)
- {
- _xTargetedDisplayAR = x;
- }
-
- /** Set 6.1.4.5 YCbCr coefficients.
- * @param coefficients Coefficients
- */
- public void setYCbCrCoefficients (Rational [] coefficients)
- {
- _yCbCrCoefficients = coefficients;
- }
-
- /** Set 6.1.4.4 YCbCr positioning.
- * @param positioning Positioning
- */
- public void setYCbCrPositioning (int positioning)
- {
- _yCbCrPositioning = positioning;
- }
-
- /** Set 6.1.4.3 YCbCr Sub-sampling.
- * @param sampling Sub-sampling
- */
- public void setYCbCrSubSampling (int [] sampling)
- {
- _yCbCrSubSampling = sampling;
- }
-
- /** Set 7.6.3.2.2 Y physical scanning resolution.
- * @param y Y physical scanning resolution
- */
- public void setYPhysScanResolution (double y)
- {
- _yPhysScanResolution = y;
- }
-
- /** Set 7.7.3.16.2 Y print aspect ratio.
- * @param y Y aspect ratio
- */
- public void setYPrintAspectRatio (double y)
- {
- _yPrintAspectRatio = y;
- }
-
- /** Set 8.1.4 Y sampling frequency.
- * @param y Y sampling frequency
- */
- public void setYSamplingFrequency (Rational y)
- {
- _ySamplingFrequency = y;
- }
-
- /** Set 6.2.6.2 Y targeted display aspect ratio.
- * @param y Y units
- */
- public void setYTargetedDisplayAspectRatio (long y)
- {
- _yTargetedDisplayAR = y;
- }
-
- /** Set information for Swing GUI viewer.
- * @param viewerData Private data for RepTreeModel
- */
- public void setViewerData (Property viewerData)
- {
- _viewerData = viewerData;
- }
-
- /* Canonicizes (canonizes? whatever) a date to ISO
- * 8601 format. Returns null if it can't make sense of
- * it. Returns the date unchanged if it's already
- * canonical. Initially this converts TIFF dates to ISO.
- */
- private String make8601Valid (String date)
- {
- try {
- if (date.charAt (4) == ':') {
- // It's a TIFF date, or a good imitation of one.
- // TIFF dates have exact offsets, making things easy.
- String yr = date.substring (0, 4);
- String mo = date.substring (5, 7);
- String da = date.substring (8, 10);
- String hr = date.substring (11, 13);
- String mi = date.substring (14, 16);
- String se = date.substring (17, 19);
- return yr + "-" + mo + "-" + da + "T" +
- hr + TIME_SEP + mi + TIME_SEP + se;
- }
- return date; // default
- }
- catch (Exception e) {
- // Malformed date
- return null;
- }
- }
-
- public static String extractIccProfileDescription(byte[] data) throws IllegalArgumentException {
- // Validate the ICCProfile with the java library
- ICC_Profile profile = ICC_Profile.getInstance(data);
- // Extract the 'desc' record (cf http://www.color.org/ICC1-V41.pdf)
- byte[] dataProf = profile.getData(ICC_Profile.icSigProfileDescriptionTag);
- if (dataProf == null) {
- return null;
- }
-
- String description = null;
- ByteBuffer bb = ByteBuffer.wrap(dataProf).asReadOnlyBuffer();
- int majorVersion = profile.getMajorVersion();
- int minorVersion = profile.getMinorVersion();
- LOGGER.fine("Version " + majorVersion + "." + minorVersion);
-
- int beginTag = bb.getInt(0);
- if (beginTag == ICC_Profile.icSigProfileDescriptionTag) {
- // Invariant option
- // ICC v2 http://www.color.org/ICC_Minor_Revision_for_Web.pdf
- // Read only the ASCII form (cf 6.5.17 ICC v2)
- final int OFFSET_LENGTH = 8;
- final int OFFSET_DESC = OFFSET_LENGTH + 4;
-
- int lengthAscii = bb.getInt(OFFSET_LENGTH);
-
- // readString
- byte[] asciiDesc = new byte[lengthAscii -1];
- bb.position(OFFSET_DESC);
- bb.get(asciiDesc);
-
- description = new String(asciiDesc, StandardCharsets.US_ASCII);
- } else {
- // ICC v4 http://www.color.org/ICC1-V41.pdf
- final int OFFSET_NUMBER = 8;
- final int MLUC_TAG = 0x6D6C7563;
- final int OFFSET_NAME_LENGTH = 20;
- final int OFFSET_NAME_OFFSET = 24;
-
- // 6.2 segment tag table definition
- int tagMluc = bb.getInt(0);
-
- // Read the 1st mulc form (cf 6.5.12 ICC v4)
- int nb = bb.getInt(OFFSET_NUMBER);
- if (tagMluc != MLUC_TAG || nb < 1) {
- throw new IllegalArgumentException(CoreMessageConstants.ERR_ICC_PRFL_DESC_MISS);
- }
- int firstNameLength = bb.getInt(OFFSET_NAME_LENGTH);
- int firstNameOffset = bb.getInt(OFFSET_NAME_OFFSET);
- // readString
- byte[] desc = new byte[firstNameLength];
- bb.position(firstNameOffset);
- bb.get(desc);
-
- // The Unicode strings in storage are encoded as 16-bit
- // big-endian, UTF-16BE, and should not be NULL terminated.
- description = new String(desc, StandardCharsets.UTF_16BE);
- }
- return description;
- }
-
+ };
+
+ /** Index for 6.1.4.1 color space value labels. */
+ public static final int[] COLORSPACE_INDEX = {
+ 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 32803, 32844, 32845, 34892, 65535
+ };
+
+ /** 6.1.3.1 Compression scheme value labels. */
+ /* Taken from the TIFFTAG_COMPRESSION */
+ public static final String[] COMPRESSION_SCHEME = {
+ "uncompressed",
+ "CCITT 1D",
+ "CCITT Group 3",
+ "CCITT Group 4", /* 1-4 */
+ "LZW",
+ "JPEG",
+ "ISO JPEG",
+ "Deflate", /* 5-8 */
+ "JBIG", /* 32661 */
+ "RLE with word alignment", /* 32771 */
+ "PackBits",
+ "NeXT 2-bit encoding",
+ "ThunderScan 4-bit encoding", /* 32773- */
+ "RasterPadding in CT or MP", /* 32895 */
+ "RLE for LW",
+ "RLE for HC",
+ "RLE for BL", /* 32896-8 */
+ "Pixar 10-bit LZW", /* 32908 */
+ "Pixar companded 11-bit ZIP encoding", /* 32909 */
+ "PKZIP-style Deflate encoding", /* 32946 */
+ "Kodak DCS", /* 32947 */
+ "SGI 32-bit Log Luminance encoding", /* 34676 */
+ "SGI 24-bit Log Luminance encoding", /* 34677 */
+ "JPEG 2000", /* 34712 */
+ "JPEG2000 Lossy", /* 34713 non standard !!! */
+ "JPEG2000 Lossless", /* 34714 non standard !!! */
+ "LZMA" /* 34925 */
+ };
+ /** Index for 6.1.3.1 compression scheme value labels. */
+ public static final int COMPRESSION_JPEG2000_LOSSY = 34713;
+
+ public static final int COMPRESSION_JPEG2000_LOSSLESS = 34714;
+ public static final int[] COMPRESSION_SCHEME_INDEX = {
+ 1, 2, 3, 4, 5, 6, 7, 8, 32661, 32771, 32773, 32766, 32809, 32895, 32896, 32897, 32898, 32908,
+ 32909, 32946, 32947, 34676, 34677, 34712, 34713, /* non standard !!! */
+ 34714, /* non standard !!! */ 34925
+ };
+
+ /** 6.2.5 display orientation value labels. */
+ public static final String[] DISPLAY_ORIENTATION = {"portrait", "landscape"};
+
+ public static final String[] EXTRA_SAMPLES = {
+ "unspecified", "associated alpha", "unassociated alpha", "range or depth"
+ };
+
+ public static final String[] EXPOSURE_PROGRAM = {
+ "Not defined",
+ " Manual",
+ "Normal program",
+ "Aperture priority",
+ "Shutter priority",
+ "Creative program (biased toward depth of field)",
+ "Action program (biased toward fast shutter speed)",
+ "Portrait mode (for closeup photos with the background out of focus)",
+ "Landscape mode (for landscape photos with the background in focus)"
+ };
+
+ /** 7.7.3.10 flash value labels. */
+ public static final String[] FLASH = {NO, YES};
+
+ public static final String[] FLASH_20 = {"Flash did not fire", "Flash fired"};
+
+ /** 7.7.3.12 flash return value labels. */
+ public static final String[] FLASH_RETURN = {YES, NO};
+
+ /** 8.2.6 gray response unit value labels for version 0.2. */
+ public static final String[] GRAY_RESPONSE_UNIT_02 = {
+ "",
+ "tenths of a unit",
+ "hundredths of a unit",
+ "thousandths of a unit",
+ "ten-thousandths of a unit",
+ "hundred-thousandths of a unit"
+ };
+
+ /** Gray response unit value for version 2.0 of MIX, corresponding to NISO values of 1-5 */
+ public static final String[] GRAY_RESPONSE_UNIT_20 = {
+ "Number represents tenths of a unit",
+ "Number represents hundredths of a unit",
+ "Number represents thousandths of a unit",
+ "Number represents ten-thousandths of a unit",
+ "Number represents hundred-thousandths of a unit"
+ };
+
+ /** extra sample value for version 2.0 of MIX, corresponding to NISO values of 0-3 * */
+ public static final String[] EXTRA_SAMPLE_20 = {
+ "unspecified data",
+ "associated alpha data (with pre-multiplied color)",
+ "unassociated alpha data",
+ "range or depth data"
+ };
+
+ /** 7.7.3.6 metering mode value labels. */
+ public static final String[] METERING_MODE = {
+ "unidentified", "average", "center weighted average", "spot", "multispot", "pattern", "partial"
+ };
+
+ /** 6.2.4 orientation value labels. */
+ public static final String[] ORIENTATION = {
+ "",
+ "normal",
+ "reflected horiz",
+ "rotated 180 deg",
+ "reflected vert",
+ "left top",
+ "rotated cw 90 deg",
+ "Right bottom",
+ "Rotated ccw 90 deg",
+ "Unknown"
+ };
+
+ /** 6.1.6 planar configuration value labels. */
+ public static final String[] PLANAR_CONFIGURATION = {"", "chunky", "planar"};
+
+ /** 8.1.1 sampling frequency plane value labels. */
+ public static final String[] SAMPLING_FREQUENCY_PLANE = {
+ "", "camera/scanner focal plane", "object plane", "source object plane"
+ };
+
+ /** 8.1.2 sampling frequency unit value labels. */
+ public static final String[] SAMPLING_FREQUENCY_UNIT = {
+ "", "no absolute unit", "inch", "centimeter"
+ };
+
+ /** 7.7.3.7 scene illuminant value labels. */
+ public static final String[] SCENE_ILLUMINANT = {
+ "unidentified",
+ "daylight",
+ "fluorescent",
+ "tungsten lamp",
+ "flash",
+ "standard illuminant A",
+ "standard illuminat B",
+ "standard illuminant C",
+ "D55 illuminant",
+ "D65 illuminant",
+ "D75 illuminant"
+ };
+ /** Index for 7.7.3.7 scene illuminant value labels. */
+ public static final int[] SCENE_ILLUMINANT_INDEX = {0, 1, 2, 3, 10, 17, 18, 19, 20, 21, 22};
+
+ /** 6.1.5.1 segment type value labels. */
+ public static final String[] SEGMENT_TYPE = {"strips", "tiles"};
+
+ /** 7.8 sensor value labels. */
+ public static final String[] SENSOR = {
+ "Undefined",
+ "MonochromeArea",
+ "OneChipColorArea",
+ "TwoChipColorArea",
+ "ThreeChipColorArea",
+ "ColorSequentialArea",
+ "MonochromeLinear",
+ "ColorTriLinear",
+ "ColorSequentialLinear"
+ };
+
+ /** 8.1.7.1 (8.1.8.1) source dimension unit. */
+ public static final String[] SOURCE_DIMENSION_UNIT = {"inches", "mm"};
+
+ /** 6.1.4.4 YCbCr positioning value labels. */
+ public static final String[] YCBCR_POSITIONING = {"", "centered", "cosited"};
+
+ /** 8.3.1 TargetType. */
+ public static final String[] TARGET_TYPE = {"external", "internal"};
+
+ /** Undefined value. */
+ public static final int NULL = -1;
+
+ public static final double NILL = -1.0;
+
+ /**
+ * **************************************************************** PRIVATE INSTANCE FIELDS.
+ *
+ * NisoImageMetadata
object. */
+ public NisoImageMetadata() {
+ _autoFocus = NULL;
+ _backLight = NULL;
+ _brightness = null;
+ _checksumMethod = NULL;
+ _colorSpace = NULL;
+ _colorTemp = NILL;
+ _compressionLevel = NULL;
+ _compressionScheme = NULL;
+ _dateTimeProcessed = null;
+ _digitalCameraManufacturer = null;
+ _digitalCameraModelName = null;
+ _digitalCameraModelNumber = null;
+ _digitalCameraModelSerialNo = null;
+ _displayOrientation = NULL;
+ _exifVersion = null;
+ _exposureBias = null;
+ _exposureIndex = NILL;
+ _exposureProgram = NULL;
+ _exposureTime = NILL;
+ _fileSize = NULL;
+ _flash = NULL;
+ _flashEnergy = null;
+ _flashReturn = NULL;
+ _fNumber = NILL;
+ _focalLength = NILL;
+ _grayResponseUnit = NULL;
+ _imageData = null;
+ _imageLength = NULL;
+ _imageWidth = NULL;
+ _jp2Layers = NULL;
+ _jp2ResolutionLevels = NULL;
+ _jp2Tiles = null;
+ _maxApertureValue = null;
+ _meteringMode = NULL;
+ _orientation = NULL;
+ _performanceData = null;
+ _pixelSize = NILL;
+ _planarConfiguration = NULL;
+ _processingActions = null;
+ _processingAgency = null;
+ _processingSoftwareName = null;
+ _processingSoftwareVersion = null;
+ _profiles = null;
+ _rowsPerStrip = NULL;
+ _scannerManufacturer = null;
+ _scannerModelName = null;
+ _scannerModelNumber = null;
+ _scannerModelSerialNo = null;
+ _samplesPerPixel = NULL;
+ _samplingFrequencyPlane = NULL;
+ _samplingFrequencyUnit = NULL;
+ _sceneIlluminant = NULL;
+ _segmentType = NULL;
+ _sensor = NULL;
+ _sourceData = null;
+ _sourceXDimension = NILL;
+ _sourceXDimensionUnit = NULL;
+ _sourceYDimension = NILL;
+ _sourceYDimensionUnit = NULL;
+ _tileLength = NULL;
+ _tileWidth = NULL;
+ _targetIDManufacturer = null;
+ _targetIDMedia = null;
+ _targetIDName = null;
+ _targetIDNo = null;
+ _targetType = NULL;
+ _xPhysScanResolution = NILL;
+ _xPrintAspectRatio = NILL;
+ _xSamplingFrequency = null;
+ _xTargetedDisplayAR = NULL;
+ _yCbCrPositioning = NULL;
+ _yPhysScanResolution = NILL;
+ _yPrintAspectRatio = NILL;
+ _ySamplingFrequency = null;
+ _yTargetedDisplayAR = NULL;
+ _viewerData = null;
+ }
+
+ /**
+ * **************************************************************** PUBLIC INSTANCE METHODS.
+ *
+ * PropertyType
.
+ * This class encapsulates arbitrary format-specific properties. A Property's value can be a simple
+ * object or a structure. If it is a simple object, it has arity SCALAR. If it is a structure, it
+ * must be a Map, List, Set, or array, with the corresponding arity. The simple object (in the case
+ * of arity SCALAR) or the components of the structure must have a type corresponding to one of the
+ * enumerations given by PropertyType
.
*
- * The components of a Property may themselves be Property
- * objects, allowing nested structures.
+ * type
.
- */
- public Property (String name, PropertyType type, Object value)
- {
- init (name, type, PropertyArity.SCALAR, value);
- }
-
- /**
- * Creates a Property with a given name, type, arity and value.
- *
- * @param name The displayable name of the property.
- * @param type The type of property.
- * @param arity The arity of the property.
- * @param value The value of the property. If the arity is
- * SCALAR, the type of this parameter must agree
- * with type
. Otherwise, the arity
- * must agree with arity
, and its
- * components must agree with type
.
- */
- public Property (String name, PropertyType type, PropertyArity arity,
- Object value)
- {
- init (name, type, arity, value);
- }
-
- private void init (String name, PropertyType type, PropertyArity arity,
- Object value)
- {
- /* Some limited type checking. Checking for mismatched
- types here may help avoid difficult chasing down
- of the bugs such mismatches cause. */
- if (value == null) {
- throw new NullPointerException (CoreMessageConstants.EXC_PROP_VAL_NULL);
- }
- if ((arity == PropertyArity.SCALAR) && !isObjScalarProp(value)) {
- throw new IncompatibleClassChangeError
- (String.format(CoreMessageConstants.EXC_SCL_PROP_CLSS_INCMPT, CoreMessageConstants.EXC_PROP_CLSS_INCMPT));
- }
- else if ((arity == PropertyArity.MAP) && (!(value instanceof Map))) {
- throw new IncompatibleClassChangeError
- (String.format(CoreMessageConstants.EXC_MAP_PROP_CLSS_INCMPT, CoreMessageConstants.EXC_PROP_CLSS_INCMPT));
- }
- else if ((arity == PropertyArity.SET) && (!(value instanceof Set))) {
- throw new IncompatibleClassChangeError
- (String.format(CoreMessageConstants.EXC_SET_PROP_CLSS_INCMPT, CoreMessageConstants.EXC_PROP_CLSS_INCMPT));
- }
- else if ((arity == PropertyArity.LIST) && (!(value instanceof List))) {
- throw new IncompatibleClassChangeError
- (String.format(CoreMessageConstants.EXC_LIST_PROP_CLSS_INCMPT, CoreMessageConstants.EXC_PROP_CLSS_INCMPT));
- }
-
- _name = name;
- _type = type;
- _arity = arity;
- _value = value;
- }
-
- private static boolean isObjScalarProp(Object toTest) {
- return !(toTest instanceof List ||
- toTest instanceof Map ||
- toTest instanceof Set);
+public class Property {
+ /**
+ * **************************************************************** PRIVATE INSTANCE FIELDS.
+ * ****************************************************************
+ */
+ private String _name;
+
+ private PropertyType _type;
+ private PropertyArity _arity;
+ private Object _value;
+
+ /**
+ * **************************************************************** CLASS CONSTRUCTOR.
+ * ****************************************************************
+ */
+
+ /**
+ * Creates a Property with arity SCALAR.
+ *
+ * @param name The displayable name of the property
+ * @param type The type of property
+ * @param value The value of the property. The type of the parameter must agree with type
+ *
.
+ */
+ public Property(String name, PropertyType type, Object value) {
+ init(name, type, PropertyArity.SCALAR, value);
+ }
+
+ /**
+ * Creates a Property with a given name, type, arity and value.
+ *
+ * @param name The displayable name of the property.
+ * @param type The type of property.
+ * @param arity The arity of the property.
+ * @param value The value of the property. If the arity is SCALAR, the type of this parameter must
+ * agree with type
. Otherwise, the arity must agree with arity
, and
+ * its components must agree with type
.
+ */
+ public Property(String name, PropertyType type, PropertyArity arity, Object value) {
+ init(name, type, arity, value);
+ }
+
+ private void init(String name, PropertyType type, PropertyArity arity, Object value) {
+ /* Some limited type checking. Checking for mismatched
+ types here may help avoid difficult chasing down
+ of the bugs such mismatches cause. */
+ if (value == null) {
+ throw new NullPointerException(CoreMessageConstants.EXC_PROP_VAL_NULL);
}
- /******************************************************************
- * PUBLIC INSTANCE METHODS.
- *
- * Accessor methods.
- ******************************************************************/
-
- /**
- * Returns the arity (type of structure) of this Property.
- */
- public PropertyArity getArity ()
- {
- return _arity;
+ if ((arity == PropertyArity.SCALAR) && !isObjScalarProp(value)) {
+ throw new IncompatibleClassChangeError(
+ String.format(
+ CoreMessageConstants.EXC_SCL_PROP_CLSS_INCMPT,
+ CoreMessageConstants.EXC_PROP_CLSS_INCMPT));
+ } else if ((arity == PropertyArity.MAP) && (!(value instanceof Map))) {
+ throw new IncompatibleClassChangeError(
+ String.format(
+ CoreMessageConstants.EXC_MAP_PROP_CLSS_INCMPT,
+ CoreMessageConstants.EXC_PROP_CLSS_INCMPT));
+ } else if ((arity == PropertyArity.SET) && (!(value instanceof Set))) {
+ throw new IncompatibleClassChangeError(
+ String.format(
+ CoreMessageConstants.EXC_SET_PROP_CLSS_INCMPT,
+ CoreMessageConstants.EXC_PROP_CLSS_INCMPT));
+ } else if ((arity == PropertyArity.LIST) && (!(value instanceof List))) {
+ throw new IncompatibleClassChangeError(
+ String.format(
+ CoreMessageConstants.EXC_LIST_PROP_CLSS_INCMPT,
+ CoreMessageConstants.EXC_PROP_CLSS_INCMPT));
}
- /**
- * Return a property by its name, regardless of its position in the
- * structural hierarchy of properties.
- * @param name Property name
- * @return Named property (or null)
- */
- public Property getByName (String name)
- {
- if (_name.equals (name)) {
- return this;
- }
-
- if (!_arity.equals (PropertyArity.SCALAR) &&
- _type.equals (PropertyType.PROPERTY)) {
- if (_arity.equals (PropertyArity.ARRAY)) {
- Property [] array = (Property []) _value;
- for (int i=0; i