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

Print this page


   1 /*
   2  * Copyright (c) 1999, 2001, 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


 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 }
   1 /*
   2  * Copyright (c) 1999, 2014, 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


 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 }