jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java
changeset 34416 68c0d866db5d
child 35302 e4d2275861c3
equal deleted inserted replaced
34415:098d54b4051d 34416:68c0d866db5d
       
     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 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</code>s.  A <code>TIFFTagSet</code> may be
       
    43  * provided to the reader by means of the
       
    44  * <code>addAllowedTagSet</code> method.  By default, the tag sets
       
    45  * <code>BaselineTIFFTagSet</code>, <code>FaxTIFFTagSet</code>,
       
    46  * <code>ExifParentTIFFTagSet</code>, and <code>GeoTIFFTagSet</code>
       
    47  * are included.
       
    48  *
       
    49  * @since 1.9
       
    50  */
       
    51 public class TIFFImageReadParam extends ImageReadParam {
       
    52 
       
    53     private List<TIFFTagSet> allowedTagSets = new ArrayList<TIFFTagSet>(4);
       
    54 
       
    55     /**
       
    56      * Constructs a <code>TIFFImageReadParam</code>.  Tags defined by
       
    57      * the <code>TIFFTagSet</code>s <code>BaselineTIFFTagSet</code>,
       
    58      * <code>FaxTIFFTagSet</code>, <code>ExifParentTIFFTagSet</code>, and
       
    59      * <code>GeoTIFFTagSet</code> will be supported.
       
    60      *
       
    61      * @see BaselineTIFFTagSet
       
    62      * @see FaxTIFFTagSet
       
    63      * @see ExifParentTIFFTagSet
       
    64      * @see GeoTIFFTagSet
       
    65      */
       
    66     public TIFFImageReadParam() {
       
    67         addAllowedTagSet(BaselineTIFFTagSet.getInstance());
       
    68         addAllowedTagSet(FaxTIFFTagSet.getInstance());
       
    69         addAllowedTagSet(ExifParentTIFFTagSet.getInstance());
       
    70         addAllowedTagSet(GeoTIFFTagSet.getInstance());
       
    71     }
       
    72 
       
    73     /**
       
    74      * Adds a <code>TIFFTagSet</code> object to the list of allowed
       
    75      * tag sets.
       
    76      *
       
    77      * @param tagSet a <code>TIFFTagSet</code>.
       
    78      *
       
    79      * @throws IllegalArgumentException if <code>tagSet</code> is
       
    80      * <code>null</code>.
       
    81      */
       
    82     public void addAllowedTagSet(TIFFTagSet tagSet) {
       
    83         if (tagSet == null) {
       
    84             throw new IllegalArgumentException("tagSet == null!");
       
    85         }
       
    86         allowedTagSets.add(tagSet);
       
    87     }
       
    88 
       
    89     /**
       
    90      * Removes a <code>TIFFTagSet</code> object from the list of
       
    91      * allowed tag sets.  Removal is based on the <code>equals</code>
       
    92      * method of the <code>TIFFTagSet</code>, which is normally
       
    93      * defined as reference equality.
       
    94      *
       
    95      * @param tagSet a <code>TIFFTagSet</code>.
       
    96      *
       
    97      * @throws IllegalArgumentException if <code>tagSet</code> is
       
    98      * <code>null</code>.
       
    99      */
       
   100     public void removeAllowedTagSet(TIFFTagSet tagSet) {
       
   101         if (tagSet == null) {
       
   102             throw new IllegalArgumentException("tagSet == null!");
       
   103         }
       
   104         allowedTagSets.remove(tagSet);
       
   105     }
       
   106 
       
   107     /**
       
   108      * Returns a <code>List</code> containing the allowed
       
   109      * <code>TIFFTagSet</code> objects.
       
   110      *
       
   111      * @return a <code>List</code> of <code>TIFFTagSet</code>s.
       
   112      */
       
   113     public List<TIFFTagSet> getAllowedTagSets() {
       
   114         return allowedTagSets;
       
   115     }
       
   116 }