    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017package org.apache.commons.imaging.formats.tiff.constants;
    018
    019public enum TiffDirectoryType {
    020    TIFF_DIRECTORY_IFD0(true, TiffDirectoryConstants.DIRECTORY_TYPE_DIR_0, "IFD0"),
    021
    022    TIFF_DIRECTORY_IFD1(true, TiffDirectoryConstants.DIRECTORY_TYPE_DIR_1, "IFD1"),
    023
    024    TIFF_DIRECTORY_IFD2(true, TiffDirectoryConstants.DIRECTORY_TYPE_DIR_2, "IFD2"),
    025
    026    TIFF_DIRECTORY_IFD3(true, TiffDirectoryConstants.DIRECTORY_TYPE_DIR_3, "IFD3"),
    027
    028    EXIF_DIRECTORY_INTEROP_IFD(false, TiffDirectoryConstants.DIRECTORY_TYPE_INTEROPERABILITY, "Interop IFD"),
    029    EXIF_DIRECTORY_MAKER_NOTES(false, TiffDirectoryConstants.DIRECTORY_TYPE_MAKER_NOTES, "Maker Notes"),
    030    EXIF_DIRECTORY_EXIF_IFD(false, TiffDirectoryConstants.DIRECTORY_TYPE_EXIF, "Exif IFD"),
    031    EXIF_DIRECTORY_GPS(false, TiffDirectoryConstants.DIRECTORY_TYPE_GPS, "GPS IFD");
    032
    033    public static final TiffDirectoryType EXIF_DIRECTORY_IFD0 = TIFF_DIRECTORY_IFD0;
    034    public static final TiffDirectoryType TIFF_DIRECTORY_ROOT = TIFF_DIRECTORY_IFD0;
    035    public static final TiffDirectoryType EXIF_DIRECTORY_IFD1 = TIFF_DIRECTORY_IFD1;
    036
    037    public static final TiffDirectoryType EXIF_DIRECTORY_IFD2 = TIFF_DIRECTORY_IFD2;
    038
    039    public static final TiffDirectoryType EXIF_DIRECTORY_IFD3 = TIFF_DIRECTORY_IFD3;
    040
    041    public static final TiffDirectoryType EXIF_DIRECTORY_SUB_IFD = TIFF_DIRECTORY_IFD1;
    042
    043    public static final TiffDirectoryType EXIF_DIRECTORY_SUB_IFD1 = TIFF_DIRECTORY_IFD2;
    044    public static final TiffDirectoryType EXIF_DIRECTORY_SUB_IFD2 = TIFF_DIRECTORY_IFD3;
    045    public static final TiffDirectoryType EXIF_DIRECTORY_UNKNOWN = null;
    046
    047    public static TiffDirectoryType getExifDirectoryType(final int type) {
    048
    049        for (final TiffDirectoryType tiffDirectoryType : values()) {
    050            if (tiffDirectoryType.directoryType == type) {
    051                return tiffDirectoryType;
    052            }
    053        }
    054        return EXIF_DIRECTORY_UNKNOWN;
    055    }
    056
    057    private final boolean isImageDirectory;
    058    public final int directoryType;
    059    public final String name;
    060
    061    TiffDirectoryType(final boolean isImageDirectory, final int directoryType, final String name) {
    062        this.isImageDirectory = isImageDirectory;
    063        this.directoryType = directoryType;
    064        this.name = name;
    065    }
    066
    067    public boolean isImageDirectory() {
    068        return isImageDirectory;
    069    }
    070}