Changeset 6127 in josm for trunk/src/com/drew/metadata/iptc/IptcDescriptor.java
- Timestamp:
- 2013-08-09T18:05:11+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/metadata/iptc/IptcDescriptor.java
r4231 r6127 1 1 /* 2 * This is public domain software - that is, you can do whatever you want 3 * with it, and include it software that is licensed under the GNU or the 4 * BSD license, or whatever other licence you choose, including proprietary 5 * closed source licenses. I do ask that you leave this header in tact. 6 * 7 * If you make modifications to this code that you think would benefit the 8 * wider community, please send me a copy and I'll post it on my site. 9 * 10 * If you make use of this code, I'd appreciate hearing about it. 11 * drew@drewnoakes.com 12 * Latest version of this software kept at 13 * http://drewnoakes.com/ 14 * 15 * Created by dnoakes on 21-Nov-2002 17:58:19 using IntelliJ IDEA. 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/ 16 20 */ 17 21 package com.drew.metadata.iptc; 18 22 19 import com.drew.metadata.Directory; 23 import com.drew.lang.StringUtil; 24 import com.drew.lang.annotations.NotNull; 25 import com.drew.lang.annotations.Nullable; 20 26 import com.drew.metadata.TagDescriptor; 21 27 22 28 /** 23 * 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 24 34 */ 25 public class IptcDescriptor extends TagDescriptor 35 public class IptcDescriptor extends TagDescriptor<IptcDirectory> 26 36 { 27 public IptcDescriptor(Directory directory) 37 public IptcDescriptor(@NotNull IptcDirectory directory) 28 38 { 29 39 super(directory); 30 40 } 31 41 42 @Nullable 32 43 public String getDescription(int tagType) 33 44 { 34 return _directory.getString(tagType); 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); 35 241 } 36 242 }
Note:
See TracChangeset
for help on using the changeset viewer.
