| 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.annotations.NotNull;
|
|---|
| 24 | import com.drew.lang.annotations.Nullable;
|
|---|
| 25 | import com.drew.metadata.Directory;
|
|---|
| 26 |
|
|---|
| 27 | import java.util.Arrays;
|
|---|
| 28 | import java.util.HashMap;
|
|---|
| 29 | import java.util.List;
|
|---|
| 30 |
|
|---|
| 31 | /**
|
|---|
| 32 | * Describes tags used by the International Press Telecommunications Council (IPTC) metadata format.
|
|---|
| 33 | *
|
|---|
| 34 | * @author Drew Noakes http://drewnoakes.com
|
|---|
| 35 | */
|
|---|
| 36 | public class IptcDirectory extends Directory
|
|---|
| 37 | {
|
|---|
| 38 | // IPTC EnvelopeRecord Tags
|
|---|
| 39 | public static final int TAG_ENVELOPE_RECORD_VERSION = 0x0100; // 0 + 0x0100
|
|---|
| 40 | public static final int TAG_DESTINATION = 0x0105; // 5
|
|---|
| 41 | public static final int TAG_FILE_FORMAT = 0x0114; // 20
|
|---|
| 42 | public static final int TAG_FILE_VERSION = 0x0116; // 22
|
|---|
| 43 | public static final int TAG_SERVICE_ID = 0x011E; // 30
|
|---|
| 44 | public static final int TAG_ENVELOPE_NUMBER = 0x0128; // 40
|
|---|
| 45 | public static final int TAG_PRODUCT_ID = 0x0132; // 50
|
|---|
| 46 | public static final int TAG_ENVELOPE_PRIORITY = 0x013C; // 60
|
|---|
| 47 | public static final int TAG_DATE_SENT = 0x0146; // 70
|
|---|
| 48 | public static final int TAG_TIME_SENT = 0x0150; // 80
|
|---|
| 49 | public static final int TAG_CODED_CHARACTER_SET = 0x015A; // 90
|
|---|
| 50 | public static final int TAG_UNIQUE_OBJECT_NAME = 0x0164; // 100
|
|---|
| 51 | public static final int TAG_ARM_IDENTIFIER = 0x0178; // 120
|
|---|
| 52 | public static final int TAG_ARM_VERSION = 0x017a; // 122
|
|---|
| 53 |
|
|---|
| 54 | // IPTC ApplicationRecord Tags
|
|---|
| 55 | public static final int TAG_APPLICATION_RECORD_VERSION = 0x0200; // 0 + 0x0200
|
|---|
| 56 | public static final int TAG_OBJECT_TYPE_REFERENCE = 0x0203; // 3
|
|---|
| 57 | public static final int TAG_OBJECT_ATTRIBUTE_REFERENCE = 0x0204; // 4
|
|---|
| 58 | public static final int TAG_OBJECT_NAME = 0x0205; // 5
|
|---|
| 59 | public static final int TAG_EDIT_STATUS = 0x0207; // 7
|
|---|
| 60 | public static final int TAG_EDITORIAL_UPDATE = 0x0208; // 8
|
|---|
| 61 | public static final int TAG_URGENCY = 0X020A; // 10
|
|---|
| 62 | public static final int TAG_SUBJECT_REFERENCE = 0X020C; // 12
|
|---|
| 63 | public static final int TAG_CATEGORY = 0x020F; // 15
|
|---|
| 64 | public static final int TAG_SUPPLEMENTAL_CATEGORIES = 0x0214; // 20
|
|---|
| 65 | public static final int TAG_FIXTURE_ID = 0x0216; // 22
|
|---|
| 66 | public static final int TAG_KEYWORDS = 0x0219; // 25
|
|---|
| 67 | public static final int TAG_CONTENT_LOCATION_CODE = 0x021A; // 26
|
|---|
| 68 | public static final int TAG_CONTENT_LOCATION_NAME = 0x021B; // 27
|
|---|
| 69 | public static final int TAG_RELEASE_DATE = 0X021E; // 30
|
|---|
| 70 | public static final int TAG_RELEASE_TIME = 0x0223; // 35
|
|---|
| 71 | public static final int TAG_EXPIRATION_DATE = 0x0225; // 37
|
|---|
| 72 | public static final int TAG_EXPIRATION_TIME = 0x0226; // 38
|
|---|
| 73 | public static final int TAG_SPECIAL_INSTRUCTIONS = 0x0228; // 40
|
|---|
| 74 | public static final int TAG_ACTION_ADVISED = 0x022A; // 42
|
|---|
| 75 | public static final int TAG_REFERENCE_SERVICE = 0x022D; // 45
|
|---|
| 76 | public static final int TAG_REFERENCE_DATE = 0x022F; // 47
|
|---|
| 77 | public static final int TAG_REFERENCE_NUMBER = 0x0232; // 50
|
|---|
| 78 | public static final int TAG_DATE_CREATED = 0x0237; // 55
|
|---|
| 79 | public static final int TAG_TIME_CREATED = 0X023C; // 60
|
|---|
| 80 | public static final int TAG_DIGITAL_DATE_CREATED = 0x023E; // 62
|
|---|
| 81 | public static final int TAG_DIGITAL_TIME_CREATED = 0x023F; // 63
|
|---|
| 82 | public static final int TAG_ORIGINATING_PROGRAM = 0x0241; // 65
|
|---|
| 83 | public static final int TAG_PROGRAM_VERSION = 0x0246; // 70
|
|---|
| 84 | public static final int TAG_OBJECT_CYCLE = 0x024B; // 75
|
|---|
| 85 | public static final int TAG_BY_LINE = 0x0250; // 80
|
|---|
| 86 | public static final int TAG_BY_LINE_TITLE = 0x0255; // 85
|
|---|
| 87 | public static final int TAG_CITY = 0x025A; // 90
|
|---|
| 88 | public static final int TAG_SUB_LOCATION = 0x025C; // 92
|
|---|
| 89 | public static final int TAG_PROVINCE_OR_STATE = 0x025F; // 95
|
|---|
| 90 | public static final int TAG_COUNTRY_OR_PRIMARY_LOCATION_CODE = 0x0264; // 100
|
|---|
| 91 | public static final int TAG_COUNTRY_OR_PRIMARY_LOCATION_NAME = 0x0265; // 101
|
|---|
| 92 | public static final int TAG_ORIGINAL_TRANSMISSION_REFERENCE = 0x0267; // 103
|
|---|
| 93 | public static final int TAG_HEADLINE = 0x0269; // 105
|
|---|
| 94 | public static final int TAG_CREDIT = 0x026E; // 110
|
|---|
| 95 | public static final int TAG_SOURCE = 0x0273; // 115
|
|---|
| 96 | public static final int TAG_COPYRIGHT_NOTICE = 0x0274; // 116
|
|---|
| 97 | public static final int TAG_CONTACT = 0x0276; // 118
|
|---|
| 98 | public static final int TAG_CAPTION = 0x0278; // 120
|
|---|
| 99 | public static final int TAG_LOCAL_CAPTION = 0x0279; // 121
|
|---|
| 100 | public static final int TAG_CAPTION_WRITER = 0x027A; // 122
|
|---|
| 101 | public static final int TAG_RASTERIZED_CAPTION = 0x027D; // 125
|
|---|
| 102 | public static final int TAG_IMAGE_TYPE = 0x0282; // 130
|
|---|
| 103 | public static final int TAG_IMAGE_ORIENTATION = 0x0283; // 131
|
|---|
| 104 | public static final int TAG_LANGUAGE_IDENTIFIER = 0x0287; // 135
|
|---|
| 105 | public static final int TAG_AUDIO_TYPE = 0x0296; // 150
|
|---|
| 106 | public static final int TAG_AUDIO_SAMPLING_RATE = 0x0297; // 151
|
|---|
| 107 | public static final int TAG_AUDIO_SAMPLING_RESOLUTION = 0x0298; // 152
|
|---|
| 108 | public static final int TAG_AUDIO_DURATION = 0x0299; // 153
|
|---|
| 109 | public static final int TAG_AUDIO_OUTCUE = 0x029A; // 154
|
|---|
| 110 |
|
|---|
| 111 | public static final int TAG_JOB_ID = 0x02B8; // 184
|
|---|
| 112 | public static final int TAG_MASTER_DOCUMENT_ID = 0x02B9; // 185
|
|---|
| 113 | public static final int TAG_SHORT_DOCUMENT_ID = 0x02BA; // 186
|
|---|
| 114 | public static final int TAG_UNIQUE_DOCUMENT_ID = 0x02BB; // 187
|
|---|
| 115 | public static final int TAG_OWNER_ID = 0x02BC; // 188
|
|---|
| 116 |
|
|---|
| 117 | public static final int TAG_OBJECT_PREVIEW_FILE_FORMAT = 0x02C8; // 200
|
|---|
| 118 | public static final int TAG_OBJECT_PREVIEW_FILE_FORMAT_VERSION = 0x02C9; // 201
|
|---|
| 119 | public static final int TAG_OBJECT_PREVIEW_DATA = 0x02CA; // 202
|
|---|
| 120 |
|
|---|
| 121 | @NotNull
|
|---|
| 122 | protected static final HashMap<Integer, String> _tagNameMap = new HashMap<Integer, String>();
|
|---|
| 123 |
|
|---|
| 124 | static
|
|---|
| 125 | {
|
|---|
| 126 | _tagNameMap.put(TAG_ENVELOPE_RECORD_VERSION, "Enveloped Record Version");
|
|---|
| 127 | _tagNameMap.put(TAG_DESTINATION, "Destination");
|
|---|
| 128 | _tagNameMap.put(TAG_FILE_FORMAT, "File Format");
|
|---|
| 129 | _tagNameMap.put(TAG_FILE_VERSION, "File Version");
|
|---|
| 130 | _tagNameMap.put(TAG_SERVICE_ID, "Service Identifier");
|
|---|
| 131 | _tagNameMap.put(TAG_ENVELOPE_NUMBER, "Envelope Number");
|
|---|
| 132 | _tagNameMap.put(TAG_PRODUCT_ID, "Product Identifier");
|
|---|
| 133 | _tagNameMap.put(TAG_ENVELOPE_PRIORITY, "Envelope Priority");
|
|---|
| 134 | _tagNameMap.put(TAG_DATE_SENT, "Date Sent");
|
|---|
| 135 | _tagNameMap.put(TAG_TIME_SENT, "Time Sent");
|
|---|
| 136 | _tagNameMap.put(TAG_CODED_CHARACTER_SET, "Coded Character Set");
|
|---|
| 137 | _tagNameMap.put(TAG_UNIQUE_OBJECT_NAME, "Unique Object Name");
|
|---|
| 138 | _tagNameMap.put(TAG_ARM_IDENTIFIER, "ARM Identifier");
|
|---|
| 139 | _tagNameMap.put(TAG_ARM_VERSION, "ARM Version");
|
|---|
| 140 |
|
|---|
| 141 | _tagNameMap.put(TAG_APPLICATION_RECORD_VERSION, "Application Record Version");
|
|---|
| 142 | _tagNameMap.put(TAG_OBJECT_TYPE_REFERENCE, "Object Type Reference");
|
|---|
| 143 | _tagNameMap.put(TAG_OBJECT_ATTRIBUTE_REFERENCE, "Object Attribute Reference");
|
|---|
| 144 | _tagNameMap.put(TAG_OBJECT_NAME, "Object Name");
|
|---|
| 145 | _tagNameMap.put(TAG_EDIT_STATUS, "Edit Status");
|
|---|
| 146 | _tagNameMap.put(TAG_EDITORIAL_UPDATE, "Editorial Update");
|
|---|
| 147 | _tagNameMap.put(TAG_URGENCY, "Urgency");
|
|---|
| 148 | _tagNameMap.put(TAG_SUBJECT_REFERENCE, "Subject Reference");
|
|---|
| 149 | _tagNameMap.put(TAG_CATEGORY, "Category");
|
|---|
| 150 | _tagNameMap.put(TAG_SUPPLEMENTAL_CATEGORIES, "Supplemental Category(s)");
|
|---|
| 151 | _tagNameMap.put(TAG_FIXTURE_ID, "Fixture Identifier");
|
|---|
| 152 | _tagNameMap.put(TAG_KEYWORDS, "Keywords");
|
|---|
| 153 | _tagNameMap.put(TAG_CONTENT_LOCATION_CODE, "Content Location Code");
|
|---|
| 154 | _tagNameMap.put(TAG_CONTENT_LOCATION_NAME, "Content Location Name");
|
|---|
| 155 | _tagNameMap.put(TAG_RELEASE_DATE, "Release Date");
|
|---|
| 156 | _tagNameMap.put(TAG_RELEASE_TIME, "Release Time");
|
|---|
| 157 | _tagNameMap.put(TAG_EXPIRATION_DATE, "Expiration Date");
|
|---|
| 158 | _tagNameMap.put(TAG_EXPIRATION_TIME, "Expiration Time");
|
|---|
| 159 | _tagNameMap.put(TAG_SPECIAL_INSTRUCTIONS, "Special Instructions");
|
|---|
| 160 | _tagNameMap.put(TAG_ACTION_ADVISED, "Action Advised");
|
|---|
| 161 | _tagNameMap.put(TAG_REFERENCE_SERVICE, "Reference Service");
|
|---|
| 162 | _tagNameMap.put(TAG_REFERENCE_DATE, "Reference Date");
|
|---|
| 163 | _tagNameMap.put(TAG_REFERENCE_NUMBER, "Reference Number");
|
|---|
| 164 | _tagNameMap.put(TAG_DATE_CREATED, "Date Created");
|
|---|
| 165 | _tagNameMap.put(TAG_TIME_CREATED, "Time Created");
|
|---|
| 166 | _tagNameMap.put(TAG_DIGITAL_DATE_CREATED, "Digital Date Created");
|
|---|
| 167 | _tagNameMap.put(TAG_DIGITAL_TIME_CREATED, "Digital Time Created");
|
|---|
| 168 | _tagNameMap.put(TAG_ORIGINATING_PROGRAM, "Originating Program");
|
|---|
| 169 | _tagNameMap.put(TAG_PROGRAM_VERSION, "Program Version");
|
|---|
| 170 | _tagNameMap.put(TAG_OBJECT_CYCLE, "Object Cycle");
|
|---|
| 171 | _tagNameMap.put(TAG_BY_LINE, "By-line");
|
|---|
| 172 | _tagNameMap.put(TAG_BY_LINE_TITLE, "By-line Title");
|
|---|
| 173 | _tagNameMap.put(TAG_CITY, "City");
|
|---|
| 174 | _tagNameMap.put(TAG_SUB_LOCATION, "Sub-location");
|
|---|
| 175 | _tagNameMap.put(TAG_PROVINCE_OR_STATE, "Province/State");
|
|---|
| 176 | _tagNameMap.put(TAG_COUNTRY_OR_PRIMARY_LOCATION_CODE, "Country/Primary Location Code");
|
|---|
| 177 | _tagNameMap.put(TAG_COUNTRY_OR_PRIMARY_LOCATION_NAME, "Country/Primary Location Name");
|
|---|
| 178 | _tagNameMap.put(TAG_ORIGINAL_TRANSMISSION_REFERENCE, "Original Transmission Reference");
|
|---|
| 179 | _tagNameMap.put(TAG_HEADLINE, "Headline");
|
|---|
| 180 | _tagNameMap.put(TAG_CREDIT, "Credit");
|
|---|
| 181 | _tagNameMap.put(TAG_SOURCE, "Source");
|
|---|
| 182 | _tagNameMap.put(TAG_COPYRIGHT_NOTICE, "Copyright Notice");
|
|---|
| 183 | _tagNameMap.put(TAG_CONTACT, "Contact");
|
|---|
| 184 | _tagNameMap.put(TAG_CAPTION, "Caption/Abstract");
|
|---|
| 185 | _tagNameMap.put(TAG_LOCAL_CAPTION, "Local Caption");
|
|---|
| 186 | _tagNameMap.put(TAG_CAPTION_WRITER, "Caption Writer/Editor");
|
|---|
| 187 | _tagNameMap.put(TAG_RASTERIZED_CAPTION, "Rasterized Caption");
|
|---|
| 188 | _tagNameMap.put(TAG_IMAGE_TYPE, "Image Type");
|
|---|
| 189 | _tagNameMap.put(TAG_IMAGE_ORIENTATION, "Image Orientation");
|
|---|
| 190 | _tagNameMap.put(TAG_LANGUAGE_IDENTIFIER, "Language Identifier");
|
|---|
| 191 | _tagNameMap.put(TAG_AUDIO_TYPE, "Audio Type");
|
|---|
| 192 | _tagNameMap.put(TAG_AUDIO_SAMPLING_RATE, "Audio Sampling Rate");
|
|---|
| 193 | _tagNameMap.put(TAG_AUDIO_SAMPLING_RESOLUTION, "Audio Sampling Resolution");
|
|---|
| 194 | _tagNameMap.put(TAG_AUDIO_DURATION, "Audio Duration");
|
|---|
| 195 | _tagNameMap.put(TAG_AUDIO_OUTCUE, "Audio Outcue");
|
|---|
| 196 |
|
|---|
| 197 | _tagNameMap.put(TAG_JOB_ID, "Job Identifier");
|
|---|
| 198 | _tagNameMap.put(TAG_MASTER_DOCUMENT_ID, "Master Document Identifier");
|
|---|
| 199 | _tagNameMap.put(TAG_SHORT_DOCUMENT_ID, "Short Document Identifier");
|
|---|
| 200 | _tagNameMap.put(TAG_UNIQUE_DOCUMENT_ID, "Unique Document Identifier");
|
|---|
| 201 | _tagNameMap.put(TAG_OWNER_ID, "Owner Identifier");
|
|---|
| 202 |
|
|---|
| 203 | _tagNameMap.put(TAG_OBJECT_PREVIEW_FILE_FORMAT, "Object Data Preview File Format");
|
|---|
| 204 | _tagNameMap.put(TAG_OBJECT_PREVIEW_FILE_FORMAT_VERSION, "Object Data Preview File Format Version");
|
|---|
| 205 | _tagNameMap.put(TAG_OBJECT_PREVIEW_DATA, "Object Data Preview Data");
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | public IptcDirectory()
|
|---|
| 209 | {
|
|---|
| 210 | this.setDescriptor(new IptcDescriptor(this));
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 | @NotNull
|
|---|
| 214 | public String getName()
|
|---|
| 215 | {
|
|---|
| 216 | return "Iptc";
|
|---|
| 217 | }
|
|---|
| 218 |
|
|---|
| 219 | @NotNull
|
|---|
| 220 | protected HashMap<Integer, String> getTagNameMap()
|
|---|
| 221 | {
|
|---|
| 222 | return _tagNameMap;
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 225 | /**
|
|---|
| 226 | * Returns any keywords contained in the IPTC data. This value may be <code>null</code>.
|
|---|
| 227 | */
|
|---|
| 228 | @Nullable
|
|---|
| 229 | public List<String> getKeywords()
|
|---|
| 230 | {
|
|---|
| 231 | final String[] array = getStringArray(IptcDirectory.TAG_KEYWORDS);
|
|---|
| 232 | if (array==null)
|
|---|
| 233 | return null;
|
|---|
| 234 | return Arrays.asList(array);
|
|---|
| 235 | }
|
|---|
| 236 | }
|
|---|