|
From: <ls...@us...> - 2007-01-07 08:19:54
|
Revision: 2999
http://jnode.svn.sourceforge.net/jnode/?rev=2999&view=rev
Author: lsantha
Date: 2007-01-07 00:19:52 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
Classpath patches.
Modified Paths:
--------------
trunk/core/src/classpath/javax/javax/imageio/IIOImage.java
trunk/core/src/classpath/javax/javax/imageio/ImageIO.java
trunk/core/src/classpath/javax/javax/imageio/ImageReader.java
trunk/core/src/classpath/javax/javax/imageio/ImageWriteParam.java
trunk/core/src/classpath/javax/javax/imageio/ImageWriter.java
trunk/core/src/classpath/javax/javax/imageio/metadata/IIOMetadataFormat.java
trunk/core/src/classpath/javax/javax/imageio/metadata/IIOMetadataFormatImpl.java
trunk/core/src/classpath/javax/javax/imageio/spi/IIORegistry.java
trunk/core/src/classpath/javax/javax/imageio/spi/IIOServiceProvider.java
trunk/core/src/classpath/javax/javax/imageio/spi/ImageInputStreamSpi.java
trunk/core/src/classpath/javax/javax/imageio/spi/ImageOutputStreamSpi.java
trunk/core/src/classpath/javax/javax/imageio/spi/RegisterableService.java
trunk/core/src/classpath/javax/javax/imageio/spi/ServiceRegistry.java
trunk/core/src/classpath/javax/javax/imageio/stream/FileCacheImageOutputStream.java
Modified: trunk/core/src/classpath/javax/javax/imageio/IIOImage.java
===================================================================
--- trunk/core/src/classpath/javax/javax/imageio/IIOImage.java 2007-01-07 05:43:57 UTC (rev 2998)
+++ trunk/core/src/classpath/javax/javax/imageio/IIOImage.java 2007-01-07 08:19:52 UTC (rev 2999)
@@ -79,8 +79,7 @@
/**
* A list of BufferedImage thumbnails of this image.
*/
- // for 1.5 these lists are List<? extends BufferedImage>
- protected List thumbnails;
+ protected List<? extends BufferedImage> thumbnails;
/**
* Construct an IIOImage containing raster image data, thumbnails
@@ -92,7 +91,8 @@
*
* @exception IllegalArgumentException if raster is null
*/
- public IIOImage (Raster raster, List thumbnails, IIOMetadata metadata)
+ public IIOImage (Raster raster, List<? extends BufferedImage> thumbnails,
+ IIOMetadata metadata)
{
if (raster == null)
throw new IllegalArgumentException ("raster may not be null");
@@ -112,7 +112,8 @@
*
* @exception IllegalArgumentException if image is null
*/
- public IIOImage (RenderedImage image, List thumbnails, IIOMetadata metadata)
+ public IIOImage (RenderedImage image, List<? extends BufferedImage> thumbnails,
+ IIOMetadata metadata)
{
if (image == null)
throw new IllegalArgumentException ("image may not be null");
@@ -192,7 +193,7 @@
*
* @return a list of thumbnails or null
*/
- public List getThumbnails()
+ public List<? extends BufferedImage> getThumbnails()
{
return thumbnails;
}
@@ -260,7 +261,7 @@
*
* @param thumbnails a new list of thumbnails or null
*/
- public void setThumbnails (List thumbnails)
+ public void setThumbnails (List<? extends BufferedImage> thumbnails)
{
this.thumbnails = thumbnails;
}
Modified: trunk/core/src/classpath/javax/javax/imageio/ImageIO.java
===================================================================
--- trunk/core/src/classpath/javax/javax/imageio/ImageIO.java 2007-01-07 05:43:57 UTC (rev 2998)
+++ trunk/core/src/classpath/javax/javax/imageio/ImageIO.java 2007-01-07 08:19:52 UTC (rev 2999)
@@ -315,27 +315,37 @@
}
}
- private static final class ImageReaderIterator implements Iterator
+ private static final class ImageReaderIterator
+ implements Iterator<ImageReader>
{
- Iterator it;
+ Iterator<ImageReaderSpi> it;
Object readerExtension;
- public ImageReaderIterator(Iterator it, Object readerExtension)
+ public ImageReaderIterator(Iterator<ImageReaderSpi> it,
+ Object readerExtension)
{
this.it = it;
this.readerExtension = readerExtension;
}
+ public ImageReaderIterator(Iterator<ImageReaderSpi> it)
+ {
+ this.it = it;
+ }
+
public boolean hasNext()
{
return it.hasNext();
}
- public Object next()
+ public ImageReader next()
{
try
{
- return ((ImageReaderSpi) it.next()).createReaderInstance(readerExtension);
+ ImageReaderSpi spi = it.next();
+ return (readerExtension == null
+ ? spi.createReaderInstance()
+ : spi.createReaderInstance(readerExtension));
}
catch (IOException e)
{
@@ -349,27 +359,37 @@
}
}
- private static final class ImageWriterIterator implements Iterator
+ private static final class ImageWriterIterator
+ implements Iterator<ImageWriter>
{
- Iterator it;
+ Iterator<ImageWriterSpi> it;
Object writerExtension;
- public ImageWriterIterator(Iterator it, Object writerExtension)
+ public ImageWriterIterator(Iterator<ImageWriterSpi> it,
+ Object writerExtension)
{
this.it = it;
this.writerExtension = writerExtension;
}
+ public ImageWriterIterator(Iterator<ImageWriterSpi> it)
+ {
+ this.it = it;
+ }
+
public boolean hasNext()
{
return it.hasNext();
}
- public Object next()
+ public ImageWriter next()
{
try
{
- return ((ImageWriterSpi) it.next()).createWriterInstance(writerExtension);
+ ImageWriterSpi spi = it.next();
+ return (writerExtension == null
+ ? spi.createWriterInstance()
+ : spi.createWriterInstance(writerExtension));
}
catch (IOException e)
{
@@ -386,13 +406,14 @@
private static File cacheDirectory;
private static boolean useCache = true;
- private static Iterator getReadersByFilter(Class type,
+ private static Iterator<ImageReader> getReadersByFilter(Class<ImageReaderSpi> type,
ServiceRegistry.Filter filter,
Object readerExtension)
{
try
{
- Iterator it = getRegistry().getServiceProviders(type, filter, true);
+ Iterator<ImageReaderSpi> it
+ = getRegistry().getServiceProviders(type, filter, true);
return new ImageReaderIterator(it, readerExtension);
}
catch (IllegalArgumentException e)
@@ -401,13 +422,14 @@
}
}
- private static Iterator getWritersByFilter(Class type,
+ private static Iterator<ImageWriter> getWritersByFilter(Class<ImageWriterSpi> type,
ServiceRegistry.Filter filter,
Object writerExtension)
{
try
{
- Iterator it = getRegistry().getServiceProviders(type, filter, true);
+ Iterator<ImageWriterSpi> it
+ = getRegistry().getServiceProviders(type, filter, true);
return new ImageWriterIterator(it, writerExtension);
}
catch (IllegalArgumentException e)
@@ -436,7 +458,7 @@
*
* @exception IllegalArgumentException if formatName is null
*/
- public static Iterator getImageReadersByFormatName(String formatName)
+ public static Iterator<ImageReader> getImageReadersByFormatName(String formatName)
{
if (formatName == null)
throw new IllegalArgumentException("formatName may not be null");
@@ -457,7 +479,7 @@
*
* @exception IllegalArgumentException if MIMEType is null
*/
- public static Iterator getImageReadersByMIMEType(String MIMEType)
+ public static Iterator<ImageReader> getImageReadersByMIMEType(String MIMEType)
{
if (MIMEType == null)
throw new IllegalArgumentException("MIMEType may not be null");
@@ -477,7 +499,7 @@
*
* @exception IllegalArgumentException if fileSuffix is null
*/
- public static Iterator getImageReadersBySuffix(String fileSuffix)
+ public static Iterator<ImageReader> getImageReadersBySuffix(String fileSuffix)
{
if (fileSuffix == null)
throw new IllegalArgumentException("formatName may not be null");
@@ -497,7 +519,7 @@
*
* @exception IllegalArgumentException if formatName is null
*/
- public static Iterator getImageWritersByFormatName(String formatName)
+ public static Iterator<ImageWriter> getImageWritersByFormatName(String formatName)
{
if (formatName == null)
throw new IllegalArgumentException("formatName may not be null");
@@ -518,7 +540,7 @@
*
* @exception IllegalArgumentException if MIMEType is null
*/
- public static Iterator getImageWritersByMIMEType(String MIMEType)
+ public static Iterator<ImageWriter> getImageWritersByMIMEType(String MIMEType)
{
if (MIMEType == null)
throw new IllegalArgumentException("MIMEType may not be null");
@@ -538,7 +560,7 @@
*
* @exception IllegalArgumentException if fileSuffix is null
*/
- public static Iterator getImageWritersBySuffix(String fileSuffix)
+ public static Iterator<ImageWriter> getImageWritersBySuffix(String fileSuffix)
{
if (fileSuffix == null)
throw new IllegalArgumentException("fileSuffix may not be null");
@@ -1068,8 +1090,7 @@
if (writer == null)
throw new IllegalArgumentException ("null argument");
- ImageWriterSpi spi = (ImageWriterSpi) getRegistry()
- .getServiceProviderByClass(writer.getClass());
+ ImageWriterSpi spi = writer.getOriginatingProvider();
String[] readerSpiNames = spi.getImageReaderSpiNames();
@@ -1098,14 +1119,16 @@
*
* @return an iterator over a collection of image readers
*/
- public static Iterator getImageReaders (Object input)
+ public static Iterator<ImageReader> getImageReaders (Object input)
{
if (input == null)
throw new IllegalArgumentException ("null argument");
- return getRegistry().getServiceProviders (ImageReaderSpi.class,
+ Iterator<ImageReaderSpi> spiIterator
+ = getRegistry().getServiceProviders (ImageReaderSpi.class,
new ReaderObjectFilter(input),
true);
+ return new ImageReaderIterator(spiIterator);
}
/**
@@ -1118,16 +1141,18 @@
*
* @return an iterator over a collection of image writers
*/
- public static Iterator getImageWriters (ImageTypeSpecifier type,
+ public static Iterator<ImageWriter> getImageWriters (ImageTypeSpecifier type,
String formatName)
{
if (type == null || formatName == null)
throw new IllegalArgumentException ("null argument");
- return getRegistry().getServiceProviders (ImageWriterSpi.class,
+ final Iterator<ImageWriterSpi> spiIterator
+ = getRegistry().getServiceProviders (ImageWriterSpi.class,
new WriterObjectFilter(type,
formatName),
true);
+ return new ImageWriterIterator(spiIterator);
}
/**
@@ -1149,8 +1174,7 @@
if (reader == null)
throw new IllegalArgumentException ("null argument");
- ImageReaderSpi spi = (ImageReaderSpi) getRegistry()
- .getServiceProviderByClass(reader.getClass());
+ ImageReaderSpi spi = reader.getOriginatingProvider();
String[] writerSpiNames = spi.getImageWriterSpiNames();
@@ -1184,15 +1208,33 @@
* @exception IllegalArgumentException if either reader or writer is
* null
*/
- public static Iterator getImageTranscoders (ImageReader reader,
+ public static Iterator<ImageTranscoder> getImageTranscoders (ImageReader reader,
ImageWriter writer)
{
if (reader == null || writer == null)
throw new IllegalArgumentException ("null argument");
- return getRegistry().getServiceProviders (ImageTranscoderSpi.class,
+ final Iterator<ImageTranscoderSpi> spiIterator
+ = getRegistry().getServiceProviders (ImageTranscoderSpi.class,
new TranscoderFilter (reader,
writer),
true);
+ return new Iterator<ImageTranscoder>()
+ {
+ public boolean hasNext()
+ {
+ return spiIterator.hasNext();
+ }
+
+ public ImageTranscoder next()
+ {
+ return spiIterator.next().createTranscoderInstance();
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ };
}
}
Modified: trunk/core/src/classpath/javax/javax/imageio/ImageReader.java
===================================================================
--- trunk/core/src/classpath/javax/javax/imageio/ImageReader.java 2007-01-07 05:43:57 UTC (rev 2998)
+++ trunk/core/src/classpath/javax/javax/imageio/ImageReader.java 2007-01-07 08:19:52 UTC (rev 2999)
@@ -116,7 +116,7 @@
* A list of installed progress listeners. Initially null, meaning
* no installed listeners.
*/
- protected List progressListeners = null;
+ protected List<IIOReadProgressListener> progressListeners = null;
/**
* true if this reader should only read data further ahead in the
@@ -129,19 +129,19 @@
* A list of installed update listeners. Initially null, meaning no
* installed listeners.
*/
- protected List updateListeners = null;
+ protected List<IIOReadUpdateListener> updateListeners = null;
/**
* A list of installed warning listeners. Initially null, meaning
* no installed listeners.
*/
- protected List warningListeners = null;
+ protected List<IIOReadWarningListener> warningListeners = null;
/**
* A list of warning locales corresponding with the list of
* installed warning listeners. Initially null, meaning no locales.
*/
- protected List warningLocales = null;
+ protected List<Locale> warningLocales = null;
/**
* Construct an image reader.
@@ -371,7 +371,7 @@
* out-of-bounds
* @exception IOException if a read error occurs
*/
- public abstract Iterator getImageTypes(int imageIndex)
+ public abstract Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex)
throws IOException;
/**
@@ -1594,7 +1594,7 @@
* height is greater than Integer.MAX_VALUE
*/
protected static BufferedImage getDestination (ImageReadParam param,
- Iterator imageTypes,
+ Iterator<ImageTypeSpecifier> imageTypes,
int width,
int height)
throws IIOException
@@ -1694,7 +1694,7 @@
*/
public IIOMetadata getImageMetadata (int imageIndex,
String formatName,
- Set nodeNames)
+ Set<String> nodeNames)
throws IOException
{
if (formatName == null || nodeNames == null)
@@ -1808,7 +1808,7 @@
* @exception IOException if a read error occurs
*/
public IIOMetadata getStreamMetadata (String formatName,
- Set nodeNames)
+ Set<String> nodeNames)
throws IOException
{
if (formatName == null || nodeNames == null)
@@ -1915,7 +1915,7 @@
* destination image regions are empty
* @exception IOException if a read error occurs
*/
- public Iterator readAll (Iterator params)
+ public Iterator<IIOImage> readAll (Iterator<? extends ImageReadParam> params)
throws IOException
{
List l = new ArrayList ();
Modified: trunk/core/src/classpath/javax/javax/imageio/ImageWriteParam.java
===================================================================
--- trunk/core/src/classpath/javax/javax/imageio/ImageWriteParam.java 2007-01-07 05:43:57 UTC (rev 2998)
+++ trunk/core/src/classpath/javax/javax/imageio/ImageWriteParam.java 2007-01-07 08:19:52 UTC (rev 2999)
@@ -278,7 +278,7 @@
public String[] getCompressionQualityDescriptions()
{
checkNotExplicitCompression();
- checkCompressionTypesSet();;
+ checkCompressionTypesSet();
return null;
}
@@ -286,7 +286,7 @@
public float[] getCompressionQualityValues()
{
checkNotExplicitCompression();
- checkCompressionTypesSet();;
+ checkCompressionTypesSet();
return null;
}
Modified: trunk/core/src/classpath/javax/javax/imageio/ImageWriter.java
===================================================================
--- trunk/core/src/classpath/javax/javax/imageio/ImageWriter.java 2007-01-07 05:43:57 UTC (rev 2998)
+++ trunk/core/src/classpath/javax/javax/imageio/ImageWriter.java 2007-01-07 08:19:52 UTC (rev 2999)
@@ -40,6 +40,7 @@
import java.awt.Dimension;
import java.awt.Rectangle;
+import java.awt.image.BufferedImage;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.io.IOException;
@@ -102,19 +103,19 @@
* A list of installed progress listeners. Initially null, meaning
* no installed listeners.
*/
- protected List progressListeners = null;
+ protected List<IIOWriteProgressListener> progressListeners = null;
/**
* A list of installed warning listeners. Initially null, meaning
* no installed listeners.
*/
- protected List warningListeners = null;
+ protected List<IIOWriteWarningListener> warningListeners = null;
/**
* A list of warning locales corresponding with the list of
* installed warning listeners. Initially null, meaning no locales.
*/
- protected List warningLocales = null;
+ protected List<Locale> warningLocales = null;
/**
* Construct an image writer.
@@ -1076,7 +1077,7 @@
public void prepareInsertEmpty (int imageIndex, ImageTypeSpecifier imageType,
int width, int height,
IIOMetadata imageMetadata,
- List thumbnails,
+ List<? extends BufferedImage> thumbnails,
ImageWriteParam param)
throws IOException
{
@@ -1149,7 +1150,7 @@
ImageTypeSpecifier imageType,
int width, int height,
IIOMetadata imageMetadata,
- List thumbnails,
+ List<? extends BufferedImage> thumbnails,
ImageWriteParam param)
throws IOException
{
Modified: trunk/core/src/classpath/javax/javax/imageio/metadata/IIOMetadataFormat.java
===================================================================
--- trunk/core/src/classpath/javax/javax/imageio/metadata/IIOMetadataFormat.java 2007-01-07 05:43:57 UTC (rev 2998)
+++ trunk/core/src/classpath/javax/javax/imageio/metadata/IIOMetadataFormat.java 2007-01-07 08:19:52 UTC (rev 2999)
@@ -106,15 +106,15 @@
int getObjectArrayMinLength (String elementName);
- Class getObjectClass (String elementName);
+ Class<?> getObjectClass (String elementName);
Object getObjectDefaultValue (String elementName);
Object[] getObjectEnumerations (String elementName);
- Comparable getObjectMaxValue (String elementName);
+ Comparable<?> getObjectMaxValue (String elementName);
- Comparable getObjectMinValue (String elementName);
+ Comparable<?> getObjectMinValue (String elementName);
int getObjectValueType (String elementName);
Modified: trunk/core/src/classpath/javax/javax/imageio/metadata/IIOMetadataFormatImpl.java
===================================================================
--- trunk/core/src/classpath/javax/javax/imageio/metadata/IIOMetadataFormatImpl.java 2007-01-07 05:43:57 UTC (rev 2998)
+++ trunk/core/src/classpath/javax/javax/imageio/metadata/IIOMetadataFormatImpl.java 2007-01-07 08:19:52 UTC (rev 2999)
@@ -462,7 +462,7 @@
int dataType,
boolean required,
String defaultValue,
- List enumeratedValues)
+ List<String> enumeratedValues)
{
IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
node.setAttributeNode (new IIOMetadataNodeAttrEnumerated (node,
@@ -568,8 +568,8 @@
node.setUserObject (null);
}
- protected void addObjectValue (String elementName, Class classType,
- boolean required, Object defaultValue)
+ protected <T> void addObjectValue (String elementName, Class<T> classType,
+ boolean required, T defaultValue)
{
IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
addNodeObject (node, new NodeObject (node,
@@ -578,9 +578,9 @@
defaultValue));
}
- protected void addObjectValue (String elementName, Class classType,
- boolean required, Object defaultValue,
- List enumeratedValues)
+ protected <T> void addObjectValue (String elementName, Class<T> classType,
+ boolean required, T defaultValue,
+ List<? extends T> enumeratedValues)
{
IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
addNodeObject (node, new NodeObjectEnumerated (node,
@@ -590,10 +590,11 @@
enumeratedValues));
}
- protected void addObjectValue (String elementName, Class classType,
- Object defaultValue,
- Comparable minValue,
- Comparable maxValue,
+ protected <T extends Object & Comparable<? super T>>
+ void addObjectValue (String elementName, Class<T> classType,
+ T defaultValue,
+ Comparable<? super T> minValue,
+ Comparable<? super T> maxValue,
boolean minInclusive,
boolean maxInclusive)
{
@@ -607,7 +608,7 @@
maxInclusive));
}
- protected void addObjectValue (String elementName, Class classType,
+ protected void addObjectValue (String elementName, Class<?> classType,
int arrayMinLength, int arrayMaxLength)
{
IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
@@ -836,7 +837,7 @@
return ((Integer) ((NodeObjectArray) getNodeObject (node)).getArrayMinLength ()).intValue();
}
- public Class getObjectClass (String elementName)
+ public Class<?> getObjectClass (String elementName)
{
IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
return getNodeObject (node).getClassType ();
@@ -854,13 +855,13 @@
return ((NodeObjectEnumerated) getNodeObject (node)).getEnumerations ();
}
- public Comparable getObjectMaxValue (String elementName)
+ public Comparable<?> getObjectMaxValue (String elementName)
{
IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
return ((NodeObjectBounded) getNodeObject (node)).getMaxValue ();
}
- public Comparable getObjectMinValue (String elementName)
+ public Comparable<?> getObjectMinValue (String elementName)
{
IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
return ((NodeObjectBounded) getNodeObject (node)).getMinValue ();
Modified: trunk/core/src/classpath/javax/javax/imageio/spi/IIORegistry.java
===================================================================
--- trunk/core/src/classpath/javax/javax/imageio/spi/IIORegistry.java 2007-01-07 05:43:57 UTC (rev 2998)
+++ trunk/core/src/classpath/javax/javax/imageio/spi/IIORegistry.java 2007-01-07 08:19:52 UTC (rev 2999)
@@ -39,13 +39,13 @@
package javax.imageio.spi;
import gnu.classpath.ServiceFactory;
-import gnu.java.awt.ClasspathToolkit;
import java.awt.Toolkit;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import gnu.java.awt.ClasspathToolkit;
import gnu.javax.imageio.bmp.BMPImageReaderSpi;
import gnu.javax.imageio.bmp.BMPImageWriterSpi;
import gnu.javax.imageio.gif.GIFImageReaderSpi;
Modified: trunk/core/src/classpath/javax/javax/imageio/spi/IIOServiceProvider.java
===================================================================
--- trunk/core/src/classpath/javax/javax/imageio/spi/IIOServiceProvider.java 2007-01-07 05:43:57 UTC (rev 2998)
+++ trunk/core/src/classpath/javax/javax/imageio/spi/IIOServiceProvider.java 2007-01-07 08:19:52 UTC (rev 2999)
@@ -110,7 +110,7 @@
* @param category the service category for which this provider has
* been registered as an implementor.
*/
- public void onRegistration(ServiceRegistry registry, Class category)
+ public void onRegistration(ServiceRegistry registry, Class<?> category)
{
}
@@ -128,7 +128,7 @@
* @param category the service category for which this provider has
* been registered as an implementor.
*/
- public void onDeregistration(ServiceRegistry registry, Class category)
+ public void onDeregistration(ServiceRegistry registry, Class<?> category)
{
}
Modified: trunk/core/src/classpath/javax/javax/imageio/spi/ImageInputStreamSpi.java
===================================================================
--- trunk/core/src/classpath/javax/javax/imageio/spi/ImageInputStreamSpi.java 2007-01-07 05:43:57 UTC (rev 2998)
+++ trunk/core/src/classpath/javax/javax/imageio/spi/ImageInputStreamSpi.java 2007-01-07 08:19:52 UTC (rev 2999)
@@ -59,7 +59,7 @@
* Indicates which kind of input is processable by the streams
* created by {@link #createInputStreamInstance(Object)}.
*/
- protected Class inputClass;
+ protected Class<?> inputClass;
/**
@@ -80,7 +80,7 @@
* or <code>version</code> is <code>null</code>.
*/
public ImageInputStreamSpi(String vendorName, String version,
- Class inputClass)
+ Class<?> inputClass)
{
super(vendorName, version);
this.inputClass = inputClass;
@@ -91,7 +91,7 @@
* Determines which kind of input is processable by the streams
* created by {@link #createInputStreamInstance(Object)}.
*/
- public Class getInputClass()
+ public Class<?> getInputClass()
{
return inputClass;
}
Modified: trunk/core/src/classpath/javax/javax/imageio/spi/ImageOutputStreamSpi.java
===================================================================
--- trunk/core/src/classpath/javax/javax/imageio/spi/ImageOutputStreamSpi.java 2007-01-07 05:43:57 UTC (rev 2998)
+++ trunk/core/src/classpath/javax/javax/imageio/spi/ImageOutputStreamSpi.java 2007-01-07 08:19:52 UTC (rev 2999)
@@ -59,7 +59,7 @@
* Indicates which kind of output is produced by the streams
* created by {@link #createOutputStreamInstance(Object)}.
*/
- protected Class outputClass;
+ protected Class<?> outputClass;
/**
@@ -80,7 +80,7 @@
* or <code>version</code> is <code>null</code>.
*/
public ImageOutputStreamSpi(String vendorName, String version,
- Class outputClass)
+ Class<?> outputClass)
{
super(vendorName, version);
this.outputClass = outputClass;
@@ -91,7 +91,7 @@
* Determines which kind of output is produced by the streams
* created by {@link #createOutputStreamInstance(Object)}.
*/
- public Class getOutputClass()
+ public Class<?> getOutputClass()
{
return outputClass;
}
Modified: trunk/core/src/classpath/javax/javax/imageio/spi/RegisterableService.java
===================================================================
--- trunk/core/src/classpath/javax/javax/imageio/spi/RegisterableService.java 2007-01-07 05:43:57 UTC (rev 2998)
+++ trunk/core/src/classpath/javax/javax/imageio/spi/RegisterableService.java 2007-01-07 08:19:52 UTC (rev 2999)
@@ -62,7 +62,7 @@
* @param category the service category for which this provider has
* been registered as an implementor.
*/
- void onRegistration(ServiceRegistry registry, Class category);
+ void onRegistration(ServiceRegistry registry, Class<?> category);
/**
@@ -78,6 +78,6 @@
* @param category the service category for which this provider has
* been registered as an implementor.
*/
- void onDeregistration(ServiceRegistry registry, Class category);
+ void onDeregistration(ServiceRegistry registry, Class<?> category);
}
Modified: trunk/core/src/classpath/javax/javax/imageio/spi/ServiceRegistry.java
===================================================================
--- trunk/core/src/classpath/javax/javax/imageio/spi/ServiceRegistry.java 2007-01-07 05:43:57 UTC (rev 2998)
+++ trunk/core/src/classpath/javax/javax/imageio/spi/ServiceRegistry.java 2007-01-07 08:19:52 UTC (rev 2999)
@@ -121,7 +121,7 @@
* @throws ClassCastException if <code>categories</code> does not
* iterate over instances of {@link java.lang.Class}.
*/
- public ServiceRegistry(Iterator categories)
+ public ServiceRegistry(Iterator<Class<?>> categories)
{
ArrayList cats = new ArrayList(/* expected size */ 10);
@@ -178,7 +178,7 @@
* @throws IllegalArgumentException if <code>spi</code> is
* <code>null</code>.
*/
- public static Iterator lookupProviders(Class spi,
+ public static <T> Iterator<T> lookupProviders(Class<T> spi,
ClassLoader loader)
{
return ServiceFactory.lookupProviders(spi, loader);
@@ -200,7 +200,7 @@
*
* @see #lookupProviders(Class, ClassLoader)
*/
- public static Iterator lookupProviders(Class spi)
+ public static <T> Iterator<T> lookupProviders(Class<T> spi)
{
return ServiceFactory.lookupProviders(spi);
}
@@ -212,7 +212,7 @@
* @return an unmodifiable {@link
* java.util.Iterator}<{@link java.lang.Class}>.
*/
- public Iterator getCategories()
+ public Iterator<Class<?>> getCategories()
{
return new Iterator()
{
@@ -317,8 +317,8 @@
* @throws ClassCastException if <code>provider</code> does not
* implement <code>category</code>.
*/
- public synchronized boolean registerServiceProvider(Object provider,
- Class category)
+ public synchronized <T> boolean registerServiceProvider(T provider,
+ Class<T> category)
{
for (int i = 0; i < categories.length; i++)
if (categories[i] == category)
@@ -383,7 +383,7 @@
* #ServiceRegistry(Iterator) constructor} of this
* <code>ServiceRegistry</code>.
*/
- public synchronized void registerServiceProviders(Iterator providers)
+ public synchronized void registerServiceProviders(Iterator<?> providers)
{
if (providers == null)
throw new IllegalArgumentException();
@@ -467,8 +467,8 @@
* @throws ClassCastException if <code>provider</code> does not
* implement <code>category</code>.
*/
- public synchronized boolean deregisterServiceProvider(Object provider,
- Class category)
+ public synchronized <T> boolean deregisterServiceProvider(T provider,
+ Class<T> category)
{
for (int i = 0; i < categories.length; i++)
if (categories[i] == category)
@@ -535,7 +535,7 @@
* #ServiceRegistry(Iterator) constructor} of this
* <code>ServiceRegistry</code>.
*/
- public synchronized void deregisterAll(Class category)
+ public synchronized void deregisterAll(Class<?> category)
{
boolean ok = false;
@@ -663,7 +663,8 @@
*
* @see #getServiceProviders(Class, Filter, boolean)
*/
- public Iterator getServiceProviders(Class category, boolean useOrdering)
+ public <T> Iterator<T> getServiceProviders(Class<T> category,
+ boolean useOrdering)
{
return getServiceProviders(category, null, useOrdering);
}
@@ -691,7 +692,7 @@
* #ServiceRegistry(Iterator) constructor} of this
* <code>ServiceRegistry</code>.
*/
- public synchronized Iterator getServiceProviders(Class category,
+ public synchronized <T> Iterator<T> getServiceProviders(Class<T> category,
Filter filter,
boolean useOrdering)
{
@@ -751,7 +752,7 @@
*
* @param providerClass a class to search for.
*/
- public synchronized Object getServiceProviderByClass(Class providerClass)
+ public synchronized <T> T getServiceProviderByClass(Class<T> providerClass)
{
if (providerClass == null)
throw new IllegalArgumentException();
@@ -772,7 +773,7 @@
{
Object provider = iter.next();
if (providerClass.isInstance(provider))
- return provider;
+ return (T) provider;
}
}
@@ -799,9 +800,9 @@
* @see #unsetOrdering
* @see #getServiceProviders(Class, Filter, boolean)
*/
- public synchronized boolean setOrdering(Class category,
- Object firstProvider,
- Object secondProvider)
+ public synchronized <T> boolean setOrdering(Class<T> category,
+ T firstProvider,
+ T secondProvider)
{
return addConstraint(getCategoryID(category), firstProvider,
secondProvider);
@@ -826,9 +827,9 @@
*
* @see #setOrdering
*/
- public synchronized boolean unsetOrdering(Class category,
- Object firstProvider,
- Object secondProvider)
+ public synchronized <T> boolean unsetOrdering(Class<T> category,
+ T firstProvider,
+ T secondProvider)
{
return removeConstraint(getCategoryID(category),
firstProvider, secondProvider);
@@ -956,6 +957,6 @@
* criteria; <code>false</code> if it does not match.
*/
boolean filter(Object provider);
- };
+ }
}
Modified: trunk/core/src/classpath/javax/javax/imageio/stream/FileCacheImageOutputStream.java
===================================================================
--- trunk/core/src/classpath/javax/javax/imageio/stream/FileCacheImageOutputStream.java 2007-01-07 05:43:57 UTC (rev 2998)
+++ trunk/core/src/classpath/javax/javax/imageio/stream/FileCacheImageOutputStream.java 2007-01-07 08:19:52 UTC (rev 2999)
@@ -38,11 +38,10 @@
package javax.imageio.stream;
-import gnu.classpath.NotImplementedException;
-
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
+import java.io.RandomAccessFile;
/**
* @author Michael Koch (kon...@gm...)
@@ -50,34 +49,32 @@
public class FileCacheImageOutputStream extends ImageOutputStreamImpl
{
private OutputStream stream;
- private File cacheDir;
+ private File cacheFile;
+ private RandomAccessFile cache;
+ private long maxPos;
- public FileCacheImageOutputStream(OutputStream stream, File cacheDir)
+ public FileCacheImageOutputStream(OutputStream s, File cacheDir)
throws IOException
{
- super();
- this.stream = stream;
- // FIXME: We do not support caching yet.
- this.cacheDir = cacheDir;
+ stream = s;
+ cacheFile = File.createTempFile("imageio", ".tmp", cacheDir);
+ cache = new RandomAccessFile(cacheFile, "rw");
+ maxPos = 0;
}
public void close()
throws IOException
{
- if (stream != null)
- {
- stream.close();
+ maxPos = cache.length();
+ seek(maxPos);
+ flushBefore(maxPos);
+ super.close();
+ cache.close();
+ cacheFile.delete();
+ stream.flush();
stream = null;
}
- }
- private void checkStreamClosed()
- throws IOException
- {
- if (stream == null)
- throw new IOException("stream closed");
- }
-
public boolean isCached()
{
return true;
@@ -94,32 +91,88 @@
}
public int read()
- throws IOException, NotImplementedException
+ throws IOException
{
- // FIXME: Implement me.
- throw new Error("not implemented");
+ bitOffset = 0;
+ int val = cache.read();
+ if (val != -1)
+ streamPos++;
+ return val;
}
public int read(byte[] data, int offset, int len)
- throws IOException, NotImplementedException
+ throws IOException
{
- // FIXME: Implement me.
- throw new Error("not implemented");
+ bitOffset = 0;
+ int num = cache.read(data, offset, len);
+ if (num != -1)
+ streamPos += num;
+ return num;
}
public void write(byte[] data, int offset, int len)
throws IOException
{
- checkStreamClosed();
- // FIXME: Flush pending bits.
- stream.write(data, offset, len);
+ flushBits();
+ cache.write(data, offset, len);
+ streamPos += len;
+ maxPos = Math.max(streamPos, maxPos);
}
public void write(int value)
throws IOException
{
- checkStreamClosed();
- // FIXME: Flush pending bits.
- stream.write(value);
+ flushBits();
+ cache.write(value);
+ streamPos++;
+ maxPos = Math.max(streamPos, maxPos);
}
+
+ public long length()
+ {
+ long l;
+ try
+ {
+ l = cache.length();
+ }
+ catch (IOException ex)
+ {
+ l = -1;
+ }
+ return l;
+ }
+
+ public void seek(long pos)
+ throws IOException
+ {
+ checkClosed();
+ if (pos < flushedPos)
+ throw new IndexOutOfBoundsException();
+ cache.seek(pos);
+ streamPos = cache.getFilePointer();
+ maxPos = Math.max(streamPos, maxPos);
+ bitOffset = 0;
+ }
+
+ public void flushBefore(long pos)
+ throws IOException
+ {
+ long oldPos = flushedPos;
+ super.flushBefore(pos);
+ long flushed = flushedPos - oldPos;
+ if (flushed > 0)
+ {
+ int len = 512;
+ byte[] buf = new byte[len];
+ cache.seek(oldPos);
+ while (flushed > 0)
+ {
+ int l = (int) Math.min(flushed, len);
+ cache.readFully(buf, 0, l);
+ stream.write(buf, 0, l);
+ flushed -= l;
+ }
+ stream.flush();
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|