< prev index next >

src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java

Print this page




  23  * questions.
  24  */
  25 package javax.imageio.plugins.tiff;
  26 
  27 import java.util.StringTokenizer;
  28 import org.w3c.dom.NamedNodeMap;
  29 import org.w3c.dom.Node;
  30 import com.sun.imageio.plugins.tiff.TIFFFieldNode;
  31 import com.sun.imageio.plugins.tiff.TIFFIFD;
  32 
  33 /**
  34  * A class representing a field in a TIFF 6.0 Image File Directory.
  35  *
  36  * <p> A field in a TIFF Image File Directory (IFD) is defined as a
  37  * tag number accompanied by a sequence of values of identical data type.
  38  * TIFF 6.0 defines 12 data types; a 13th type {@code IFD} is
  39  * defined in TIFF Tech Note 1 of TIFF Specification Supplement 1. These
  40  * TIFF data types are referred to by Java constants and mapped internally
  41  * onto Java language data types and type names as follows:
  42  *
  43  * <br>
  44  * <br>
  45  * <table border="1">
  46  * <caption>TIFF Data Type to Java Data Type Mapping</caption>
  47  *
  48  * <tr>
  49  * <th>
  50  * <b>TIFF Data Type</b>
  51  * </th>
  52  * <th>
  53  * <b>Java Constant</b>
  54  * </th>
  55  * <th>
  56  * <b>Java Data Type</b>
  57  * </th>
  58  * <th>
  59  * <b>Java Type Name</b>
  60  * </th>
  61  * </tr>
  62  *
  63  * <tr>
  64  * <td>
  65  * {@code BYTE}
  66  * </td>
  67  * <td>
  68  * {@link TIFFTag#TIFF_BYTE}
  69  * </td>
  70  * <td>
  71  * {@code byte}
  72  * </td>
  73  * <td>
  74  * {@code "Byte"}
  75  * </td>
  76  * </tr>
  77  *
  78  * <tr>
  79  * <td>
  80  * {@code ASCII}
  81  * </td>
  82  * <td>
  83  * {@link TIFFTag#TIFF_ASCII}
  84  * </td>
  85  * <td>
  86  * {@code String}
  87  * </td>
  88  * <td>
  89  * {@code "Ascii"}
  90  * </td>
  91  * </tr>
  92  *
  93  * <tr>
  94  * <td>
  95  * {@code SHORT}
  96  * </td>
  97  * <td>
  98  * {@link TIFFTag#TIFF_SHORT}
  99  * </td>
 100  * <td>
 101  * {@code char}
 102  * </td>
 103  * <td>
 104  * {@code "Short"}
 105  * </td>
 106  * </tr>
 107  *
 108  * <tr>
 109  * <td>
 110  * {@code LONG}
 111  * </td>
 112  * <td>
 113  * {@link TIFFTag#TIFF_LONG}
 114  * </td>
 115  * <td>
 116  * {@code long}
 117  * </td>
 118  * <td>
 119  * {@code "Long"}
 120  * </td>
 121  * </tr>
 122  *
 123  * <tr>
 124  * <td>
 125  * {@code RATIONAL}
 126  * </td>
 127  * <td>
 128  * {@link TIFFTag#TIFF_RATIONAL}
 129  * </td>
 130  * <td>
 131  * {@code long[2]} {numerator, denominator}
 132  * </td>
 133  * <td>
 134  * {@code "Rational"}
 135  * </td>
 136  * </tr>
 137  *
 138  * <tr>
 139  * <td>
 140  * {@code SBYTE}
 141  * </td>
 142  * <td>
 143  * {@link TIFFTag#TIFF_SBYTE}
 144  * </td>
 145  * <td>
 146  * {@code byte}
 147  * </td>
 148  * <td>
 149  * {@code "SByte"}
 150  * </td>
 151  * </tr>
 152  *
 153  * <tr>
 154  * <td>
 155  * {@code UNDEFINED}
 156  * </td>
 157  * <td>
 158  * {@link TIFFTag#TIFF_UNDEFINED}
 159  * </td>
 160  * <td>
 161  * {@code byte}
 162  * </td>
 163  * <td>
 164  * {@code "Undefined"}
 165  * </td>
 166  * </tr>
 167  *
 168  * <tr>
 169  * <td>
 170  * {@code SSHORT}
 171  * </td>
 172  * <td>
 173  * {@link TIFFTag#TIFF_SSHORT}
 174  * </td>
 175  * <td>
 176  * {@code short}
 177  * </td>
 178  * <td>
 179  * {@code "SShort"}
 180  * </td>
 181  * </tr>
 182  *
 183  * <tr>
 184  * <td>
 185  * {@code SLONG}
 186  * </td>
 187  * <td>
 188  * {@link TIFFTag#TIFF_SLONG}
 189  * </td>
 190  * <td>
 191  * {@code int}
 192  * </td>
 193  * <td>
 194  * {@code "SLong"}
 195  * </td>
 196  * </tr>
 197  *
 198  * <tr>
 199  * <td>
 200  * {@code SRATIONAL}
 201  * </td>
 202  * <td>
 203  * {@link TIFFTag#TIFF_SRATIONAL}
 204  * </td>
 205  * <td>
 206  * {@code int[2]} {numerator, denominator}
 207  * </td>
 208  * <td>
 209  * {@code "SRational"}
 210  * </td>
 211  * </tr>
 212  *
 213  * <tr>
 214  * <td>
 215  * {@code FLOAT}
 216  * </td>
 217  * <td>
 218  * {@link TIFFTag#TIFF_FLOAT}
 219  * </td>
 220  * <td>
 221  * {@code float}
 222  * </td>
 223  * <td>
 224  * {@code "Float"}
 225  * </td>
 226  * </tr>
 227  *
 228  * <tr>
 229  * <td>
 230  * {@code DOUBLE}
 231  * </td>
 232  * <td>
 233  * {@link TIFFTag#TIFF_DOUBLE}
 234  * </td>
 235  * <td>
 236  * {@code double}
 237  * </td>
 238  * <td>
 239  * {@code "Double"}
 240  * </td>
 241  * </tr>
 242  *
 243  * <tr>
 244  * <td>
 245  * {@code IFD}
 246  * </td>
 247  * <td>
 248  * {@link TIFFTag#TIFF_IFD_POINTER}
 249  * </td>
 250  * <td>
 251  * {@code long}
 252  * </td>
 253  * <td>
 254  * {@code "IFDPointer"}
 255  * </td>
 256  * </tr>
 257  *
 258  * </table>
 259  *
 260  * @since 9
 261  * @see   TIFFDirectory
 262  * @see   TIFFTag
 263  */
 264 public final class TIFFField implements Cloneable {
 265 
 266     private static final long MAX_UINT32 = 0xffffffffL;
 267 
 268     private static final String[] TYPE_NAMES = {
 269         null,
 270         "Byte", "Ascii", "Short", "Long", "Rational",
 271         "SByte", "Undefined", "SShort", "SLong", "SRational",
 272         "Float", "Double", "IFDPointer"
 273     };
 274 
 275     private static final boolean[] IS_INTEGRAL = {
 276         false,
 277         true, false, true, true, false,




  23  * questions.
  24  */
  25 package javax.imageio.plugins.tiff;
  26 
  27 import java.util.StringTokenizer;
  28 import org.w3c.dom.NamedNodeMap;
  29 import org.w3c.dom.Node;
  30 import com.sun.imageio.plugins.tiff.TIFFFieldNode;
  31 import com.sun.imageio.plugins.tiff.TIFFIFD;
  32 
  33 /**
  34  * A class representing a field in a TIFF 6.0 Image File Directory.
  35  *
  36  * <p> A field in a TIFF Image File Directory (IFD) is defined as a
  37  * tag number accompanied by a sequence of values of identical data type.
  38  * TIFF 6.0 defines 12 data types; a 13th type {@code IFD} is
  39  * defined in TIFF Tech Note 1 of TIFF Specification Supplement 1. These
  40  * TIFF data types are referred to by Java constants and mapped internally
  41  * onto Java language data types and type names as follows:
  42  *
  43  * <table class="striped">


  44  * <caption>TIFF Data Type to Java Data Type Mapping</caption>
  45  * <thead>
  46  *   <tr>
  47  *     <th scope="col">TIFF Data Type
  48  *     <th scope="col">Java Constant
  49  *     <th scope="col">Java Data Type
  50  *     <th scope="col">Java Type Name
  51  * </thead>
  52  * <tbody>








  53  *   <tr>
  54  *     <th scope="row">{@code BYTE}
  55  *     <td>{@link TIFFTag#TIFF_BYTE}
  56  *     <td>{@code byte}
  57  *     <td>{@code "Byte"}










  58  *   <tr>
  59  *     <th scope="row">{@code ASCII}
  60  *     <td>{@link TIFFTag#TIFF_ASCII}
  61  *     <td>{@code String}
  62  *     <td>{@code "Ascii"}










  63  *   <tr>
  64  *     <th scope="row">{@code SHORT}
  65  *     <td>{@link TIFFTag#TIFF_SHORT}
  66  *     <td>{@code char}
  67  *     <td>{@code "Short"}










  68  *   <tr>
  69  *     <th scope="row">{@code LONG}
  70  *     <td>{@link TIFFTag#TIFF_LONG}
  71  *     <td>{@code long}
  72  *     <td>{@code "Long"}










  73  *   <tr>
  74  *     <th scope="row">{@code RATIONAL}
  75  *     <td>{@link TIFFTag#TIFF_RATIONAL}
  76  *     <td>{@code long[2]} {numerator, denominator}
  77  *     <td>{@code "Rational"}










  78  *   <tr>
  79  *     <th scope="row">{@code SBYTE}
  80  *     <td>{@link TIFFTag#TIFF_SBYTE}
  81  *     <td>{@code byte}
  82  *     <td>{@code "SByte"}










  83  *   <tr>
  84  *     <th scope="row">{@code UNDEFINED}
  85  *     <td>{@link TIFFTag#TIFF_UNDEFINED}
  86  *     <td>{@code byte}
  87  *     <td>{@code "Undefined"}










  88  *   <tr>
  89  *     <th scope="row">{@code SSHORT}
  90  *     <td>{@link TIFFTag#TIFF_SSHORT}
  91  *     <td>{@code short}
  92  *     <td>{@code "SShort"}










  93  *   <tr>
  94  *     <th scope="row">{@code SLONG}
  95  *     <td>{@link TIFFTag#TIFF_SLONG}
  96  *     <td>{@code int}
  97  *     <td>{@code "SLong"}










  98  *   <tr>
  99  *     <th scope="row">{@code SRATIONAL}
 100  *     <td>{@link TIFFTag#TIFF_SRATIONAL}
 101  *     <td>{@code int[2]} {numerator, denominator}
 102  *     <td>{@code "SRational"}










 103  *   <tr>
 104  *     <th scope="row">{@code FLOAT}
 105  *     <td>{@link TIFFTag#TIFF_FLOAT}
 106  *     <td>{@code float}
 107  *     <td>{@code "Float"}










 108  *   <tr>
 109  *     <th scope="row">{@code DOUBLE}
 110  *     <td>{@link TIFFTag#TIFF_DOUBLE}
 111  *     <td>{@code double}
 112  *     <td>{@code "Double"}










 113  *   <tr>
 114  *     <th scope="row">{@code IFD}
 115  *     <td>{@link TIFFTag#TIFF_IFD_POINTER}
 116  *     <td>{@code long}
 117  *     <td>{@code "IFDPointer"}








 118  *   </tr>
 119  * </tbody>
 120  * </table>
 121  *
 122  * @since 9
 123  * @see   TIFFDirectory
 124  * @see   TIFFTag
 125  */
 126 public final class TIFFField implements Cloneable {
 127 
 128     private static final long MAX_UINT32 = 0xffffffffL;
 129 
 130     private static final String[] TYPE_NAMES = {
 131         null,
 132         "Byte", "Ascii", "Short", "Long", "Rational",
 133         "SByte", "Undefined", "SShort", "SLong", "SRational",
 134         "Float", "Double", "IFDPointer"
 135     };
 136 
 137     private static final boolean[] IS_INTEGRAL = {
 138         false,
 139         true, false, true, true, false,


< prev index next >