| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
package com.drew.metadata.exif.makernotes; |
| 23 |
|
| 24 |
import com.drew.lang.annotations.NotNull; |
| 25 |
import com.drew.lang.annotations.Nullable; |
| 26 |
import com.drew.metadata.StringValue; |
| 27 |
import com.drew.metadata.TagDescriptor; |
| 28 |
|
| 29 |
import java.text.DateFormat; |
| 30 |
import java.text.DecimalFormat; |
| 31 |
import java.text.ParseException; |
| 32 |
import java.text.SimpleDateFormat; |
| 33 |
|
| 34 |
import static com.drew.metadata.exif.makernotes.ReconyxHyperFire2MakernoteDirectory.*; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
@SuppressWarnings("WeakerAccess") |
| 40 |
public class ReconyxHyperFire2MakernoteDescriptor extends TagDescriptor<ReconyxHyperFire2MakernoteDirectory> |
| 41 |
{ |
| 42 |
public ReconyxHyperFire2MakernoteDescriptor(@NotNull ReconyxHyperFire2MakernoteDirectory directory) |
| 43 |
{ |
| 44 |
super(directory); |
| 45 |
} |
| 46 |
|
| 47 |
@Override |
| 48 |
@Nullable |
| 49 |
public String getDescription(int tagType) |
| 50 |
{ |
| 51 |
switch (tagType) { |
| 52 |
|
| 53 |
case TAG_FILE_NUMBER: |
| 54 |
return String.format("%d", _directory.getInteger(tagType)); |
| 55 |
|
| 56 |
case TAG_DIRECTORY_NUMBER: |
| 57 |
return String.format("%d", _directory.getInteger(tagType)); |
| 58 |
|
| 59 |
case TAG_FIRMWARE_VERSION: |
| 60 |
return _directory.getString(tagType); |
| 61 |
|
| 62 |
case TAG_FIRMWARE_DATE: |
| 63 |
String dtFirm = _directory.getString(tagType); |
| 64 |
try { |
| 65 |
DateFormat parser = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss"); |
| 66 |
return parser.format(parser.parse(dtFirm)); |
| 67 |
} catch (ParseException e) { |
| 68 |
return null; |
| 69 |
} |
| 70 |
|
| 71 |
case TAG_TRIGGER_MODE: |
| 72 |
return _directory.getString(tagType); |
| 73 |
|
| 74 |
case TAG_SEQUENCE: |
| 75 |
int[] sequence = _directory.getIntArray(tagType); |
| 76 |
if (sequence == null) |
| 77 |
return null; |
| 78 |
return String.format("%d/%d", sequence[0], sequence[1]); |
| 79 |
|
| 80 |
case TAG_EVENT_NUMBER: |
| 81 |
return String.format("%d", _directory.getInteger(tagType)); |
| 82 |
|
| 83 |
case TAG_DATE_TIME_ORIGINAL: |
| 84 |
String date = _directory.getString(tagType); |
| 85 |
try { |
| 86 |
DateFormat parser = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss"); |
| 87 |
return parser.format(parser.parse(date)); |
| 88 |
} catch (ParseException e) { |
| 89 |
return null; |
| 90 |
} |
| 91 |
|
| 92 |
case TAG_DAY_OF_WEEK: |
| 93 |
return getIndexedDescription(tagType, "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); |
| 94 |
|
| 95 |
case TAG_MOON_PHASE: |
| 96 |
return getIndexedDescription(tagType, "New", "Waxing Crescent", "First Quarter", "Waxing Gibbous", "Full", "Waning Gibbous", "Last Quarter", "Waning Crescent"); |
| 97 |
|
| 98 |
case TAG_AMBIENT_TEMPERATURE_FAHRENHEIT: |
| 99 |
case TAG_AMBIENT_TEMPERATURE: |
| 100 |
return String.format("%d", _directory.getInteger(tagType)); |
| 101 |
|
| 102 |
case TAG_CONTRAST: |
| 103 |
case TAG_BRIGHTNESS: |
| 104 |
case TAG_SHARPNESS: |
| 105 |
case TAG_SATURATION: |
| 106 |
return String.format("%d", _directory.getInteger(tagType)); |
| 107 |
|
| 108 |
case TAG_FLASH: |
| 109 |
return getIndexedDescription(tagType, "Off", "On"); |
| 110 |
|
| 111 |
|
| 112 |
case TAG_AMBIENT_INFRARED: |
| 113 |
case TAG_AMBIENT_LIGHT: |
| 114 |
return String.format("%d", _directory.getInteger(tagType)); |
| 115 |
|
| 116 |
case TAG_MOTION_SENSITIVITY: |
| 117 |
return String.format("%d", _directory.getInteger(tagType)); |
| 118 |
|
| 119 |
case TAG_BATTERY_VOLTAGE: |
| 120 |
case TAG_BATTERY_VOLTAGE_AVG: |
| 121 |
Double value = _directory.getDoubleObject(tagType); |
| 122 |
DecimalFormat formatter = new DecimalFormat("0.000"); |
| 123 |
return value == null ? null : formatter.format(value); |
| 124 |
|
| 125 |
case TAG_BATTERY_TYPE: |
| 126 |
return String.format("%d", _directory.getInteger(tagType)); |
| 127 |
|
| 128 |
case TAG_USER_LABEL: |
| 129 |
return _directory.getString(tagType); |
| 130 |
case TAG_SERIAL_NUMBER: |
| 131 |
|
| 132 |
StringValue svalue = _directory.getStringValue(tagType); |
| 133 |
if(svalue == null) |
| 134 |
return null; |
| 135 |
return svalue.toString(); |
| 136 |
|
| 137 |
default: |
| 138 |
return super.getDescription(tagType); |
| 139 |
} |
| 140 |
} |
| 141 |
} |