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