Debian Codegraph @

src/com/drew/metadata/exif/makernotes/AppleRunTimeMakernoteDescriptor.java

raw symbols SCIP
1 /*
2 * Copyright 2002-2019 Drew Noakes and contributors
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 package com.drew.metadata.exif.makernotes;
22
23 import com.drew.lang.annotations.Nullable;
24 import com.drew.metadata.MetadataException;
25 import com.drew.metadata.TagDescriptor;
26
27 /**
28 * @author Bob Johnson
29 */
30 public class AppleRunTimeMakernoteDescriptor extends TagDescriptor<AppleRunTimeMakernoteDirectory>
31 {
32 public AppleRunTimeMakernoteDescriptor(AppleRunTimeMakernoteDirectory directory)
33 {
34 super(directory);
35 }
36
37 @Override
38 @Nullable
39 public String getDescription(int tagType)
40 {
41 switch (tagType) {
42 case AppleRunTimeMakernoteDirectory.CMTimeFlags:
43 return getFlagsDescription();
44 case AppleRunTimeMakernoteDirectory.CMTimeValue:
45 return getValueDescription();
46 default:
47 return super.getDescription(tagType);
48 }
49 }
50
51 // flags bitmask details
52 // 0000 0001 = Valid
53 // 0000 0010 = Rounded
54 // 0000 0100 = Positive Infinity
55 // 0000 1000 = Negative Infinity
56 // 0001 0000 = Indefinite
57 @Nullable
58 public String getFlagsDescription()
59 {
60 try {
61 final int value = _directory.getInt(AppleRunTimeMakernoteDirectory.CMTimeFlags);
62
63 StringBuilder sb = new StringBuilder();
64
65 if ((value & 0x1) == 1)
66 sb.append("Valid");
67 else
68 sb.append("Invalid");
69
70 if ((value & 0x2) != 0)
71 sb.append(", rounded");
72
73 if ((value & 0x4) != 0)
74 sb.append(", positive infinity");
75
76 if ((value & 0x8) != 0)
77 sb.append(", negative infinity");
78
79 if ((value & 0x10) != 0)
80 sb.append(", indefinite");
81
82 return sb.toString();
83 } catch (MetadataException ignored) {
84 return null;
85 }
86 }
87
88 @Nullable
89 public String getValueDescription()
90 {
91 try {
92 long value = _directory.getLong(AppleRunTimeMakernoteDirectory.CMTimeValue);
93 long scale = _directory.getLong(AppleRunTimeMakernoteDirectory.CMTimeScale);
94
95 return String.format("%d seconds", (value / scale));
96 } catch (MetadataException ignored) {
97 return null;
98 }
99 }
100 }