src/share/classes/javax/imageio/spi/ImageReaderSpi.java

Print this page




 220               nativeImageMetadataFormatName,
 221               nativeImageMetadataFormatClassName,
 222               extraImageMetadataFormatNames,
 223               extraImageMetadataFormatClassNames);
 224 
 225         if (inputTypes == null) {
 226             throw new IllegalArgumentException
 227                 ("inputTypes == null!");
 228         }
 229         if (inputTypes.length == 0) {
 230             throw new IllegalArgumentException
 231                 ("inputTypes.length == 0!");
 232         }
 233 
 234         this.inputTypes = (inputTypes == STANDARD_INPUT_TYPE) ?
 235             new Class<?>[] { ImageInputStream.class } :
 236             inputTypes.clone();
 237 
 238         // If length == 0, leave it null
 239         if (writerSpiNames != null && writerSpiNames.length > 0) {
 240             this.writerSpiNames = (String[])writerSpiNames.clone();
 241         }
 242     }
 243 
 244     /**
 245      * Returns an array of <code>Class</code> objects indicating what
 246      * types of objects may be used as arguments to the reader's
 247      * <code>setInput</code> method.
 248      *
 249      * <p> For most readers, which only accept input from an
 250      * <code>ImageInputStream</code>, a single-element array
 251      * containing <code>ImageInputStream.class</code> should be
 252      * returned.
 253      *
 254      * @return a non-<code>null</code> array of
 255      * <code>Class</code>objects of length at least 1.
 256      */
 257     public Class[] getInputTypes() {
 258         return (Class[])inputTypes.clone();
 259     }
 260 
 261     /**
 262      * Returns <code>true</code> if the supplied source object appears
 263      * to be of the format supported by this reader.  Returning
 264      * <code>true</code> from this method does not guarantee that
 265      * reading will succeed, only that there appears to be a
 266      * reasonable chance of success based on a brief inspection of the
 267      * stream contents.  If the source is an
 268      * <code>ImageInputStream</code>, implementations will commonly
 269      * check the first several bytes of the stream for a "magic
 270      * number" associated with the format.  Once actual reading has
 271      * commenced, the reader may still indicate failure at any time
 272      * prior to the completion of decoding.
 273      *
 274      * <p> It is important that the state of the object not be
 275      * disturbed in order that other <code>ImageReaderSpi</code>s can
 276      * properly determine whether they are able to decode the object.
 277      * In particular, if the source is an
 278      * <code>ImageInputStream</code>, a


 391      * <p> This mechanism may be used to obtain
 392      * <code>ImageWriters</code> that will understand the internal
 393      * structure of non-pixel meta-data (see
 394      * <code>IIOTreeInfo</code>) generated by an
 395      * <code>ImageReader</code>.  By obtaining this data from the
 396      * <code>ImageReader</code> and passing it on to one of the
 397      * <code>ImageWriters</code> obtained with this method, a client
 398      * program can read an image, modify it in some way, and write it
 399      * back out while preserving all meta-data, without having to
 400      * understand anything about the internal structure of the
 401      * meta-data, or even about the image format.
 402      *
 403      * @return an array of <code>String</code>s of length at least 1
 404      * containing names of <code>ImageWriterSpi</code>, or
 405      * <code>null</code>.
 406      *
 407      * @see javax.imageio.ImageIO#getImageWriter(ImageReader)
 408      */
 409     public String[] getImageWriterSpiNames() {
 410         return writerSpiNames == null ?
 411             null : (String[])writerSpiNames.clone();
 412     }
 413 }


 220               nativeImageMetadataFormatName,
 221               nativeImageMetadataFormatClassName,
 222               extraImageMetadataFormatNames,
 223               extraImageMetadataFormatClassNames);
 224 
 225         if (inputTypes == null) {
 226             throw new IllegalArgumentException
 227                 ("inputTypes == null!");
 228         }
 229         if (inputTypes.length == 0) {
 230             throw new IllegalArgumentException
 231                 ("inputTypes.length == 0!");
 232         }
 233 
 234         this.inputTypes = (inputTypes == STANDARD_INPUT_TYPE) ?
 235             new Class<?>[] { ImageInputStream.class } :
 236             inputTypes.clone();
 237 
 238         // If length == 0, leave it null
 239         if (writerSpiNames != null && writerSpiNames.length > 0) {
 240             this.writerSpiNames = writerSpiNames.clone();
 241         }
 242     }
 243 
 244     /**
 245      * Returns an array of <code>Class</code> objects indicating what
 246      * types of objects may be used as arguments to the reader's
 247      * <code>setInput</code> method.
 248      *
 249      * <p> For most readers, which only accept input from an
 250      * <code>ImageInputStream</code>, a single-element array
 251      * containing <code>ImageInputStream.class</code> should be
 252      * returned.
 253      *
 254      * @return a non-<code>null</code> array of
 255      * <code>Class</code>objects of length at least 1.
 256      */
 257     public Class[] getInputTypes() {
 258         return inputTypes.clone();
 259     }
 260 
 261     /**
 262      * Returns <code>true</code> if the supplied source object appears
 263      * to be of the format supported by this reader.  Returning
 264      * <code>true</code> from this method does not guarantee that
 265      * reading will succeed, only that there appears to be a
 266      * reasonable chance of success based on a brief inspection of the
 267      * stream contents.  If the source is an
 268      * <code>ImageInputStream</code>, implementations will commonly
 269      * check the first several bytes of the stream for a "magic
 270      * number" associated with the format.  Once actual reading has
 271      * commenced, the reader may still indicate failure at any time
 272      * prior to the completion of decoding.
 273      *
 274      * <p> It is important that the state of the object not be
 275      * disturbed in order that other <code>ImageReaderSpi</code>s can
 276      * properly determine whether they are able to decode the object.
 277      * In particular, if the source is an
 278      * <code>ImageInputStream</code>, a


 391      * <p> This mechanism may be used to obtain
 392      * <code>ImageWriters</code> that will understand the internal
 393      * structure of non-pixel meta-data (see
 394      * <code>IIOTreeInfo</code>) generated by an
 395      * <code>ImageReader</code>.  By obtaining this data from the
 396      * <code>ImageReader</code> and passing it on to one of the
 397      * <code>ImageWriters</code> obtained with this method, a client
 398      * program can read an image, modify it in some way, and write it
 399      * back out while preserving all meta-data, without having to
 400      * understand anything about the internal structure of the
 401      * meta-data, or even about the image format.
 402      *
 403      * @return an array of <code>String</code>s of length at least 1
 404      * containing names of <code>ImageWriterSpi</code>, or
 405      * <code>null</code>.
 406      *
 407      * @see javax.imageio.ImageIO#getImageWriter(ImageReader)
 408      */
 409     public String[] getImageWriterSpiNames() {
 410         return writerSpiNames == null ?
 411             null : writerSpiNames.clone();
 412     }
 413 }