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