    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(
    021            true, TiffDirectoryConstants.DIRECTORY_TYPE_DIR_0, "IFD0"),
    022
    023    TIFF_DIRECTORY_IFD1(
    024            true, TiffDirectoryConstants.DIRECTORY_TYPE_DIR_1, "IFD1"),
    025
    026    TIFF_DIRECTORY_IFD2(
    027            true, TiffDirectoryConstants.DIRECTORY_TYPE_DIR_2, "IFD2"),
    028
    029    TIFF_DIRECTORY_IFD3(
    030            true, TiffDirectoryConstants.DIRECTORY_TYPE_DIR_3, "IFD3"),
    031
    032    EXIF_DIRECTORY_INTEROP_IFD(
    033            false, TiffDirectoryConstants.DIRECTORY_TYPE_INTEROPERABILITY, "Interop IFD"),
    034    EXIF_DIRECTORY_MAKER_NOTES(
    035            false, TiffDirectoryConstants.DIRECTORY_TYPE_MAKER_NOTES, "Maker Notes"),
    036    EXIF_DIRECTORY_EXIF_IFD(
    037            false, TiffDirectoryConstants.DIRECTORY_TYPE_EXIF, "Exif IFD"),
    038    EXIF_DIRECTORY_GPS(
    039            false, TiffDirectoryConstants.DIRECTORY_TYPE_GPS, "GPS IFD");
    040
    041    private final boolean isImageDirectory;
    042    public final int directoryType;
    043    public final String name;
    044
    045    TiffDirectoryType(final boolean isImageDirectory, final int directoryType, final String name) {
    046        this.isImageDirectory = isImageDirectory;
    047        this.directoryType = directoryType;
    048        this.name = name;
    049    }
    050
    051    public boolean isImageDirectory() {
    052        return isImageDirectory;
    053    }
    054
    055    public static TiffDirectoryType getExifDirectoryType(final int type) {
    056
    057        for (final TiffDirectoryType tiffDirectoryType : values()) {
    058            if (tiffDirectoryType.directoryType == type) {
    059                return tiffDirectoryType;
    060            }
    061        }
    062        return TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN;
    063    }
    064
    065    public static final TiffDirectoryType EXIF_DIRECTORY_IFD0 = TIFF_DIRECTORY_IFD0;
    066    public static final TiffDirectoryType TIFF_DIRECTORY_ROOT = TIFF_DIRECTORY_IFD0;
    067    public static final TiffDirectoryType EXIF_DIRECTORY_IFD1 = TIFF_DIRECTORY_IFD1;
    068    public static final TiffDirectoryType EXIF_DIRECTORY_IFD2 = TIFF_DIRECTORY_IFD2;
    069    public static final TiffDirectoryType EXIF_DIRECTORY_IFD3 = TIFF_DIRECTORY_IFD3;
    070    public static final TiffDirectoryType EXIF_DIRECTORY_SUB_IFD = TIFF_DIRECTORY_IFD1;
    071    public static final TiffDirectoryType EXIF_DIRECTORY_SUB_IFD1 = TIFF_DIRECTORY_IFD2;
    072    public static final TiffDirectoryType EXIF_DIRECTORY_SUB_IFD2 = TIFF_DIRECTORY_IFD3;
    073    public static final TiffDirectoryType EXIF_DIRECTORY_UNKNOWN = null;
    074}