You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/10/09 07:33:21 UTC

svn commit: r454289 [4/22] - in /incubator/harmony/enhanced/classlib/trunk/modules/H-1609: ./ modules/ modules/applet/ modules/applet/src/ modules/applet/src/main/ modules/applet/src/main/java/ modules/applet/src/main/java/java/ modules/applet/src/main...

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,253 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.3 $
+ */
+package javax.imageio.spi;
+
+import java.util.*;
+
+/**
+ * TODO: add all the methods from the spec
+ */
+public class ServiceRegistry {
+
+    CategoriesMap categories = new CategoriesMap(this);
+
+    public ServiceRegistry(Iterator categoriesIterator) {
+        if (null == categoriesIterator) {
+            throw new IllegalArgumentException("categories iterator should not be NULL");
+        }
+        while(categoriesIterator.hasNext()) {
+            Class c =  (Class) categoriesIterator.next();
+            categories.addCategory(c);
+        }
+    }
+
+    public static Iterator lookupProviders(Class providerClass, ClassLoader loader) {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static Iterator lookupProviders(Class providerClass) {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public boolean registerServiceProvider(Object provider, Class category) {
+        return categories.addProvider(provider, category);
+    }
+
+    public void registerServiceProviders(Iterator providers) {
+        for (Iterator iterator = providers; iterator.hasNext();) {
+            categories.addProvider(iterator.next(), null);
+        }
+    }
+
+    public void registerServiceProvider(Object provider) {
+        categories.addProvider(provider, null);
+    }
+
+    public boolean deregisterServiceProvider(Object provider, Class category) {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public void deregisterServiceProvider(Object provider) {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public Iterator getServiceProviders(Class category, Filter filter, boolean useOrdering) {
+        return new FilteredIterator(filter, categories.getProviders(category, useOrdering));
+    }
+
+    public Iterator getServiceProviders(Class category, boolean useOrdering) {
+        return categories.getProviders(category, useOrdering);
+    }
+
+    public Object getServiceProviderByClass(Class providerClass) {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public boolean setOrdering(Class category, Object firstProvider, Object secondProvider) {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public boolean unsetOrdering(Class category, Object firstProvider, Object secondProvider) {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public void deregisterAll(Class category) {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public void deregisterAll() {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public void finalize() throws Throwable {
+        //-- TODO
+    }
+
+    public boolean contains(Object provider) {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public Iterator getCategories() {
+        return categories.list();
+    }
+
+    public static interface Filter {
+        boolean filter(Object provider);
+    }
+
+    private static class CategoriesMap {
+        //-- <category class> -> ProvidersMap (Map)
+        Map categories = new HashMap();
+
+        ServiceRegistry registry;
+
+        public CategoriesMap(ServiceRegistry registry) {
+            this.registry = registry;
+        }
+
+        //-- TODO: useOrdering
+        Iterator getProviders(Class category, boolean useOrdering) {
+            ProvidersMap providers = (ProvidersMap) categories.get(category);
+            if (null == providers) {
+                throw new IllegalArgumentException("Unknown category: " + category);
+            }
+            return providers.getProviders(useOrdering);
+        }
+
+        Iterator list() {
+            return categories.keySet().iterator();
+        }
+
+        void addCategory(Class category) {
+            categories.put(category, new ProvidersMap());
+        }
+
+        /**
+         * Adds a provider to the category. If <code>category</code> is
+         * <code>null</code> then the provider will be added to all categories
+         * which the provider is assignable from.
+         * @param provider provider to add
+         * @param category category to add provider to
+         * @return if there were such provider in some category
+         */
+        boolean addProvider(Object provider, Class category) {
+            if (provider == null) {
+                throw new IllegalArgumentException("provider should be != NULL");
+            }
+
+            boolean rt;
+            if (category == null) {
+                rt = findAndAdd(provider);
+            } else {
+                rt  = addToNamed(provider, category);
+            }
+
+            if (provider instanceof RegisterableService) {
+                ((RegisterableService) provider).onRegistration(registry, category);
+            }
+
+            return rt;
+        }
+
+        private boolean addToNamed(Object provider, Class category) {
+            Object obj = categories.get(category);
+
+            if (null == obj) {
+                throw new IllegalArgumentException("Unknown category: " + category);
+            }
+
+            return ((ProvidersMap) obj).addProvider(provider);
+        }
+
+        private boolean findAndAdd(Object provider) {
+            boolean rt = false;
+            for (Iterator iterator = categories.entrySet().iterator(); iterator.hasNext();) {
+                Map.Entry e = (Map.Entry) iterator.next();
+                if (((Class)e.getKey()).isAssignableFrom(provider.getClass())) {
+                    rt |= ((ProvidersMap) e.getValue()).addProvider(provider);
+                }
+            }
+            return rt;
+        }
+    }
+
+    private static class ProvidersMap {
+        //-- TODO: providers ordering support
+
+        Map providers = new HashMap();
+
+        boolean addProvider(Object provider) {
+            return providers.put(provider.getClass(), provider) != null;
+        }
+
+        Iterator getProviderClasses() {
+            return providers.keySet().iterator();
+        }
+
+        //-- TODO ordering
+        Iterator getProviders(boolean userOrdering) {
+            return providers.values().iterator();
+        }
+    }
+
+    private static class FilteredIterator implements Iterator {
+
+        private Filter filter;
+        private Iterator backend;
+        private Object nextObj;
+
+        public FilteredIterator(Filter filter, Iterator backend) {
+            this.filter = filter;
+            this.backend = backend;
+            findNext();
+        }
+
+        public Object next() {
+            if (nextObj == null) {
+                throw new NoSuchElementException();
+            }
+            Object tmp = nextObj;
+            findNext();
+            return tmp;
+        }
+
+        public boolean hasNext() {
+            return nextObj != null;
+        }
+
+        public void remove() {
+            throw new UnsupportedOperationException("???");
+        }
+
+        /**
+         * Sets nextObj to a next provider matching the criterion given by the filter
+         */
+        private void findNext() {
+            nextObj = null;
+            while (backend.hasNext()) {
+                Object o = backend.next();
+                if (filter.filter(o)) {
+                    nextObj = o;
+                    return;
+                }
+            }
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/FileImageOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/FileImageOutputStream.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/FileImageOutputStream.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/FileImageOutputStream.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,95 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.3 $
+ */
+package javax.imageio.stream;
+
+import java.io.*;
+
+public class FileImageOutputStream extends ImageOutputStreamImpl {
+
+    RandomAccessFile file;
+
+    public FileImageOutputStream(File f) throws FileNotFoundException, IOException {
+        this(f != null
+                ? new RandomAccessFile(f, "rw")
+                : null);
+    }
+
+    public FileImageOutputStream(RandomAccessFile raf) {
+        if (raf == null) {
+            throw new IllegalArgumentException("file should not be NULL");
+        }
+        file = raf;
+    }
+
+    public void write(int b) throws IOException {
+        checkClosed();
+        // according to the spec for ImageOutputStreamImpl#flushBits()
+        flushBits();
+        file.write(b);
+        streamPos++;
+    }
+
+    public void write(byte[] b, int off, int len) throws IOException {
+        checkClosed();
+        // according to the spec for ImageOutputStreamImpl#flushBits()
+        flushBits();
+        file.write(b, off, len);
+        streamPos += len;
+    }
+
+    public int read() throws IOException {
+        checkClosed();
+        int rt = file.read();
+        if (rt != -1) {
+            streamPos++;
+        }
+        return rt;
+    }
+
+    public int read(byte[] b, int off, int len) throws IOException {
+        checkClosed();
+        int rt = file.read(b, off, len);
+        if (rt != -1) {
+            streamPos += rt;
+        }
+        return rt;
+    }
+
+    public long length() {
+        try {
+            checkClosed();
+            return file.length();
+        } catch(IOException e) {
+            return super.length(); // -1L
+        }
+    }
+
+    public void seek(long pos) throws IOException {
+        //-- checkClosed() is performed in super.seek()
+        super.seek(pos);
+        file.seek(pos);
+        streamPos = file.getFilePointer();
+    }
+
+    public void close() throws IOException {
+        super.close();
+        file.close();
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/FileImageOutputStream.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/IIOByteBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/IIOByteBuffer.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/IIOByteBuffer.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/IIOByteBuffer.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,62 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Sergey I. Salishev
+ * @version $Revision: 1.2 $
+ */
+package javax.imageio.stream;
+
+/**
+ * @author Sergey I. Salishev
+ * @version $Revision: 1.2 $
+ */
+public class IIOByteBuffer {
+    
+    private byte[] data;
+    private int offset;
+    private int length;
+
+    public IIOByteBuffer(byte[] data, int offset, int length) {
+        this.data = data;
+        this.offset = offset;
+        this.length = length;
+    }
+
+    public byte[] getData() {
+        return data;
+    }
+
+    public int getLength() {
+        return length;
+    }
+
+    public int getOffset() {
+        return offset;
+    }
+
+    public void setData(byte[] data) {
+        this.data = data;
+    }
+
+    public void setLength(int length) {
+        this.length = length;
+    }
+
+    public void setOffset(int offset) {
+        this.offset = offset;
+    }
+}
+

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/IIOByteBuffer.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageInputStream.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageInputStream.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageInputStream.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,117 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.2 $
+ */
+package javax.imageio.stream;
+
+import java.io.DataInput;
+import java.io.IOException;
+import java.nio.ByteOrder;
+
+public interface ImageInputStream extends DataInput {
+
+    void setByteOrder(ByteOrder byteOrder);
+
+    ByteOrder getByteOrder();
+
+    int read() throws IOException;
+
+    int read(byte[] b) throws IOException;
+
+    int read(byte[] b, int off, int len) throws IOException;
+
+    void readBytes(IIOByteBuffer buf, int len) throws IOException;
+
+    boolean readBoolean() throws IOException;
+
+    byte readByte() throws IOException;
+
+    int readUnsignedByte() throws IOException;
+
+    short readShort() throws IOException;
+
+    int readUnsignedShort() throws IOException;
+
+    char readChar() throws IOException;
+
+    int readInt() throws IOException;
+
+    long readUnsignedInt() throws IOException;
+
+    long readLong() throws IOException;
+
+    float readFloat() throws IOException;
+
+    double readDouble() throws IOException;
+
+    String readLine() throws IOException;
+
+    String readUTF() throws IOException;
+
+    void readFully(byte[] b, int off, int len) throws IOException;
+
+    void readFully(byte[] b) throws IOException;
+
+    void readFully(short[] s, int off, int len) throws IOException;
+
+    void readFully(char[] c, int off, int len) throws IOException;
+
+    void readFully(int[] i, int off, int len) throws IOException;
+
+    void readFully(long[] l, int off, int len) throws IOException;
+
+    void readFully(float[] f, int off, int len) throws IOException;
+
+    void readFully(double[] d, int off, int len) throws IOException;
+
+    long getStreamPosition() throws IOException;
+
+    int getBitOffset() throws IOException;
+
+    void setBitOffset(int bitOffset) throws IOException;
+
+    int readBit() throws IOException;
+
+    long readBits(int numBits) throws IOException;
+
+    long length() throws IOException;
+
+    int skipBytes(int n) throws IOException;
+
+    long skipBytes(long n) throws IOException;
+
+    void seek(long pos) throws IOException;
+
+    void mark();
+
+    void reset() throws IOException;
+
+    void flushBefore(long pos) throws IOException;
+
+    void flush() throws IOException;
+
+    long getFlushedPosition();
+
+    boolean isCached();
+
+    boolean isCachedMemory();
+
+    boolean isCachedFile();
+
+    void close() throws IOException;
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageInputStream.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageInputStreamImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageInputStreamImpl.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageInputStreamImpl.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageInputStreamImpl.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,338 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.3 $
+ */
+package javax.imageio.stream;
+
+import java.nio.ByteOrder;
+import java.io.IOException;
+import java.io.EOFException;
+import java.util.Stack;
+
+public abstract class ImageInputStreamImpl implements ImageInputStream {
+
+    protected ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
+
+    protected long streamPos = 0;
+    protected long flushedPos = 0;
+    protected int bitOffset = 0;
+
+    private boolean closed = false;
+
+    private PositionStack posStack = new PositionStack();
+
+    public ImageInputStreamImpl() {}
+
+    protected final void checkClosed() throws IOException {
+        if (closed) {
+            throw new IOException("stream is closed");
+        }
+    }
+
+    public void setByteOrder(ByteOrder byteOrder) {
+        this.byteOrder = byteOrder;
+    }
+
+    public ByteOrder getByteOrder() {
+        return byteOrder;
+    }
+
+    public abstract int read() throws IOException;
+
+    public int read(byte[] b) throws IOException {
+        return read(b, 0, b.length);
+    }
+
+    public abstract int read(byte[] b, int off, int len) throws IOException;
+
+    public void readBytes(IIOByteBuffer buf, int len) throws IOException {
+        if (buf == null) {
+            throw new NullPointerException("buffer is NULL");
+        }
+
+        byte[] b = new byte[len];
+        len = read(b, 0, b.length);
+
+        buf.setData(b);
+        buf.setOffset(0);
+        buf.setLength(len);
+    }
+
+    public boolean readBoolean() throws IOException {
+        int b = read();
+        if (b < 0) {
+            throw new EOFException("EOF reached");
+        }
+        return b != 0;
+    }
+
+    public byte readByte() throws IOException {
+        int b = read();
+        if (b < 0) {
+            throw new EOFException("EOF reached");
+        }
+        return (byte) b;
+    }
+
+    public int readUnsignedByte() throws IOException {
+        int b = read();
+        if (b < 0) {
+            throw new EOFException("EOF reached");
+        }
+        return b;
+    }
+
+    public short readShort() throws IOException {
+        int b1 = read();
+        int b2 = read();
+
+        if (b1 < 0 || b2 < 0) {
+            throw new EOFException("EOF reached");
+        }
+
+        return byteOrder == ByteOrder.BIG_ENDIAN ?
+                (short) ((b1 << 8) | (b2 & 0xff)) :
+                (short) ((b2 << 8) | (b1 & 0xff));
+    }
+
+    public int readUnsignedShort() throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public char readChar() throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public int readInt() throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public long readUnsignedInt() throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public long readLong() throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public float readFloat() throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public double readDouble() throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public String readLine() throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public String readUTF() throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void readFully(byte[] b, int off, int len) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void readFully(byte[] b) throws IOException {
+        readFully(b, 0, b.length);
+    }
+
+    public void readFully(short[] s, int off, int len) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void readFully(char[] c, int off, int len) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void readFully(int[] i, int off, int len) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void readFully(long[] l, int off, int len) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void readFully(float[] f, int off, int len) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void readFully(double[] d, int off, int len) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public long getStreamPosition() throws IOException {
+        checkClosed();
+        return streamPos;
+    }
+
+    public int getBitOffset() throws IOException {
+        checkClosed();
+        return bitOffset;
+    }
+
+    public void setBitOffset(int bitOffset) throws IOException {
+        checkClosed();
+        this.bitOffset = bitOffset;
+    }
+
+    public int readBit() throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public long readBits(int numBits) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public long length() {
+        return -1L;
+    }
+
+    public int skipBytes(int n) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public long skipBytes(long n) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void seek(long pos) throws IOException {
+        checkClosed();
+        if (pos < getFlushedPosition()) {
+            throw new IllegalArgumentException("trying to seek before flushed pos");
+        }
+        bitOffset = 0;
+        streamPos = pos;
+    }
+
+    public void mark() {
+        try {
+            posStack.push(getStreamPosition());
+        } catch (IOException e) {
+            e.printStackTrace();
+            throw new RuntimeException("Stream marking error");
+        }
+    }
+
+    public void reset() throws IOException {
+        //-- TODO bit pos
+        if (!posStack.isEmpty()) {
+            long p = posStack.pop();
+            if (p < flushedPos) {
+                throw new IOException("marked position lies in the flushed portion of the stream");
+            }
+            seek(p);
+        }
+    }
+
+    public void flushBefore(long pos) throws IOException {
+        if (pos > getStreamPosition()) {
+            throw new IndexOutOfBoundsException("Trying to flush outside of current position");
+        }
+        if (pos < flushedPos) {
+            throw new IndexOutOfBoundsException("Trying to flush within already flushed portion");
+        }
+        flushedPos = pos;
+        //-- TODO implement
+    }
+
+    public void flush() throws IOException {
+        flushBefore(getStreamPosition());
+    }
+
+    public long getFlushedPosition() {
+        return flushedPos;
+    }
+
+    public boolean isCached() {
+        return false; //def
+    }
+
+    public boolean isCachedMemory() {
+        return false; //def
+    }
+
+    public boolean isCachedFile() {
+        return false; //def
+    }
+
+    public void close() throws IOException {
+        checkClosed();
+        closed = true;
+
+    }
+
+    protected void finalize() throws Throwable {
+        if (!closed) try {
+            close();
+        } finally {
+            super.finalize();
+        }
+    }
+
+    private static class PositionStack {
+        private static final int SIZE = 10;
+
+        private long[] values = new long[SIZE];
+        private int pos = 0;
+
+
+        void push(long v) {
+            if (pos >= values.length) {
+                ensure(pos+1);
+            }
+            values[pos++] = v;
+        }
+
+        long pop() {
+            return values[--pos];
+        }
+
+        boolean isEmpty() {
+            return pos == 0;
+        }
+
+        private void ensure(int size) {
+            long[] arr = new long[Math.max(2 * values.length, size)];
+            System.arraycopy(values, 0, arr, 0, values.length);
+            values = arr;
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageInputStreamImpl.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageOutputStream.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageOutputStream.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageOutputStream.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,83 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.2 $
+ */
+package javax.imageio.stream;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+public interface ImageOutputStream extends DataOutput, ImageInputStream {
+
+    /**
+     * DataOutput methods redeclaration
+     */
+    void write(int b) throws IOException;
+
+    void write(byte[] b) throws IOException;
+
+    void write(byte[] b, int off, int len) throws IOException;
+
+    void writeBoolean(boolean b) throws IOException;
+
+    void writeByte(int b) throws IOException;
+
+    void writeShort(int v) throws IOException;
+
+    void writeChar(int v) throws IOException;
+
+    void writeInt(int v) throws IOException;
+
+    void writeLong(long v) throws IOException;
+
+    void writeFloat(float v) throws IOException;
+
+    void writeDouble(double v) throws IOException;
+
+    void writeBytes(String s) throws IOException;
+
+    void writeChars(String s) throws IOException;
+
+    void writeUTF(String s) throws IOException;
+
+    /**
+     * ImageInputStream method
+     */
+    void flushBefore(long pos) throws IOException;
+
+
+    /**
+     * ImageOutputStream specific methods
+     */
+    void writeShorts(short[] s, int off, int len) throws IOException;
+
+    void writeChars(char[] c, int off, int len) throws IOException;
+
+    void writeInts(int[] i, int off, int len) throws IOException;
+
+    void writeLongs(long[] l, int off, int len) throws IOException;
+
+    void writeFloats(float[] f, int off, int len) throws IOException;
+
+    void writeDoubles(double[] d, int off, int len) throws IOException;
+
+    void writeBit(int bit) throws IOException;
+
+    void writeBits(long bits, int numBits) throws IOException;
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageOutputStream.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageOutputStreamImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageOutputStreamImpl.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageOutputStreamImpl.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageOutputStreamImpl.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,154 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.3 $
+ */
+package javax.imageio.stream;
+
+import java.io.IOException;
+import java.nio.ByteOrder;
+
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.3 $
+ */
+public abstract class ImageOutputStreamImpl extends ImageInputStreamImpl
+        implements ImageOutputStream {
+
+    public ImageOutputStreamImpl() {}
+
+    public abstract void write(int b) throws IOException;
+
+    public void write(byte[] b) throws IOException {
+        write(b, 0, b.length);
+    }
+
+    public abstract void write(byte[] b, int off, int len) throws IOException;
+
+    public void writeBoolean(boolean v) throws IOException {
+        write(v ? 1 : 0);
+    }
+
+    public void writeByte(int v) throws IOException {
+        write(v);
+    }
+
+    public void writeShort(int v) throws IOException {
+        if (byteOrder == ByteOrder.BIG_ENDIAN) {
+
+        } else {
+
+        }
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void writeChar(int v) throws IOException {
+        writeShort(v);
+    }
+
+    public void writeInt(int v) throws IOException {
+        if (byteOrder == ByteOrder.BIG_ENDIAN) {
+
+        } else {
+
+        }
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void writeLong(long v) throws IOException {
+        if (byteOrder == ByteOrder.BIG_ENDIAN) {
+
+        } else {
+
+        }
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void writeFloat(float v) throws IOException {
+        writeInt(Float.floatToIntBits(v));
+    }
+
+    public void writeDouble(double v) throws IOException {
+        writeLong(Double.doubleToLongBits(v));
+    }
+
+    public void writeBytes(String s) throws IOException {
+        write(s.getBytes());
+    }
+
+    public void writeChars(String s) throws IOException {
+        char[] chs = s.toCharArray();
+        writeChars(chs, 0, chs.length);
+    }
+
+    public void writeUTF(String s) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void writeShorts(short[] s, int off, int len) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void writeChars(char[] c, int off, int len) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void writeInts(int[] i, int off, int len) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void writeLongs(long[] l, int off, int len) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void writeFloats(float[] f, int off, int len) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void writeDoubles(double[] d, int off, int len) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void writeBit(int bit) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    public void writeBits(long bits, int numBits) throws IOException {
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    protected final void flushBits() throws IOException {
+        if (bitOffset == 0) {
+            return;
+        }
+        
+        //-- TODO implement
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/stream/ImageOutputStreamImpl.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/IISDecodingImageSource.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/IISDecodingImageSource.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/IISDecodingImageSource.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/IISDecodingImageSource.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,91 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem Rafikov
+ * @version $Revision: 1.2 $
+ */
+package org.apache.harmony.x.imageio.plugins.jpeg;
+
+import javax.imageio.stream.ImageInputStream;
+
+import org.apache.harmony.awt.gl.image.DecodingImageSource;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * This allows usage of the java2d jpegdecoder with ImageInputStream in
+ * the JPEGImageReader. Temporary, only to make JPEGImageReader#read(..)
+ * working.
+ *
+ */
+public class IISDecodingImageSource extends DecodingImageSource {
+
+    private InputStream is;
+
+    public IISDecodingImageSource(ImageInputStream iis) {
+        is = new IISToInputStreamWrapper(iis);
+    }
+
+    protected boolean checkConnection() {
+        return true;
+    }
+
+    protected InputStream getInputStream() {
+        return is;
+    }
+
+    static class IISToInputStreamWrapper extends InputStream {
+
+        private ImageInputStream input;
+
+        public IISToInputStreamWrapper(ImageInputStream input) {
+            this.input=input;
+        }
+
+        public int read() throws IOException {
+            return input.read();
+        }
+
+        public int read(byte[] b) throws IOException {
+            return input.read(b);
+        }
+
+        public int read(byte[] b, int off, int len) throws IOException {
+            return input.read(b, off, len);
+        }
+
+        public long skip(long n) throws IOException {
+            return input.skipBytes(n);
+        }
+
+        public boolean markSupported() {
+            return true;
+        }
+
+        public void mark(int readlimit) {
+            input.mark();
+        }
+
+        public void reset() throws IOException {
+            input.reset();
+        }
+
+        public void close() throws IOException {
+            input.close();
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/IISDecodingImageSource.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGConsts.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGConsts.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGConsts.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGConsts.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,41 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.2 $
+ */
+package org.apache.harmony.x.imageio.plugins.jpeg;
+
+public class JPEGConsts {
+
+    private JPEGConsts() {}
+
+    public static final int SOI = 0xD8;
+
+    //-- IJG (Independed JPEG Group) color spaces
+    public static final int JCS_UNKNOW = 0;
+    public static final int JCS_GRAYSCALE = 1;
+    public static final int JCS_RGB = 2;
+    public static final int JCS_YCbCr = 3;
+    public static final int JCS_CMYK = 4;
+    public static final int JCS_YCC = 5;
+    public static final int JCS_RGBA = 6;
+    public static final int JCS_YCbCrA = 7;
+    public static final int JCS_YCCA = 10;
+    public static final int JCS_YCCK = 11;
+
+    public static int[][] BAND_OFFSETS = {{}, {0}, {0, 1}, {0, 1, 2}, {0, 1, 2, 3}};
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGConsts.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReader.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReader.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReader.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReader.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,103 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.4 $
+ */
+package org.apache.harmony.x.imageio.plugins.jpeg;
+
+
+import javax.imageio.ImageReader;
+import javax.imageio.ImageReadParam;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.spi.ImageReaderSpi;
+
+import org.apache.harmony.awt.gl.image.DecodingImageSource;
+import org.apache.harmony.awt.gl.image.OffscreenImage;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.awt.image.BufferedImage;
+
+/**
+ * This implementation uses org.apache.harmony.awt.gl.image.JpegDecoder to read
+ * an image. The only implemented method is read(..);
+ *
+ * TODO: Implements generic decoder to be used by javad2 and imageio
+ *
+ * @see org.apache.harmony.awt.gl.image.JpegDecoder
+ * @see org.apache.harmony.x.imageio.plugins.jpeg.IISDecodingImageSource
+ */
+public class JPEGImageReader extends ImageReader {
+
+    ImageInputStream iis;
+
+    public JPEGImageReader(ImageReaderSpi imageReaderSpi) {
+        super(imageReaderSpi);
+    }
+
+    public int getHeight(int i) throws IOException {
+        //-- TODO imlement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+
+    public int getWidth(int i) throws IOException {
+        //-- TODO imlement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+
+    public int getNumImages(boolean b) throws IOException {
+        //-- TODO imlement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+
+    public Iterator getImageTypes(int i) throws IOException {
+        //-- TODO imlement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+
+    public IIOMetadata getStreamMetadata() throws IOException {
+        //-- TODO imlement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+
+    public IIOMetadata getImageMetadata(int i) throws IOException {
+        //-- TODO imlement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+
+    public BufferedImage read(int i, ImageReadParam imageReadParam) throws IOException {
+        if (iis == null) {
+            throw new IllegalArgumentException("input stream == null");
+        }
+
+        DecodingImageSource source = new IISDecodingImageSource(iis);
+        OffscreenImage image = new OffscreenImage(source);
+        source.addConsumer(image);
+        source.load();
+        return image.getBufferedImage();
+    }
+
+    public BufferedImage read(int i) throws IOException {
+        return read(i, null);
+    }
+
+    public void setInput(Object input, boolean seekForwardOnly, boolean ignoreMetadata) {
+        super.setInput(input, seekForwardOnly, ignoreMetadata);
+        iis = (ImageInputStream) input;
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReader.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReaderSpi.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReaderSpi.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReaderSpi.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReaderSpi.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,88 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.3 $
+ */
+package org.apache.harmony.x.imageio.plugins.jpeg;
+
+
+import javax.imageio.spi.ImageReaderSpi;
+import javax.imageio.spi.ServiceRegistry;
+import javax.imageio.ImageReader;
+import javax.imageio.stream.ImageInputStream;
+
+import org.apache.harmony.awt.gl.image.DecodingImageSource;
+import org.apache.harmony.awt.gl.image.JpegDecoder;
+import org.apache.harmony.awt.gl.image.OffscreenImage;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Locale;
+
+public class JPEGImageReaderSpi extends ImageReaderSpi {
+
+    public JPEGImageReaderSpi() {
+        super(JPEGSpiConsts.vendorName, JPEGSpiConsts.version,
+                JPEGSpiConsts.names, JPEGSpiConsts.suffixes,
+                JPEGSpiConsts.MIMETypes, JPEGSpiConsts.readerClassName,
+                STANDARD_INPUT_TYPE, JPEGSpiConsts.writerSpiNames,
+                JPEGSpiConsts.supportsStandardStreamMetadataFormat,
+                JPEGSpiConsts.nativeStreamMetadataFormatName,
+                JPEGSpiConsts.nativeStreamMetadataFormatClassName,
+                JPEGSpiConsts.extraStreamMetadataFormatNames,
+                JPEGSpiConsts.extraStreamMetadataFormatClassNames,
+                JPEGSpiConsts.supportsStandardImageMetadataFormat,
+                JPEGSpiConsts.nativeImageMetadataFormatName,
+                JPEGSpiConsts.nativeImageMetadataFormatClassName,
+                JPEGSpiConsts.extraImageMetadataFormatNames,
+                JPEGSpiConsts.extraImageMetadataFormatClassNames);
+    }
+
+
+    public boolean canDecodeInput(Object source) throws IOException {
+        ImageInputStream markable = (ImageInputStream) source;
+        try {
+            markable.mark();
+
+            byte[] signature = new byte[3];
+            markable.seek(0);
+            markable.read(signature, 0, 3);
+            markable.reset();
+
+            if ((signature[0] & 0xFF) == 0xFF &&
+                    (signature[1] & 0xFF) == JPEGConsts.SOI &&
+                    (signature[2] & 0xFF) == 0xFF) { // JPEG
+                return true;
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+
+    public ImageReader createReaderInstance(Object extension) throws IOException {
+        return new JPEGImageReader(this);
+    }
+
+    public String getDescription(Locale locale) {
+        return "DRL JPEG decoder";
+    }
+
+    public void onRegistration(ServiceRegistry registry, Class category) {
+        // super.onRegistration(registry, category);
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReaderSpi.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageWriter.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageWriter.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageWriter.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageWriter.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,324 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.3 $
+ */
+package org.apache.harmony.x.imageio.plugins.jpeg;
+
+import javax.imageio.ImageWriter;
+import javax.imageio.IIOImage;
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.stream.ImageOutputStream;
+import javax.imageio.spi.ImageWriterSpi;
+import javax.imageio.metadata.IIOMetadata;
+import java.io.IOException;
+import java.awt.image.*;
+import java.awt.*;
+import java.awt.color.ColorSpace;
+
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.3 $
+ */
+public class JPEGImageWriter extends ImageWriter {
+
+    private long cinfo;
+    private Raster sourceRaster;
+    private WritableRaster scanRaster;
+    private int srcXOff = 0;
+    private int srcYOff = 0;
+    private int srcWidth;
+    private int srcHeight;
+
+    //-- y step for image subsampling
+    private int deltaY = 1;
+    //-- x step for image subsampling
+    private int deltaX = 1;
+
+    private ImageOutputStream ios;
+
+    public JPEGImageWriter(ImageWriterSpi imageWriterSpi) {
+        super(imageWriterSpi);
+        cinfo = initCompressionObj();
+    }
+
+    static {
+        System.loadLibrary("jpegencoder");
+        initWriterIds(ImageOutputStream.class);
+    }
+
+    public void write(IIOMetadata iioMetadata, IIOImage iioImage, ImageWriteParam param)
+            throws IOException {
+
+        if (ios == null) {
+            throw new IllegalArgumentException("ios == null");
+        }
+
+        RenderedImage img = null;
+        if (!iioImage.hasRaster()) {
+            img = iioImage.getRenderedImage();
+            if (img instanceof BufferedImage) {
+                sourceRaster = ((BufferedImage) img).getRaster();
+            } else {
+                sourceRaster = img.getData();
+            }
+        } else {
+            sourceRaster = iioImage.getRaster();
+        }
+
+        int numBands = sourceRaster.getNumBands();
+        int sourceIJGCs = img == null ? JPEGConsts.JCS_UNKNOW : getSourceCSType(img);
+
+        srcWidth = sourceRaster.getWidth();
+        srcHeight = sourceRaster.getHeight();
+
+        int destWidth = srcWidth;
+        int destHeight = srcHeight;
+
+        boolean progressive = false;
+
+        if (param != null) {
+            Rectangle reg = param.getSourceRegion();
+            if (reg != null) {
+                srcXOff = reg.x;
+                srcYOff = reg.y;
+
+                srcWidth = reg.width + srcXOff > srcWidth
+                        ? srcWidth - srcXOff
+                        : reg.width;
+                srcHeight = reg.height + srcYOff > srcHeight
+                        ? srcHeight - srcYOff
+                        : reg.height;
+            }
+
+            //-- TODO uncomment when JPEGImageWriteParam be implemented
+            //-- Only default progressive mode yet
+            // progressive = param.getProgressiveMode() ==  ImageWriteParam.MODE_DEFAULT;
+
+            //-- def is 1
+            deltaX = param.getSourceXSubsampling();
+            deltaY = param.getSourceYSubsampling();
+
+            //-- def is 0
+            int offsetX = param.getSubsamplingXOffset();
+            int offsetY = param.getSubsamplingYOffset();
+
+            srcXOff += offsetX;
+            srcYOff += offsetY;
+            srcWidth -= offsetX;
+            srcHeight -= offsetY;
+
+            destWidth = (srcWidth + deltaX - 1) / deltaX;
+            destHeight = (srcHeight + deltaY - 1) / deltaY;
+        }
+
+        //-- default DQTs (see JPEGQTable java doc and JPEG spec K1 & K2 tables)
+        //-- at http://www.w3.org/Graphics/JPEG/itu-t81.pdf
+        //-- Only figuring out how to set DQT in IJG library for future metadata
+        //-- support. IJG def tables are the same.
+        //JPEGQTable[] dqt = new JPEGQTable[2];
+//        int[][] dqt = null;
+//        int[][] dqt = new int[2][];
+//        dqt[0] = JPEGQTable.K1Div2Luminance.getTable();
+//        dqt[1] = JPEGQTable.K2Div2Chrominance.getTable();
+
+
+        //-- using default color space
+        //-- TODO: Take destination cs from param or use default if there is no cs
+        int destIJGCs = img == null ? JPEGConsts.JCS_UNKNOW : getDestinationCSType(img);
+
+        DataBufferByte dbuffer = new DataBufferByte(numBands * srcWidth);
+
+        scanRaster = Raster.createInterleavedRaster(dbuffer, srcWidth, 1,
+                numBands * srcWidth, numBands, JPEGConsts.BAND_OFFSETS[numBands], null);
+
+        encode(dbuffer.getData(), srcWidth, destWidth, destHeight, deltaX,
+                sourceIJGCs, destIJGCs, numBands, progressive,
+                null, cinfo);
+    }
+
+    public void dispose() {
+        super.dispose();
+        if (cinfo != 0) {
+            dispose(cinfo);
+            cinfo = 0;
+            ios = null;
+        }
+    }
+
+
+    public IIOMetadata getDefaultStreamMetadata(ImageWriteParam imageWriteParam) {
+        throw new UnsupportedOperationException("not supported yet");
+    }
+
+    public IIOMetadata getDefaultImageMetadata(ImageTypeSpecifier imageTypeSpecifier, ImageWriteParam imageWriteParam) {
+        throw new UnsupportedOperationException("not supported yet");
+    }
+
+    public IIOMetadata convertStreamMetadata(IIOMetadata iioMetadata, ImageWriteParam imageWriteParam) {
+        throw new UnsupportedOperationException("not supported yet");
+    }
+
+    public IIOMetadata convertImageMetadata(IIOMetadata iioMetadata, ImageTypeSpecifier imageTypeSpecifier, ImageWriteParam imageWriteParam) {
+        throw new UnsupportedOperationException("not supported yet");
+    }
+
+    public void setOutput(Object output) {
+        super.setOutput(output);
+        ios = (ImageOutputStream) output;
+        setIOS(ios, cinfo);
+        sourceRaster = null;
+        scanRaster = null;
+        srcXOff = 0;
+        srcYOff = 0;
+        srcWidth = 0;
+        srcHeight = 0;
+        deltaY = 1;
+    }
+
+    /**
+     * Frees resources
+     * @param structPointer
+     */
+    private native void dispose(long structPointer);
+
+    /**
+     * Inits methods Ids for native to java callbacks
+     * @param iosClass
+     */
+    private native static void initWriterIds(Class iosClass);
+
+    /**
+     * Inits compression objects
+     * @return pointer to the native structure
+     */
+    private native long initCompressionObj();
+
+    /**
+     * Sets image output stream in IJG layer
+     * @param stream
+     */
+    private native void setIOS(ImageOutputStream stream, long structPointer);
+
+    /**
+     * Runs encoding process.
+     *
+     * @param data image data buffer to encode
+     * @param srcWidth - source width
+     * @param width - destination width
+     * @param height destination height
+     * @param deltaX - x subsampling step
+     * @param inColorSpace - original color space
+     * @param outColorSpace - destination color space
+     * @param numBands - number of bands
+     * @param cinfo - native handler
+     * @return
+     */
+    private native boolean encode(byte[] data, int srcWidth,
+                                  int width, int height, int deltaX,
+                                  int inColorSpace, int outColorSpace,
+                                  int numBands, boolean progressive,
+                                  int[][] dqt,
+                                  long cinfo);
+
+    /**
+     * Callback for getting a next scanline
+     * @param scanline scan line number
+     */
+    private void getScanLine(int scanline) {
+        //-- TODO: processImageProgress in ImageWriter
+        Raster child = sourceRaster.createChild(srcXOff,
+                srcYOff + scanline * deltaY, srcWidth, 1, 0, 0, null);
+
+        scanRaster.setRect(child);
+    }
+
+    /**
+     * Maps color space types to IJG color spaces
+     * @param image
+     * @return
+     */
+    private int getSourceCSType(RenderedImage image) {
+        int type = JPEGConsts.JCS_UNKNOW;
+        ColorModel cm = image.getColorModel();
+
+        if (null == cm) {
+            return type;
+        }
+
+        if (cm instanceof IndexColorModel) {
+            throw new UnsupportedOperationException("IndexColorModel is not supported yet");
+        }
+
+        boolean hasAlpha = cm.hasAlpha();
+        ColorSpace cs = cm.getColorSpace();
+        switch(cs.getType()) {
+            case ColorSpace.TYPE_GRAY:
+                type = JPEGConsts.JCS_GRAYSCALE;
+                break;
+           case ColorSpace.TYPE_RGB:
+                type = hasAlpha ? JPEGConsts.JCS_RGBA : JPEGConsts.JCS_RGB;
+                break;
+           case ColorSpace.TYPE_YCbCr:
+                type = hasAlpha ? JPEGConsts.JCS_YCbCrA : JPEGConsts.JCS_YCbCr;
+                break;
+           case ColorSpace.TYPE_3CLR:
+                 type = hasAlpha ? JPEGConsts.JCS_YCCA : JPEGConsts.JCS_YCC;
+                 break;
+           case ColorSpace.TYPE_CMYK:
+                  type = JPEGConsts.JCS_CMYK;
+                  break;
+        }
+        return type;
+    }
+
+    /**
+     * Returns destination color space.
+     * (YCbCr[A] for RGB)
+     *
+     * @param image
+     * @return
+     */
+    private int getDestinationCSType(RenderedImage image) {
+        int type = JPEGConsts.JCS_UNKNOW;
+        ColorModel cm = image.getColorModel();
+        if (null != cm) {
+            boolean hasAlpha = cm.hasAlpha();
+            ColorSpace cs = cm.getColorSpace();
+
+            switch(cs.getType()) {
+                case ColorSpace.TYPE_GRAY:
+                    type = JPEGConsts.JCS_GRAYSCALE;
+                    break;
+               case ColorSpace.TYPE_RGB:
+                    type = hasAlpha ? JPEGConsts.JCS_YCbCrA : JPEGConsts.JCS_YCbCr;
+                    break;
+               case ColorSpace.TYPE_YCbCr:
+                    type = hasAlpha ? JPEGConsts.JCS_YCbCrA : JPEGConsts.JCS_YCbCr;
+                    break;
+               case ColorSpace.TYPE_3CLR:
+                     type = hasAlpha ? JPEGConsts.JCS_YCCA : JPEGConsts.JCS_YCC;
+                     break;
+               case ColorSpace.TYPE_CMYK:
+                      type = JPEGConsts.JCS_CMYK;
+                      break;
+            }
+        }
+        return type;
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageWriter.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageWriterSpi.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageWriterSpi.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageWriterSpi.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageWriterSpi.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,52 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.3 $
+ */
+package org.apache.harmony.x.imageio.plugins.jpeg;
+
+import javax.imageio.spi.ImageWriterSpi;
+import javax.imageio.ImageWriter;
+import javax.imageio.ImageTypeSpecifier;
+import java.io.IOException;
+import java.util.Locale;
+
+public class JPEGImageWriterSpi extends ImageWriterSpi {
+
+    public JPEGImageWriterSpi() {
+        super(JPEGSpiConsts.vendorName, JPEGSpiConsts.version,
+                JPEGSpiConsts.names, JPEGSpiConsts.suffixes, JPEGSpiConsts.MIMETypes,
+                JPEGSpiConsts.writerClassName, STANDARD_OUTPUT_TYPE,
+                JPEGSpiConsts.readerSpiNames, JPEGSpiConsts.supportsStandardStreamMetadataFormat /*TODO: support st. metadata format*/,
+                JPEGSpiConsts.nativeStreamMetadataFormatName, JPEGSpiConsts.nativeStreamMetadataFormatClassName,
+                JPEGSpiConsts.extraStreamMetadataFormatNames, JPEGSpiConsts.extraStreamMetadataFormatClassNames,
+                JPEGSpiConsts.supportsStandardImageMetadataFormat, JPEGSpiConsts.nativeImageMetadataFormatName, JPEGSpiConsts.nativeImageMetadataFormatClassName,
+                JPEGSpiConsts.extraImageMetadataFormatNames, JPEGSpiConsts.extraImageMetadataFormatClassNames);
+    }
+
+    public boolean canEncodeImage(ImageTypeSpecifier imageTypeSpecifier) {
+        return true;
+    }
+
+    public ImageWriter createWriterInstance(Object o) throws IOException {
+        return new JPEGImageWriter(this);
+    }
+
+    public String getDescription(Locale locale) {
+        return "DRL JPEG Encoder";
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageWriterSpi.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGSpiConsts.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGSpiConsts.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGSpiConsts.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGSpiConsts.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,56 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.2 $
+ */
+package org.apache.harmony.x.imageio.plugins.jpeg;
+
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.2 $
+ */
+public class JPEGSpiConsts {
+    private JPEGSpiConsts() {}
+
+    static final String vendorName = "Intel Corporation";
+    static final String version = "0.1 beta";
+
+    static final String readerClassName = "org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageReader";
+    static final String writerClassName = "org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageWriter";
+
+    static final String[] names = {"jpeg", "jpg", "JPEG", "JPG"};
+    static final String[] suffixes = {"jpeg", "jpg"};
+    static final String[] MIMETypes = {"image/jpeg"};
+
+    static final String[] writerSpiNames = {"org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageWriterSpi"};
+    static final String[] readerSpiNames = {"org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageReaderSpi"};
+
+    //-- TODO fill this stuff with correct data
+    static final boolean supportsStandardStreamMetadataFormat = false;
+    static final String nativeStreamMetadataFormatName = null;
+    static final String nativeStreamMetadataFormatClassName = null;
+    static final String[] extraStreamMetadataFormatNames = null;
+    static final String[] extraStreamMetadataFormatClassNames = null;
+    static final boolean supportsStandardImageMetadataFormat = false;
+    static final String nativeImageMetadataFormatName =
+            "org.apache.harmony.x.imageio.plugins.jpeg.MyFormatMetadata_1.0";
+    static final String nativeImageMetadataFormatClassName =
+            "org.apache.harmony.x.imageio.plugins.jpeg.MyFormatMetadata";
+    static final String[] extraImageMetadataFormatNames = null;
+    static final String[] extraImageMetadataFormatClassNames = null;
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/plugins/jpeg/JPEGSpiConsts.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/FileIISSpi.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/FileIISSpi.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/FileIISSpi.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/FileIISSpi.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,49 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.2 $
+ */
+package org.apache.harmony.x.imageio.spi;
+
+import javax.imageio.spi.ImageInputStreamSpi;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.FileImageOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.Locale;
+
+public class FileIISSpi extends ImageInputStreamSpi {
+
+    private static final String vendor = "Apache";
+    private static final String ver = "0.1";
+    private static final Class clazz = File.class;
+
+    public FileIISSpi() {
+        super(vendor, ver, clazz);
+    }
+
+    public ImageInputStream createInputStreamInstance(Object input, boolean useCache, File cacheDir) throws IOException {
+        if (clazz.isInstance(input)) {
+            return new FileImageOutputStream((File) input);
+        }
+        throw new IllegalArgumentException("input is not an instance of " + clazz);
+    }
+
+    public String getDescription(Locale locale) {
+        return "File IIS Spi";
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/FileIISSpi.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/FileIOSSpi.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/FileIOSSpi.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/FileIOSSpi.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/FileIOSSpi.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,52 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.2 $
+ */
+package org.apache.harmony.x.imageio.spi;
+
+import javax.imageio.spi.ImageOutputStreamSpi;
+import javax.imageio.stream.ImageOutputStream;
+import javax.imageio.stream.FileImageOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.Locale;
+
+public class FileIOSSpi extends ImageOutputStreamSpi {
+
+    private static final String vendor = "Apache";
+    private static final String ver = "0.1";
+    private static final Class clazz = File.class;
+
+
+    public FileIOSSpi() {
+        super(vendor, ver, clazz);
+    }
+
+    public ImageOutputStream createOutputStreamInstance(Object output,
+                                                        boolean useCache,
+                                                        File cacheDir) throws IOException {
+        if (output instanceof File) {
+            return new FileImageOutputStream((File)output);
+        }
+        throw new IllegalArgumentException("output is not instance of File");
+    }
+
+    public String getDescription(Locale locale) {
+        return "File IOS Spi";
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/FileIOSSpi.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/RAFIISSpi.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/RAFIISSpi.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/RAFIISSpi.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/RAFIISSpi.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,51 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.2 $
+ */
+package org.apache.harmony.x.imageio.spi;
+
+import javax.imageio.spi.ImageInputStreamSpi;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.FileImageOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.Locale;
+
+public class RAFIISSpi extends ImageInputStreamSpi {
+
+    private static final String vendor = "Apache";
+    private static final String ver = "0.1";
+    private static final Class clazz = RandomAccessFile.class;
+
+    public RAFIISSpi() {
+        super(vendor, ver, clazz);
+    }
+
+    public ImageInputStream createInputStreamInstance(Object input, boolean useCache, File cacheDir) throws IOException {
+        if (clazz.isInstance(input)) {
+            return new FileImageOutputStream((RandomAccessFile) input);
+        }
+        throw new IllegalArgumentException("input is not an instance of " + clazz);
+    }
+
+    public String getDescription(Locale locale) {
+        return "RandomAccessFile IIS Spi";
+    }
+}
+

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/RAFIISSpi.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/RAFIOSSpi.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/RAFIOSSpi.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/RAFIOSSpi.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/RAFIOSSpi.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,53 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Rustem V. Rafikov
+ * @version $Revision: 1.2 $
+ */
+package org.apache.harmony.x.imageio.spi;
+
+import javax.imageio.spi.ImageOutputStreamSpi;
+import javax.imageio.stream.ImageOutputStream;
+import javax.imageio.stream.FileImageOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.Locale;
+
+public class RAFIOSSpi extends ImageOutputStreamSpi {
+
+    private static final String vendor = "Apache";
+    private static final String ver = "0.1";
+    private static final Class clazz = RandomAccessFile.class;
+
+
+    public RAFIOSSpi() {
+        super(vendor, ver, clazz);
+    }
+
+    public ImageOutputStream createOutputStreamInstance(Object output,
+                                                        boolean useCache,
+                                                        File cacheDir) throws IOException {
+        if (output instanceof RandomAccessFile) {
+            return new FileImageOutputStream((RandomAccessFile)output);
+        }
+        throw new IllegalArgumentException("output is not instance of File");
+    }
+
+    public String getDescription(Locale locale) {
+        return "RandomAccessFile IOS Spi";
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/org/apache/harmony/x/imageio/spi/RAFIOSSpi.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/Exceptions.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/Exceptions.c?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/Exceptions.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/Exceptions.c Sun Oct  8 22:33:09 2006
@@ -0,0 +1,40 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Oleg V. Khaschansky
+ * @version $Revision: 1.2 $
+ * 
+ */
+
+#include "Exceptions.h"
+
+/*
+ * Creates and throws arbitrary exception
+ */
+void newExceptionByName(JNIEnv *env, const char* name, const char* msg) {
+    // Create exception
+    jclass cls = (*env)->FindClass(env, name);
+    /* if cls is NULL, an exception has already been thrown */
+    if (cls != NULL) {
+        (*env)->ThrowNew(env, cls, msg);
+    }
+
+    (*env)->DeleteLocalRef(env, cls);
+}
+
+void newNullPointerException(JNIEnv *env, const char* msg) {
+    newExceptionByName(env, "java/lang/NullPointerException", msg);
+}
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/Exceptions.c
------------------------------------------------------------------------------
    svn:executable = *