Skip to content

Commit

Permalink
Use getIndexedDescription
Browse files Browse the repository at this point in the history
Also allow conversion from StringValue to Long in Directory.
  • Loading branch information
drewnoakes committed Jan 22, 2024
1 parent 540c58d commit 67dfddd
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 37 deletions.
10 changes: 9 additions & 1 deletion Source/com/drew/metadata/Directory.java
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,15 @@ public Long getLongObject(int tagType)
try {
return Long.parseLong(o.toString());
} catch (NumberFormatException nfe) {
return null;
// convert the char array to an int
String s = o.toString();
byte[] bytes = s.getBytes();
long val = 0;
for (byte aByte : bytes) {
val = val << 8;
val += (aByte & 0xff);
}
return val;
}
} else if (o instanceof Rational[]) {
Rational[] rationals = (Rational[])o;
Expand Down
68 changes: 32 additions & 36 deletions Source/com/drew/metadata/iptc/IptcDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,42 +103,38 @@ public String getTimeDescription(int tagType)
@Nullable
public String getFileFormatDescription()
{
Integer value = _directory.getInteger(TAG_FILE_FORMAT);
if (value == null)
return null;
switch (value) {
case 0: return "No ObjectData";
case 1: return "IPTC-NAA Digital Newsphoto Parameter Record";
case 2: return "IPTC7901 Recommended Message Format";
case 3: return "Tagged Image File Format (Adobe/Aldus Image data)";
case 4: return "Illustrator (Adobe Graphics data)";
case 5: return "AppleSingle (Apple Computer Inc)";
case 6: return "NAA 89-3 (ANPA 1312)";
case 7: return "MacBinary II";
case 8: return "IPTC Unstructured Character Oriented File Format (UCOFF)";
case 9: return "United Press International ANPA 1312 variant";
case 10: return "United Press International Down-Load Message";
case 11: return "JPEG File Interchange (JFIF)";
case 12: return "Photo-CD Image-Pac (Eastman Kodak)";
case 13: return "Bit Mapped Graphics File [.BMP] (Microsoft)";
case 14: return "Digital Audio File [.WAV] (Microsoft & Creative Labs)";
case 15: return "Audio plus Moving Video [.AVI] (Microsoft)";
case 16: return "PC DOS/Windows Executable Files [.COM][.EXE]";
case 17: return "Compressed Binary File [.ZIP] (PKWare Inc)";
case 18: return "Audio Interchange File Format AIFF (Apple Computer Inc)";
case 19: return "RIFF Wave (Microsoft Corporation)";
case 20: return "Freehand (Macromedia/Aldus)";
case 21: return "Hypertext Markup Language [.HTML] (The Internet Society)";
case 22: return "MPEG 2 Audio Layer 2 (Musicom), ISO/IEC";
case 23: return "MPEG 2 Audio Layer 3, ISO/IEC";
case 24: return "Portable Document File [.PDF] Adobe";
case 25: return "News Industry Text Format (NITF)";
case 26: return "Tape Archive [.TAR]";
case 27: return "Tidningarnas Telegrambyra NITF version (TTNITF DTD)";
case 28: return "Ritzaus Bureau NITF version (RBNITF DTD)";
case 29: return "Corel Draw [.CDR]";
}
return String.format("Unknown (%d)", value);
return getIndexedDescription(
TAG_FILE_FORMAT,
"No ObjectData",
"IPTC-NAA Digital Newsphoto Parameter Record",
"IPTC7901 Recommended Message Format",
"Tagged Image File Format (Adobe/Aldus Image data)",
"Illustrator (Adobe Graphics data)",
"AppleSingle (Apple Computer Inc)",
"NAA 89-3 (ANPA 1312)",
"MacBinary II",
"IPTC Unstructured Character Oriented File Format (UCOFF)",
"United Press International ANPA 1312 variant",
"United Press International Down-Load Message",
"JPEG File Interchange (JFIF)",
"Photo-CD Image-Pac (Eastman Kodak)",
"Bit Mapped Graphics File [.BMP] (Microsoft)",
"Digital Audio File [.WAV] (Microsoft & Creative Labs)",
"Audio plus Moving Video [.AVI] (Microsoft)",
"PC DOS/Windows Executable Files [.COM][.EXE]",
"Compressed Binary File [.ZIP] (PKWare Inc)",
"Audio Interchange File Format AIFF (Apple Computer Inc)",
"RIFF Wave (Microsoft Corporation)",
"Freehand (Macromedia/Aldus)",
"Hypertext Markup Language [.HTML] (The Internet Society)",
"MPEG 2 Audio Layer 2 (Musicom), ISO/IEC",
"MPEG 2 Audio Layer 3, ISO/IEC",
"Portable Document File [.PDF] Adobe",
"News Industry Text Format (NITF)",
"Tape Archive [.TAR]",
"Tidningarnas Telegrambyra NITF version (TTNITF DTD)",
"Ritzaus Bureau NITF version (RBNITF DTD)",
"Corel Draw [.CDR]");
}

@Nullable
Expand Down

0 comments on commit 67dfddd

Please sign in to comment.