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: */
045: package com.sun.media.imageio.plugins.tiff;
046:
047: import java.util.ArrayList;
048: import 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: */
055: public 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", TAG_BAD_FAX_LINES, 1 << TIFF_SHORT
109: | 1 << TIFF_LONG);
110: }
111: }
112:
113: static class CleanFaxData extends TIFFTag {
114:
115: public CleanFaxData() {
116: super ("CleanFaxData", TAG_CLEAN_FAX_DATA, 1 << TIFF_SHORT);
117:
118: addValueName(CLEAN_FAX_DATA_NO_ERRORS, "No errors");
119: addValueName(CLEAN_FAX_DATA_ERRORS_CORRECTED,
120: "Errors corrected");
121: addValueName(CLEAN_FAX_DATA_ERRORS_UNCORRECTED,
122: "Errors uncorrected");
123: }
124: }
125:
126: static class ConsecutiveBadFaxLines extends TIFFTag {
127:
128: public ConsecutiveBadFaxLines() {
129: super ("ConsecutiveBadFaxLines", TAG_CONSECUTIVE_BAD_LINES,
130: 1 << TIFF_SHORT | 1 << TIFF_LONG);
131: }
132: }
133:
134: private static List tags;
135:
136: private static void initTags() {
137: tags = new ArrayList(42);
138:
139: tags.add(new FaxTIFFTagSet.BadFaxLines());
140: tags.add(new FaxTIFFTagSet.CleanFaxData());
141: tags.add(new FaxTIFFTagSet.ConsecutiveBadFaxLines());
142: }
143:
144: private FaxTIFFTagSet() {
145: super (tags);
146: }
147:
148: /**
149: * Returns a shared instance of a <code>FaxTIFFTagSet</code>.
150: *
151: * @return a <code>FaxTIFFTagSet</code> instance.
152: */
153: public synchronized static FaxTIFFTagSet getInstance() {
154: if (theInstance == null) {
155: initTags();
156: theInstance = new FaxTIFFTagSet();
157: tags = null;
158: }
159: return theInstance;
160: }
161: }
|