1 | /*
|
---|
2 | * Copyright 2002-2017 Drew Noakes
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | *
|
---|
16 | * More information about this project is available at:
|
---|
17 | *
|
---|
18 | * https://drewnoakes.com/code/exif/
|
---|
19 | * https://github.com/drewnoakes/metadata-extractor
|
---|
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.ReconyxUltraFireMakernoteDirectory.*;
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Provides human-readable string representations of tag values stored in a {@link ReconyxUltraFireMakernoteDirectory}.
|
---|
38 | *
|
---|
39 | * @author Todd West http://cascadescarnivoreproject.blogspot.com
|
---|
40 | */
|
---|
41 | @SuppressWarnings("WeakerAccess")
|
---|
42 | public class ReconyxUltraFireMakernoteDescriptor extends TagDescriptor<ReconyxUltraFireMakernoteDirectory>
|
---|
43 | {
|
---|
44 | public ReconyxUltraFireMakernoteDescriptor(@NotNull ReconyxUltraFireMakernoteDirectory directory)
|
---|
45 | {
|
---|
46 | super(directory);
|
---|
47 | }
|
---|
48 |
|
---|
49 | @Override
|
---|
50 | @Nullable
|
---|
51 | public String getDescription(int tagType)
|
---|
52 | {
|
---|
53 | switch (tagType) {
|
---|
54 | case TAG_LABEL:
|
---|
55 | return _directory.getString(tagType);
|
---|
56 | case TAG_MAKERNOTE_ID:
|
---|
57 | return String.format("0x%08X", _directory.getInteger(tagType));
|
---|
58 | case TAG_MAKERNOTE_SIZE:
|
---|
59 | return String.format("%d", _directory.getInteger(tagType));
|
---|
60 | case TAG_MAKERNOTE_PUBLIC_ID:
|
---|
61 | return String.format("0x%08X", _directory.getInteger(tagType));
|
---|
62 | case TAG_MAKERNOTE_PUBLIC_SIZE:
|
---|
63 | return String.format("%d", _directory.getInteger(tagType));
|
---|
64 | case TAG_CAMERA_VERSION:
|
---|
65 | case TAG_UIB_VERSION:
|
---|
66 | case TAG_BTL_VERSION:
|
---|
67 | case TAG_PEX_VERSION:
|
---|
68 | case TAG_EVENT_TYPE:
|
---|
69 | return _directory.getString(tagType);
|
---|
70 | case TAG_SEQUENCE:
|
---|
71 | int[] sequence = _directory.getIntArray(tagType);
|
---|
72 | if (sequence == null)
|
---|
73 | return null;
|
---|
74 | return String.format("%d/%d", sequence[0], sequence[1]);
|
---|
75 | case TAG_EVENT_NUMBER:
|
---|
76 | return String.format("%d", _directory.getInteger(tagType));
|
---|
77 | case TAG_DATE_TIME_ORIGINAL:
|
---|
78 | String date = _directory.getString(tagType);
|
---|
79 | try {
|
---|
80 | DateFormat parser = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
|
---|
81 | return parser.format(parser.parse(date));
|
---|
82 | } catch (ParseException e) {
|
---|
83 | return null;
|
---|
84 | }
|
---|
85 | /*case TAG_DAY_OF_WEEK:
|
---|
86 | return getIndexedDescription(tagType, CultureInfo.CurrentCulture.DateTimeFormat.DayNames);*/
|
---|
87 | case TAG_MOON_PHASE:
|
---|
88 | return getIndexedDescription(tagType, "New", "Waxing Crescent", "First Quarter", "Waxing Gibbous", "Full", "Waning Gibbous", "Last Quarter", "Waning Crescent");
|
---|
89 | case TAG_AMBIENT_TEMPERATURE_FAHRENHEIT:
|
---|
90 | case TAG_AMBIENT_TEMPERATURE:
|
---|
91 | return String.format("%d", _directory.getInteger(tagType));
|
---|
92 | case TAG_FLASH:
|
---|
93 | return getIndexedDescription(tagType, "Off", "On");
|
---|
94 | case TAG_BATTERY_VOLTAGE:
|
---|
95 | Double value = _directory.getDoubleObject(tagType);
|
---|
96 | DecimalFormat formatter = new DecimalFormat("0.000");
|
---|
97 | return value == null ? null : formatter.format(value);
|
---|
98 | case TAG_SERIAL_NUMBER:
|
---|
99 | // default is UTF_8
|
---|
100 | StringValue svalue = _directory.getStringValue(tagType);
|
---|
101 | if(svalue == null)
|
---|
102 | return null;
|
---|
103 | return svalue.toString();
|
---|
104 | case TAG_USER_LABEL:
|
---|
105 | return _directory.getString(tagType);
|
---|
106 | default:
|
---|
107 | return super.getDescription(tagType);
|
---|
108 | }
|
---|
109 | }
|
---|
110 | }
|
---|