Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX - NISO 1.0 Format Designation #323

Merged
merged 3 commits into from
Mar 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* 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
Expand All @@ -35,13 +35,15 @@ public class TextHandler
******************************************************************/

private static final String NAME = "TEXT";
private static final String RELEASE = "1.5";
private static final int [] DATE = {2009, 10, 14};
private static final String RELEASE = "1.6-RC";
private static final int [] DATE = {2018, 03, 16};
private static final String NOTE = "This is the default JHOVE output " +
"handler";
private static final String RIGHTS = "Copyright 2003-2009 by JSTOR and " +
"the President and Fellows of Harvard College. " +
"Released under the terms of the GNU Lesser General Public License.";
private static final String RIGHTS =
"Derived from software Copyright 2004-2011 " +
"by the President and Fellows of Harvard College. " +
"Version 1.6 release by Open Preservation Foundation. " +
"Released under the GNU Lesser General Public License.";

private NumberFormat _format;

Expand Down Expand Up @@ -139,7 +141,7 @@ public void show (App app)

/**
* Outputs information about the OutputHandler specified
* in the parameter
* in the parameter
*/
public void show (OutputHandler handler)
{
Expand Down Expand Up @@ -285,26 +287,26 @@ public void show (RepInfo info)
case RepInfo.TRUE:
s = "Well-Formed";
break;

case RepInfo.FALSE:
s = "Not well-formed";
break;

default:
s = "Unknown";
break;
}
if (info.getWellFormed () == RepInfo.TRUE) {
switch (info.getValid ()) {

case RepInfo.TRUE:
s += " and valid";
break;

case RepInfo.FALSE:
s += ", but not valid";
break;

// case UNDETERMINED: add nothing
}
}
Expand All @@ -317,7 +319,7 @@ public void show (RepInfo info)
case RepInfo.TRUE:
s = "Well-Formed";
break;

default:
s = "Not well-formed";
break;
Expand All @@ -329,7 +331,7 @@ public void show (RepInfo info)
if (n > 0) {
_writer.println (margin + " SignatureMatches:");
for (int i = 0; i < n; i++) {
_writer.println (margin + " " +
_writer.println (margin + " " +
(String) list.get (i));
}
}
Expand Down Expand Up @@ -595,7 +597,7 @@ else if (PropertyType.AESAUDIOMETADATA.equals (type)) {
margin + " ", _je.getShowRawFlag ());
}
else if (PropertyType.TEXTMDMETADATA.equals(type)) {
showTextMDMetadata((TextMDMetadata) property.getValue(),
showTextMDMetadata((TextMDMetadata) property.getValue(),
margin + " ", _je.getShowRawFlag ());
}
else {
Expand All @@ -609,7 +611,7 @@ private void showListProperty (Property property, String margin)
boolean valueIsProperty = PropertyType.PROPERTY.equals (type);
boolean valueIsNiso = PropertyType.NISOIMAGEMETADATA.equals (type);
boolean valueIsTextMD = PropertyType.TEXTMDMETADATA.equals(type);

List list = (List) property.getValue ();

int n = list.size ();
Expand Down Expand Up @@ -686,7 +688,7 @@ else if (valueIsTextMD) {
}
}

private void showSetProperty (Property property,
private void showSetProperty (Property property,
String margin) {
PropertyType type = property.getType ();
boolean valueIsProperty = PropertyType.PROPERTY.equals (type);
Expand All @@ -713,7 +715,7 @@ else if (valueIsTextMD) {
else {
if (first) {
_writer.print (val.toString ());
first = false;
first = false;
}
else {
_writer.print (", " + val.toString ());
Expand Down Expand Up @@ -876,7 +878,7 @@ else if (PropertyType.PROPERTY.equals (propType)) {
}
if (propType != PropertyType.PROPERTY &&
propType != PropertyType.NISOIMAGEMETADATA) {
_writer.println ();
_writer.println ();
}
}

Expand Down Expand Up @@ -944,15 +946,15 @@ private void showAESAudioMetadata (AESAudioMetadata aes, String margin,
s = aes.getSchemaVersion ();
if (s != null) {
_writer.println (margn2 + "SchemaVersion: " + s);
}
}
s = aes.getFormat ();
if (s != null) {
_writer.println (margn2 + "Format: " + s);
}
}
s = aes.getSpecificationVersion ();
if (s != null) {
_writer.println (margn2 + "SpecificationVersion: " + s);
}
}
s = aes.getAppSpecificData();
if (s != null) {
_writer.println (margn2 + "AppSpecificData: " + s);
Expand Down Expand Up @@ -989,7 +991,7 @@ private void showAESAudioMetadata (AESAudioMetadata aes, String margin,
List facelist = aes.getFaceList ();
if (!facelist.isEmpty ()) {
// Add the face information, which is mostly filler.
AESAudioMetadata.Face f =
AESAudioMetadata.Face f =
(AESAudioMetadata.Face) facelist.get(0);
_writer.println (margn2 + "Face: ");
_writer.println (margn3 + "TimeLine: ");
Expand Down Expand Up @@ -1017,7 +1019,7 @@ private void showAESAudioMetadata (AESAudioMetadata aes, String margin,
// iteration loop on formatList.
List flist = aes.getFormatList ();
if (!flist.isEmpty ()) {
AESAudioMetadata.FormatRegion rgn =
AESAudioMetadata.FormatRegion rgn =
(AESAudioMetadata.FormatRegion) flist.get(0);
int bitDepth = rgn.getBitDepth ();
double sampleRate = rgn.getSampleRate ();
Expand All @@ -1041,9 +1043,9 @@ private void showAESAudioMetadata (AESAudioMetadata aes, String margin,
}
if (bitRed != null) {
_writer.println (margn4 + "BitrateReduction");
_writer.println (margn5 +
_writer.println (margn5 +
"CodecName: " + bitRed[0]);
_writer.println (margn5 +
_writer.println (margn5 +
"codecNameVersion: " + bitRed[1]);
_writer.println (margn5 +
"codecCreatorApplication: " + bitRed[2]);
Expand Down Expand Up @@ -1084,11 +1086,11 @@ private void writeAESTimeRange (String baseIndent,
}
_writer.println (margn3 + "SampleRate: S" +
Integer.toString ((int) sr));
_writer.println (margn3 + "NumberOfSamples: " +
_writer.println (margn3 + "NumberOfSamples: " +
Integer.toString (start.getSamples ()));
_writer.println (margn2 + "FilmFraming: NOT_APPLICABLE");
_writer.println (margn3 + "Type: ntscFilmFramingType");

if (duration != null) {
_writer.println (margn1 + "Duration:");
_writer.println (margn2 + "FrameCount: 30");
Expand All @@ -1110,13 +1112,13 @@ private void writeAESTimeRange (String baseIndent,
}
_writer.println (margn3 + "SampleRate: S" +
Integer.toString ((int) sr));
_writer.println (margn3 + "NumberOfSamples: " +
_writer.println (margn3 + "NumberOfSamples: " +
Integer.toString (duration.getSamples ()));
_writer.println (margn2 + "FilmFraming: NOT_APPLICABLE");
_writer.println (margn3 + "Type: ntscFilmFramingType");
}
}


/**
* Display the NISO image metadata formatted according to
Expand Down Expand Up @@ -1248,7 +1250,7 @@ private void showNisoImageMetadata02 (NisoImageMetadata niso, String margin,
_writer.println ();
}
if ((n = niso.getPlanarConfiguration ()) != NisoImageMetadata.NULL) {
_writer.println (margn2 + "PlanarConfiguration: " +
_writer.println (margn2 + "PlanarConfiguration: " +
addIntegerValue (n, NisoImageMetadata.PLANAR_CONFIGURATION,
rawOutput));
}
Expand All @@ -1262,20 +1264,20 @@ private void showNisoImageMetadata02 (NisoImageMetadata niso, String margin,
_writer.println (margn2 + "FileSize: " + ln);
}
if ((n = niso.getChecksumMethod ()) != NisoImageMetadata.NULL) {
_writer.println (margn2 + "ChecksumMethod: " +
_writer.println (margn2 + "ChecksumMethod: " +
addIntegerValue (n, NisoImageMetadata.CHECKSUM_METHOD,
rawOutput));
}
if ((s = niso.getChecksumValue ()) != null) {
_writer.println (margn2 + "ChecksumValue: " + s);
}
if ((n = niso.getOrientation ()) != NisoImageMetadata.NULL) {
_writer.println (margn2 + "Orientation: " +
_writer.println (margn2 + "Orientation: " +
addIntegerValue (n, NisoImageMetadata.ORIENTATION,
rawOutput));
}
if ((n = niso.getDisplayOrientation ()) != NisoImageMetadata.NULL) {
_writer.println (margn2 + "DisplayOrientation: " +
_writer.println (margn2 + "DisplayOrientation: " +
addIntegerValue (n, NisoImageMetadata.DISPLAY_ORIENTATION,
rawOutput));
}
Expand Down Expand Up @@ -1359,7 +1361,7 @@ private void showNisoImageMetadata02 (NisoImageMetadata niso, String margin,
if ((d = niso.getExposureBias ()) != NisoImageMetadata.NILL) {
_writer.println (margn2 + "ExposureBias: " + d);
}

double [] darray = niso.getSubjectDistance ();
if (darray != null) {
_writer.print (margn2 + "SubjectDistance: " + darray[0]);
Expand Down Expand Up @@ -1446,7 +1448,7 @@ private void showNisoImageMetadata02 (NisoImageMetadata niso, String margin,
}
r = niso.getYSamplingFrequency ();
if (r != null) {
_writer.println (margn2 + "YSamplingFrequency: " +
_writer.println (margn2 + "YSamplingFrequency: " +
addRationalValue (r, rawOutput));
}
if ((ln = niso.getImageWidth ()) != NisoImageMetadata.NULL) {
Expand Down Expand Up @@ -1570,8 +1572,8 @@ private void showNisoImageMetadata02 (NisoImageMetadata niso, String margin,
}
if ((n = niso.getTargetType ()) != NisoImageMetadata.NULL) {
_writer.println (margn2 + "TargetType: " +
addIntegerValue (n, NisoImageMetadata.TARGET_TYPE, rawOutput));
}
addIntegerValue (n, NisoImageMetadata.TARGET_TYPE, rawOutput));
}
if ((s = niso.getTargetIDManufacturer ()) != null) {
_writer.println (margn2 + "TargetIDManufacturer: " + s);
}
Expand Down Expand Up @@ -1632,6 +1634,9 @@ private void showNisoImageMetadata10 (NisoImageMetadata niso, String margin,
if ((ln = niso.getFileSize ()) != NisoImageMetadata.NULL) {
_writer.println (margn2 + "FileSize: " + ln);
}
if ((s = niso.getMimeType()) != null) {
_writer.println (margn2 + "FormatName: " + s);
}
if ((s = niso.getByteOrder ()) != null) {
// Convert strings to MIX 1.0 form
if (s.startsWith ("big")) {
Expand All @@ -1653,7 +1658,7 @@ else if (s.startsWith ("little")) {
_writer.println (margn2 + "CompressionLevel: " + n);
}
if ((n = niso.getChecksumMethod ()) != NisoImageMetadata.NULL) {
_writer.println (margn2 + "ChecksumMethod: " +
_writer.println (margn2 + "ChecksumMethod: " +
addIntegerValue (n, NisoImageMetadata.CHECKSUM_METHOD,
rawOutput));
}
Expand Down Expand Up @@ -1753,7 +1758,7 @@ else if (s.startsWith ("little")) {
double yres = niso.getYPhysScanResolution();
if (xres != NisoImageMetadata.NULL && yres != NisoImageMetadata.NULL) {
double res = (xres > yres ? xres : yres);
_writer.println (margn2 +
_writer.println (margn2 +
"MaximumOpticalResolution: " + Double.toString (res));
}
if ((s = niso.getScanningSoftware ()) != null) {
Expand Down Expand Up @@ -1782,14 +1787,14 @@ else if (s.startsWith ("little")) {
}
Rational r;
if ((r = niso.getMaxApertureValue ()) != null) {
_writer.println (margn2 + "MaxApertureValue: " +
_writer.println (margn2 + "MaxApertureValue: " +
addRationalValue (r, rawOutput));
}
if ((d = niso.getExposureTime ()) != NisoImageMetadata.NILL) {
_writer.println (margn2 + "ExposureTime: " + _format.format(d));
}
if ((n = niso.getExposureProgram ()) != NisoImageMetadata.NULL) {
_writer.println (margn2 + "ExposureProgram: " +
_writer.println (margn2 + "ExposureProgram: " +
addIntegerValue (n, NisoImageMetadata.EXPOSURE_PROGRAM,
rawOutput));
}
Expand Down Expand Up @@ -1843,7 +1848,7 @@ else if (s.startsWith ("little")) {
_writer.println (margn2 + "YPrintAspectRatio: " + d);
}
if ((n = niso.getOrientation ()) != NisoImageMetadata.NULL) {
_writer.println (margn2 + "Orientation: " +
_writer.println (margn2 + "Orientation: " +
addIntegerValue (n, NisoImageMetadata.ORIENTATION,
rawOutput));
}
Expand All @@ -1868,7 +1873,7 @@ else if (s.startsWith ("little")) {
}
r = niso.getYSamplingFrequency ();
if (r != null) {
_writer.println (margn2 + "YSamplingFrequency: " +
_writer.println (margn2 + "YSamplingFrequency: " +
addRationalValue (r, rawOutput));
}
if ((iarray = niso.getBitsPerSample ()) != null) {
Expand Down Expand Up @@ -1946,8 +1951,8 @@ else if (s.startsWith ("little")) {
}
if ((n = niso.getTargetType ()) != NisoImageMetadata.NULL) {
_writer.println (margn2 + "TargetType: " +
addIntegerValue (n, NisoImageMetadata.TARGET_TYPE, rawOutput));
}
addIntegerValue (n, NisoImageMetadata.TARGET_TYPE, rawOutput));
}
if ((s = niso.getTargetIDManufacturer ()) != null) {
_writer.println (margn2 + "TargetIDManufacturer: " + s);
}
Expand Down Expand Up @@ -1995,8 +2000,8 @@ else if (s.startsWith ("little")) {


}


private String addIntegerValue (int value, String [] labels,
boolean rawOutput)
{
Expand Down
Loading