< prev index next >

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

Print this page




  29 import javax.imageio.ImageReadParam;
  30 
  31 /**
  32  * A subclass of {@link ImageReadParam} allowing control over
  33  * the TIFF reading process.
  34  *
  35  * <p> Because TIFF is an extensible format, the reader requires
  36  * information about any tags used by TIFF extensions in order to emit
  37  * meaningful metadata.  Also, TIFF extensions may define new
  38  * compression types.  Both types of information about extensions may
  39  * be provided by this interface.
  40  *
  41  * <p> Additional TIFF tags must be organized into
  42  * {@code TIFFTagSet}s.  A {@code TIFFTagSet} may be
  43  * provided to the reader by means of the
  44  * {@code addAllowedTagSet} method.  By default, the tag sets
  45  * {@code BaselineTIFFTagSet}, {@code FaxTIFFTagSet},
  46  * {@code ExifParentTIFFTagSet}, and {@code GeoTIFFTagSet}
  47  * are included.
  48  *




  49  * @since 9
  50  */
  51 public final class TIFFImageReadParam extends ImageReadParam {
  52 
  53     private final List<TIFFTagSet> allowedTagSets =
  54         new ArrayList<TIFFTagSet>(4);
  55 


  56     /**
  57      * Constructs a {@code TIFFImageReadParam}.  Tags defined by
  58      * the {@code TIFFTagSet}s {@code BaselineTIFFTagSet},
  59      * {@code FaxTIFFTagSet}, {@code ExifParentTIFFTagSet}, and
  60      * {@code GeoTIFFTagSet} will be supported.
  61      *
  62      * @see BaselineTIFFTagSet
  63      * @see FaxTIFFTagSet
  64      * @see ExifParentTIFFTagSet
  65      * @see GeoTIFFTagSet
  66      */
  67     public TIFFImageReadParam() {
  68         addAllowedTagSet(BaselineTIFFTagSet.getInstance());
  69         addAllowedTagSet(FaxTIFFTagSet.getInstance());
  70         addAllowedTagSet(ExifParentTIFFTagSet.getInstance());
  71         addAllowedTagSet(GeoTIFFTagSet.getInstance());
  72     }
  73 
  74     /**
  75      * Adds a {@code TIFFTagSet} object to the list of allowed


 100      *
 101      * @throws IllegalArgumentException if {@code tagSet} is
 102      * {@code null}.
 103      */
 104     public void removeAllowedTagSet(TIFFTagSet tagSet) {
 105         if (tagSet == null) {
 106             throw new IllegalArgumentException("tagSet == null!");
 107         }
 108         allowedTagSets.remove(tagSet);
 109     }
 110 
 111     /**
 112      * Returns a {@code List} containing the allowed
 113      * {@code TIFFTagSet} objects.
 114      *
 115      * @return a {@code List} of {@code TIFFTagSet}s.
 116      */
 117     public List<TIFFTagSet> getAllowedTagSets() {
 118         return allowedTagSets;
 119     }























 120 }


  29 import javax.imageio.ImageReadParam;
  30 
  31 /**
  32  * A subclass of {@link ImageReadParam} allowing control over
  33  * the TIFF reading process.
  34  *
  35  * <p> Because TIFF is an extensible format, the reader requires
  36  * information about any tags used by TIFF extensions in order to emit
  37  * meaningful metadata.  Also, TIFF extensions may define new
  38  * compression types.  Both types of information about extensions may
  39  * be provided by this interface.
  40  *
  41  * <p> Additional TIFF tags must be organized into
  42  * {@code TIFFTagSet}s.  A {@code TIFFTagSet} may be
  43  * provided to the reader by means of the
  44  * {@code addAllowedTagSet} method.  By default, the tag sets
  45  * {@code BaselineTIFFTagSet}, {@code FaxTIFFTagSet},
  46  * {@code ExifParentTIFFTagSet}, and {@code GeoTIFFTagSet}
  47  * are included.
  48  *
  49  * <p> Forcing reading of fields corresponding to {@code TIFFTag}s
  50  * not in any of the allowed {@code TIFFTagSet}s may be effected via
  51  * {@link #setReadUnknownTags setReadUnknownTags}.
  52  *
  53  * @since 9
  54  */
  55 public final class TIFFImageReadParam extends ImageReadParam {
  56 
  57     private final List<TIFFTagSet> allowedTagSets =
  58         new ArrayList<TIFFTagSet>(4);
  59 
  60     private boolean readUnknownTags = false;
  61 
  62     /**
  63      * Constructs a {@code TIFFImageReadParam}.  Tags defined by
  64      * the {@code TIFFTagSet}s {@code BaselineTIFFTagSet},
  65      * {@code FaxTIFFTagSet}, {@code ExifParentTIFFTagSet}, and
  66      * {@code GeoTIFFTagSet} will be supported.
  67      *
  68      * @see BaselineTIFFTagSet
  69      * @see FaxTIFFTagSet
  70      * @see ExifParentTIFFTagSet
  71      * @see GeoTIFFTagSet
  72      */
  73     public TIFFImageReadParam() {
  74         addAllowedTagSet(BaselineTIFFTagSet.getInstance());
  75         addAllowedTagSet(FaxTIFFTagSet.getInstance());
  76         addAllowedTagSet(ExifParentTIFFTagSet.getInstance());
  77         addAllowedTagSet(GeoTIFFTagSet.getInstance());
  78     }
  79 
  80     /**
  81      * Adds a {@code TIFFTagSet} object to the list of allowed


 106      *
 107      * @throws IllegalArgumentException if {@code tagSet} is
 108      * {@code null}.
 109      */
 110     public void removeAllowedTagSet(TIFFTagSet tagSet) {
 111         if (tagSet == null) {
 112             throw new IllegalArgumentException("tagSet == null!");
 113         }
 114         allowedTagSets.remove(tagSet);
 115     }
 116 
 117     /**
 118      * Returns a {@code List} containing the allowed
 119      * {@code TIFFTagSet} objects.
 120      *
 121      * @return a {@code List} of {@code TIFFTagSet}s.
 122      */
 123     public List<TIFFTagSet> getAllowedTagSets() {
 124         return allowedTagSets;
 125     }
 126 
 127     /**
 128      * Set whether to read fields corresponding to {@code TIFFTag}s not in
 129      * the allowed {@code TIFFTagSet}s. The default setting is {@code false}.
 130      * If the TIFF {@code ImageReader} is ignoring metadata, then a setting
 131      * of {@code true} is overridden as all metadata are ignored except those
 132      * essential to reading the image itself.
 133      *
 134      * @param readUnknownTags Whether to read fields of unrecognized tags
 135      */
 136     public void setReadUnknownTags(boolean readUnknownTags) {
 137         this.readUnknownTags = readUnknownTags;
 138     }
 139 
 140     /**
 141      * Retrieve the setting of whether to read fields corresponding to unknown
 142      * {@code TIFFTag}s.
 143      *
 144      * @return Whether to read fields of unrecognized tags
 145      */
 146     public boolean getReadUnknownTags() {
 147         return readUnknownTags;
 148     }
 149 }
< prev index next >