source: josm/trunk/src/com/drew/metadata/iptc/IptcDescriptor.java@ 12187

Last change on this file since 12187 was 10862, checked in by Don-vip, 8 years ago

update to metadata-extractor 2.9.1

File size: 9.7 KB
RevLine 
[8132]1/*
[10862]2 * Copyright 2002-2016 Drew Noakes
[8132]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 */
21package com.drew.metadata.iptc;
22
23import com.drew.lang.StringUtil;
24import com.drew.lang.annotations.NotNull;
25import com.drew.lang.annotations.Nullable;
26import com.drew.metadata.TagDescriptor;
27
[10862]28import static com.drew.metadata.iptc.IptcDirectory.*;
29
[8132]30/**
31 * Provides human-readable string representations of tag values stored in a {@link IptcDirectory}.
32 * <p>
33 * As the IPTC directory already stores values as strings, this class simply returns the tag's value.
34 *
35 * @author Drew Noakes https://drewnoakes.com
36 */
37public class IptcDescriptor extends TagDescriptor<IptcDirectory>
38{
39 public IptcDescriptor(@NotNull IptcDirectory directory)
40 {
41 super(directory);
42 }
43
44 @Override
45 @Nullable
46 public String getDescription(int tagType)
47 {
48 switch (tagType) {
[10862]49 case TAG_DATE_CREATED:
50 return getDateCreatedDescription();
51 case TAG_DIGITAL_DATE_CREATED:
52 return getDigitalDateCreatedDescription();
53 case TAG_DATE_SENT:
54 return getDateSentDescription();
55 case TAG_EXPIRATION_DATE:
56 return getExpirationDateDescription();
57 case TAG_EXPIRATION_TIME:
58 return getExpirationTimeDescription();
59 case TAG_FILE_FORMAT:
[8132]60 return getFileFormatDescription();
[10862]61 case TAG_KEYWORDS:
[8132]62 return getKeywordsDescription();
[10862]63 case TAG_REFERENCE_DATE:
64 return getReferenceDateDescription();
65 case TAG_RELEASE_DATE:
66 return getReleaseDateDescription();
67 case TAG_RELEASE_TIME:
68 return getReleaseTimeDescription();
69 case TAG_TIME_CREATED:
[8243]70 return getTimeCreatedDescription();
[10862]71 case TAG_DIGITAL_TIME_CREATED:
[8243]72 return getDigitalTimeCreatedDescription();
[10862]73 case TAG_TIME_SENT:
74 return getTimeSentDescription();
[8132]75 default:
76 return super.getDescription(tagType);
77 }
78 }
79
80 @Nullable
[10862]81 public String getDateDescription(int tagType)
82 {
83 String s = _directory.getString(tagType);
84 if (s == null)
85 return null;
86 if (s.length() == 8)
87 return s.substring(0, 4) + ':' + s.substring(4, 6) + ':' + s.substring(6);
88 return s;
89 }
90
91 @Nullable
92 public String getTimeDescription(int tagType)
93 {
94 String s = _directory.getString(tagType);
95 if (s == null)
96 return null;
97 if (s.length() == 6 || s.length() == 11)
98 return s.substring(0, 2) + ':' + s.substring(2, 4) + ':' + s.substring(4);
99 return s;
100 }
101
102 @Nullable
[8132]103 public String getFileFormatDescription()
104 {
[10862]105 Integer value = _directory.getInteger(TAG_FILE_FORMAT);
[8132]106 if (value == null)
107 return null;
108 switch (value) {
109 case 0: return "No ObjectData";
110 case 1: return "IPTC-NAA Digital Newsphoto Parameter Record";
111 case 2: return "IPTC7901 Recommended Message Format";
112 case 3: return "Tagged Image File Format (Adobe/Aldus Image data)";
113 case 4: return "Illustrator (Adobe Graphics data)";
114 case 5: return "AppleSingle (Apple Computer Inc)";
115 case 6: return "NAA 89-3 (ANPA 1312)";
116 case 7: return "MacBinary II";
117 case 8: return "IPTC Unstructured Character Oriented File Format (UCOFF)";
118 case 9: return "United Press International ANPA 1312 variant";
119 case 10: return "United Press International Down-Load Message";
120 case 11: return "JPEG File Interchange (JFIF)";
121 case 12: return "Photo-CD Image-Pac (Eastman Kodak)";
122 case 13: return "Bit Mapped Graphics File [.BMP] (Microsoft)";
123 case 14: return "Digital Audio File [.WAV] (Microsoft & Creative Labs)";
124 case 15: return "Audio plus Moving Video [.AVI] (Microsoft)";
125 case 16: return "PC DOS/Windows Executable Files [.COM][.EXE]";
126 case 17: return "Compressed Binary File [.ZIP] (PKWare Inc)";
127 case 18: return "Audio Interchange File Format AIFF (Apple Computer Inc)";
128 case 19: return "RIFF Wave (Microsoft Corporation)";
129 case 20: return "Freehand (Macromedia/Aldus)";
130 case 21: return "Hypertext Markup Language [.HTML] (The Internet Society)";
131 case 22: return "MPEG 2 Audio Layer 2 (Musicom), ISO/IEC";
132 case 23: return "MPEG 2 Audio Layer 3, ISO/IEC";
133 case 24: return "Portable Document File [.PDF] Adobe";
134 case 25: return "News Industry Text Format (NITF)";
135 case 26: return "Tape Archive [.TAR]";
136 case 27: return "Tidningarnas Telegrambyra NITF version (TTNITF DTD)";
137 case 28: return "Ritzaus Bureau NITF version (RBNITF DTD)";
138 case 29: return "Corel Draw [.CDR]";
139 }
140 return String.format("Unknown (%d)", value);
141 }
142
143 @Nullable
144 public String getByLineDescription()
145 {
[10862]146 return _directory.getString(TAG_BY_LINE);
[8132]147 }
148
149 @Nullable
150 public String getByLineTitleDescription()
151 {
[10862]152 return _directory.getString(TAG_BY_LINE_TITLE);
[8132]153 }
154
155 @Nullable
156 public String getCaptionDescription()
157 {
[10862]158 return _directory.getString(TAG_CAPTION);
[8132]159 }
160
161 @Nullable
162 public String getCategoryDescription()
163 {
[10862]164 return _directory.getString(TAG_CATEGORY);
[8132]165 }
166
167 @Nullable
168 public String getCityDescription()
169 {
[10862]170 return _directory.getString(TAG_CITY);
[8132]171 }
172
173 @Nullable
174 public String getCopyrightNoticeDescription()
175 {
[10862]176 return _directory.getString(TAG_COPYRIGHT_NOTICE);
[8132]177 }
178
179 @Nullable
180 public String getCountryOrPrimaryLocationDescription()
181 {
[10862]182 return _directory.getString(TAG_COUNTRY_OR_PRIMARY_LOCATION_NAME);
[8132]183 }
184
185 @Nullable
186 public String getCreditDescription()
187 {
[10862]188 return _directory.getString(TAG_CREDIT);
[8132]189 }
190
191 @Nullable
192 public String getDateCreatedDescription()
193 {
[10862]194 return getDateDescription(TAG_DATE_CREATED);
[8132]195 }
196
197 @Nullable
[10862]198 public String getDigitalDateCreatedDescription()
199 {
200 return getDateDescription(TAG_DIGITAL_DATE_CREATED);
201 }
202
203 @Nullable
204 public String getDateSentDescription()
205 {
206 return getDateDescription(TAG_DATE_SENT);
207 }
208
209 @Nullable
210 public String getExpirationDateDescription()
211 {
212 return getDateDescription(TAG_EXPIRATION_DATE);
213 }
214
215 @Nullable
216 public String getExpirationTimeDescription()
217 {
218 return getTimeDescription(TAG_EXPIRATION_TIME);
219 }
220
221 @Nullable
[8132]222 public String getHeadlineDescription()
223 {
[10862]224 return _directory.getString(TAG_HEADLINE);
[8132]225 }
226
227 @Nullable
228 public String getKeywordsDescription()
229 {
[10862]230 final String[] keywords = _directory.getStringArray(TAG_KEYWORDS);
[8132]231 if (keywords==null)
232 return null;
233 return StringUtil.join(keywords, ";");
234 }
235
236 @Nullable
237 public String getObjectNameDescription()
238 {
[10862]239 return _directory.getString(TAG_OBJECT_NAME);
[8132]240 }
241
242 @Nullable
243 public String getOriginalTransmissionReferenceDescription()
244 {
[10862]245 return _directory.getString(TAG_ORIGINAL_TRANSMISSION_REFERENCE);
[8132]246 }
247
248 @Nullable
249 public String getOriginatingProgramDescription()
250 {
[10862]251 return _directory.getString(TAG_ORIGINATING_PROGRAM);
[8132]252 }
253
254 @Nullable
255 public String getProvinceOrStateDescription()
256 {
[10862]257 return _directory.getString(TAG_PROVINCE_OR_STATE);
[8132]258 }
259
260 @Nullable
261 public String getRecordVersionDescription()
262 {
[10862]263 return _directory.getString(TAG_APPLICATION_RECORD_VERSION);
[8132]264 }
265
266 @Nullable
[10862]267 public String getReferenceDateDescription()
268 {
269 return getDateDescription(TAG_REFERENCE_DATE);
270 }
271
272 @Nullable
[8132]273 public String getReleaseDateDescription()
274 {
[10862]275 return getDateDescription(TAG_RELEASE_DATE);
[8132]276 }
277
278 @Nullable
279 public String getReleaseTimeDescription()
280 {
[10862]281 return getTimeDescription(TAG_RELEASE_TIME);
[8132]282 }
283
284 @Nullable
285 public String getSourceDescription()
286 {
[10862]287 return _directory.getString(TAG_SOURCE);
[8132]288 }
289
290 @Nullable
291 public String getSpecialInstructionsDescription()
292 {
[10862]293 return _directory.getString(TAG_SPECIAL_INSTRUCTIONS);
[8132]294 }
295
296 @Nullable
297 public String getSupplementalCategoriesDescription()
298 {
[10862]299 return _directory.getString(TAG_SUPPLEMENTAL_CATEGORIES);
[8132]300 }
301
302 @Nullable
303 public String getTimeCreatedDescription()
304 {
[10862]305 return getTimeDescription(TAG_TIME_CREATED);
[8132]306 }
307
308 @Nullable
[8243]309 public String getDigitalTimeCreatedDescription()
310 {
[10862]311 return getTimeDescription(TAG_DIGITAL_TIME_CREATED);
[8243]312 }
313
314 @Nullable
[10862]315 public String getTimeSentDescription()
316 {
317 return getTimeDescription(TAG_TIME_SENT);
318 }
319
320 @Nullable
[8132]321 public String getUrgencyDescription()
322 {
[10862]323 return _directory.getString(TAG_URGENCY);
[8132]324 }
325
326 @Nullable
327 public String getWriterDescription()
328 {
[10862]329 return _directory.getString(TAG_CAPTION_WRITER);
[8132]330 }
331}
Note: See TracBrowser for help on using the repository browser.