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

Last change on this file since 8132 was 8132, checked in by Don-vip, 10 years ago

fix #11162 - update to metadata-extractor 2.7.2

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