001/*
002 * $RCSfile: FaxTIFFTagSet.java,v $
003 *
004 * 
005 * Copyright (c) 2005 Sun Microsystems, Inc. All  Rights Reserved.
006 * 
007 * Redistribution and use in source and binary forms, with or without
008 * modification, are permitted provided that the following conditions
009 * are met: 
010 * 
011 * - Redistribution of source code must retain the above copyright 
012 *   notice, this  list of conditions and the following disclaimer.
013 * 
014 * - Redistribution in binary form must reproduce the above copyright
015 *   notice, this list of conditions and the following disclaimer in 
016 *   the documentation and/or other materials provided with the
017 *   distribution.
018 * 
019 * Neither the name of Sun Microsystems, Inc. or the names of 
020 * contributors may be used to endorse or promote products derived 
021 * from this software without specific prior written permission.
022 * 
023 * This software is provided "AS IS," without a warranty of any 
024 * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND 
025 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, 
026 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
027 * EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL 
028 * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF 
029 * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
030 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR 
031 * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
032 * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
033 * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
034 * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
035 * POSSIBILITY OF SUCH DAMAGES. 
036 * 
037 * You acknowledge that this software is not designed or intended for 
038 * use in the design, construction, operation or maintenance of any 
039 * nuclear facility. 
040 *
041 * $Revision: 1.1 $
042 * $Date: 2005/02/11 05:01:17 $
043 * $State: Exp $
044 */
045package com.github.jaiimageio.plugins.tiff;
046
047import java.util.ArrayList;
048import java.util.List;
049
050/**
051 * A class representing the extra tags found in a
052 * <a href="http://palimpsest.stanford.edu/bytopic/imaging/std/tiff-f.html">
053 * TIFF-F</a> (RFC 2036) file.
054 */
055public class FaxTIFFTagSet extends TIFFTagSet {
056
057    private static FaxTIFFTagSet theInstance = null;
058
059    // RFC 2036 - TIFF-F extensions
060
061    /** Tag indicating the number of bad fax lines (type SHORT or LONG). */
062    public static final int TAG_BAD_FAX_LINES = 326;
063
064    /**
065     * Tag indicating the number of lines of clean fax data (type
066     * SHORT).
067     *
068     * @see #CLEAN_FAX_DATA_NO_ERRORS
069     * @see #CLEAN_FAX_DATA_ERRORS_CORRECTED
070     * @see #CLEAN_FAX_DATA_ERRORS_UNCORRECTED
071     */
072    public static final int TAG_CLEAN_FAX_DATA = 327;
073
074    /**
075     * A value to be used with the "CleanFaxData" tag.
076     *
077     * @see #TAG_CLEAN_FAX_DATA
078     */
079    public static final int CLEAN_FAX_DATA_NO_ERRORS = 0;
080
081    /**
082     * A value to be used with the "CleanFaxData" tag.
083     *
084     * @see #TAG_CLEAN_FAX_DATA
085     */
086    public static final int CLEAN_FAX_DATA_ERRORS_CORRECTED = 1;
087
088    /**
089     * A value to be used with the "CleanFaxData" tag.
090     *
091     * @see #TAG_CLEAN_FAX_DATA
092     */
093    public static final int CLEAN_FAX_DATA_ERRORS_UNCORRECTED = 2;
094
095    /**
096     * Tag indicating the number of consecutive bad lines (type
097     * SHORT or LONG).
098     */
099    public static final int TAG_CONSECUTIVE_BAD_LINES = 328;
100
101    // TIFF-F extensions (RFC 2306)
102
103    // XXX TIFF-F suggested extensions (FaxImageFlags, etc.)?
104
105    static class BadFaxLines extends TIFFTag {
106        
107        public BadFaxLines() {
108            super("BadFaxLines",
109                  TAG_BAD_FAX_LINES,
110                  1 << TIFF_SHORT |
111                  1 << TIFF_LONG);
112        }
113    }
114
115    static class CleanFaxData extends TIFFTag {
116
117        public CleanFaxData() {
118            super("CleanFaxData",
119                  TAG_CLEAN_FAX_DATA,
120                  1 << TIFF_SHORT);
121
122            addValueName(CLEAN_FAX_DATA_NO_ERRORS,
123                         "No errors");
124            addValueName(CLEAN_FAX_DATA_ERRORS_CORRECTED,
125                         "Errors corrected");
126            addValueName(CLEAN_FAX_DATA_ERRORS_UNCORRECTED,
127                         "Errors uncorrected");
128        }
129    }
130
131    static class ConsecutiveBadFaxLines extends TIFFTag {
132
133        public ConsecutiveBadFaxLines() {
134            super("ConsecutiveBadFaxLines",
135                  TAG_CONSECUTIVE_BAD_LINES,
136                  1 << TIFF_SHORT |
137                  1 << TIFF_LONG);
138        }
139    }
140
141    private static List tags;
142
143    private static void initTags() {
144        tags = new ArrayList(42);
145
146        tags.add(new FaxTIFFTagSet.BadFaxLines());
147        tags.add(new FaxTIFFTagSet.CleanFaxData());
148        tags.add(new FaxTIFFTagSet.ConsecutiveBadFaxLines());
149    }
150
151    private FaxTIFFTagSet() {
152        super(tags);
153    }
154
155    /**
156     * Returns a shared instance of a <code>FaxTIFFTagSet</code>.
157     *
158     * @return a <code>FaxTIFFTagSet</code> instance.
159     */
160    public synchronized static FaxTIFFTagSet getInstance() {
161        if (theInstance == null) {
162            initTags();
163            theInstance = new FaxTIFFTagSet();
164            tags = null;
165        }
166        return theInstance;
167    }
168}