< prev index next >

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

Print this page




 655     public TIFFField(TIFFTag tag, int type, int count) {
 656         this(tag, type, count, createArrayForType(type, count));
 657     }
 658 
 659     /**
 660      * Constructs a {@code TIFFField} with a single non-negative integral
 661      * value.
 662      * The field will have type
 663      * {@link TIFFTag#TIFF_SHORT  TIFF_SHORT} if
 664      * {@code val < 65536} and type
 665      * {@link TIFFTag#TIFF_LONG TIFF_LONG} otherwise.  The count
 666      * of the field will be unity.
 667      *
 668      * @param tag The tag to associate with this field.
 669      * @param value The value to associate with this field.
 670      * @throws NullPointerException if {@code tag == null}.
 671      * @throws IllegalArgumentException if the derived type is unacceptable
 672      * for the supplied {@code TIFFTag}.
 673      * @throws IllegalArgumentException if {@code value < 0}.
 674      */
 675     public TIFFField(TIFFTag tag, int value) {
 676         if(tag == null) {
 677             throw new NullPointerException("tag == null!");
 678         }
 679         if (value < 0) {
 680             throw new IllegalArgumentException("value < 0!");
 681         }
 682 
 683         this.tag = tag;
 684         this.tagNumber = tag.getNumber();
 685         this.count = 1;
 686 
 687         if (value < 65536) {
 688             if (!tag.isDataTypeOK(TIFFTag.TIFF_SHORT)) {
 689                 throw new IllegalArgumentException("Illegal data type "
 690                     + TIFFTag.TIFF_SHORT + " for " + tag.getName() + " tag");
 691             }
 692             this.type = TIFFTag.TIFF_SHORT;
 693             char[] cdata = new char[1];
 694             cdata[0] = (char)value;
 695             this.data = cdata;




 655     public TIFFField(TIFFTag tag, int type, int count) {
 656         this(tag, type, count, createArrayForType(type, count));
 657     }
 658 
 659     /**
 660      * Constructs a {@code TIFFField} with a single non-negative integral
 661      * value.
 662      * The field will have type
 663      * {@link TIFFTag#TIFF_SHORT  TIFF_SHORT} if
 664      * {@code val < 65536} and type
 665      * {@link TIFFTag#TIFF_LONG TIFF_LONG} otherwise.  The count
 666      * of the field will be unity.
 667      *
 668      * @param tag The tag to associate with this field.
 669      * @param value The value to associate with this field.
 670      * @throws NullPointerException if {@code tag == null}.
 671      * @throws IllegalArgumentException if the derived type is unacceptable
 672      * for the supplied {@code TIFFTag}.
 673      * @throws IllegalArgumentException if {@code value < 0}.
 674      */
 675     public TIFFField(TIFFTag tag, long value) {
 676         if(tag == null) {
 677             throw new NullPointerException("tag == null!");
 678         }
 679         if (value < 0) {
 680             throw new IllegalArgumentException("value < 0!");
 681         }
 682 
 683         this.tag = tag;
 684         this.tagNumber = tag.getNumber();
 685         this.count = 1;
 686 
 687         if (value < 65536) {
 688             if (!tag.isDataTypeOK(TIFFTag.TIFF_SHORT)) {
 689                 throw new IllegalArgumentException("Illegal data type "
 690                     + TIFFTag.TIFF_SHORT + " for " + tag.getName() + " tag");
 691             }
 692             this.type = TIFFTag.TIFF_SHORT;
 693             char[] cdata = new char[1];
 694             cdata[0] = (char)value;
 695             this.data = cdata;


< prev index next >