1 /* 2 * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package javax.imageio.plugins.tiff; 26 27 import java.util.ArrayList; 28 import java.util.List; 29 30 /** 31 * A class representing the extra tags found in a 32 * <a href="http://tools.ietf.org/html/rfc2306"> TIFF-F</a> (RFC 2036) file. 33 * 34 * @since 9 35 */ 36 public class FaxTIFFTagSet extends TIFFTagSet { 37 38 private static FaxTIFFTagSet theInstance = null; 39 40 /** Tag indicating the number of bad fax lines (type SHORT or LONG). */ 41 public static final int TAG_BAD_FAX_LINES = 326; 42 43 /** 44 * Tag indicating the number of lines of clean fax data (type 45 * SHORT). 46 * 47 * @see #CLEAN_FAX_DATA_NO_ERRORS 48 * @see #CLEAN_FAX_DATA_ERRORS_CORRECTED 49 * @see #CLEAN_FAX_DATA_ERRORS_UNCORRECTED 50 */ 51 public static final int TAG_CLEAN_FAX_DATA = 327; 52 53 /** 54 * A value to be used with the "CleanFaxData" tag. 55 * 56 * @see #TAG_CLEAN_FAX_DATA 57 */ 58 public static final int CLEAN_FAX_DATA_NO_ERRORS = 0; 59 60 /** 61 * A value to be used with the "CleanFaxData" tag. 62 * 63 * @see #TAG_CLEAN_FAX_DATA 64 */ 65 public static final int CLEAN_FAX_DATA_ERRORS_CORRECTED = 1; 66 67 /** 68 * A value to be used with the "CleanFaxData" tag. 69 * 70 * @see #TAG_CLEAN_FAX_DATA 71 */ 72 public static final int CLEAN_FAX_DATA_ERRORS_UNCORRECTED = 2; 73 74 /** 75 * Tag indicating the number of consecutive bad lines (type 76 * SHORT or LONG). 77 */ 78 public static final int TAG_CONSECUTIVE_BAD_LINES = 328; 79 80 static class BadFaxLines extends TIFFTag { 81 82 public BadFaxLines() { 83 super("BadFaxLines", 84 TAG_BAD_FAX_LINES, 85 1 << TIFF_SHORT | 86 1 << TIFF_LONG, 87 1); 88 } 89 } 90 91 static class CleanFaxData extends TIFFTag { 92 93 public CleanFaxData() { 94 super("CleanFaxData", 95 TAG_CLEAN_FAX_DATA, 96 1 << TIFF_SHORT, 97 1); 98 99 addValueName(CLEAN_FAX_DATA_NO_ERRORS, 100 "No errors"); 101 addValueName(CLEAN_FAX_DATA_ERRORS_CORRECTED, 102 "Errors corrected"); 103 addValueName(CLEAN_FAX_DATA_ERRORS_UNCORRECTED, 104 "Errors uncorrected"); 105 } 106 } 107 108 static class ConsecutiveBadFaxLines extends TIFFTag { 109 110 public ConsecutiveBadFaxLines() { 111 super("ConsecutiveBadFaxLines", 112 TAG_CONSECUTIVE_BAD_LINES, 113 1 << TIFF_SHORT | 114 1 << TIFF_LONG, 115 1); 116 } 117 } 118 119 private static List<TIFFTag> tags; 120 121 private static void initTags() { 122 tags = new ArrayList<TIFFTag>(42); 123 124 tags.add(new FaxTIFFTagSet.BadFaxLines()); 125 tags.add(new FaxTIFFTagSet.CleanFaxData()); 126 tags.add(new FaxTIFFTagSet.ConsecutiveBadFaxLines()); 127 } 128 129 private FaxTIFFTagSet() { 130 super(tags); 131 } 132 133 /** 134 * Returns a shared instance of a <code>FaxTIFFTagSet</code>. 135 * 136 * @return a <code>FaxTIFFTagSet</code> instance. 137 */ 138 public synchronized static FaxTIFFTagSet getInstance() { 139 if (theInstance == null) { 140 initTags(); 141 theInstance = new FaxTIFFTagSet(); 142 tags = null; 143 } 144 return theInstance; 145 } 146 }