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 [2/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/applet/src/main/java/org/apache/harmony/applet/Connection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Connection.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Connection.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Connection.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,320 @@
+/*
+ *  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 Pavel Dolgov
+ * @version $Revision: 1.2 $
+ */
+package org.apache.harmony.applet;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.Socket;
+import java.net.URL;
+import java.util.HashMap;
+
+import org.apache.harmony.awt.ContextStorage;
+
+
+/**
+ * Connection between host application and applet infrastructure
+ */
+public class Connection implements Callback {
+    
+    private final Socket socket;
+    
+    final LineReader reader;
+//    final BufferedReader reader;
+    final PrintWriter writer;
+    
+    final Factory factory;
+
+    public static void main(String[] args) {
+        ContextStorage.activateMultiContextMode();
+        
+        int port = 0;
+        
+        try {
+            port = Integer.parseInt(args[0]);
+        } catch (Exception e) {
+            throw new IllegalArgumentException("Invalid port");
+        }
+        
+        Connection c = new Connection(port);
+        c.listen();
+    }
+    
+    Connection(int port) {
+        try {
+            socket = new Socket("localhost", port);
+            
+            reader = new LineReader(socket.getInputStream());
+//            reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
+            writer = new PrintWriter(socket.getOutputStream());
+
+            factory = new Factory(this);
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
+    void listen() {
+
+        try {
+            for (String cmd = reader.readLine(); cmd != null; cmd = reader.readLine()) {
+
+                if (cmd.equals("exit")) {
+                    exit();
+                    return;
+                }
+                if (cmd.equals("dump")) {
+                    dump();
+                    continue;
+                }
+                String args[] = cmd.split(" ");
+
+                if (args[0].equals("create")) {
+                    create(args);
+                    continue;
+                }
+                if (args[0].equals("unload")) {
+                    unload(args);
+                    continue;
+                }
+                if (args[0].equals("start")) {
+                    start(args);
+                    continue;
+                }
+                if (args[0].equals("stop")) {
+                    stop(args);
+                    continue;
+                }
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
+    private void dump() {
+        try {
+            System.err.println("  -----------THREADS--------------");
+            Thread cur = Thread.currentThread();
+            dump(cur.getThreadGroup(), "");
+            System.err.println("  -----------CONTEXT--------------");
+            factory.dump();
+            System.err.println("  -----------END DUMP--------------");
+        } catch (Exception e) {
+            System.err.println(e);
+        }
+    }
+    
+    private void dump(ThreadGroup group, String prefix) {
+        try {
+            System.err.println(prefix + group);
+        } catch (Exception e) {
+            System.err.println(e);
+        }
+        
+        try {
+            Thread threads[] = new Thread[group.activeCount()];
+            for (int cnt = group.enumerate(threads), i = 0; i<cnt; i++) {
+                if (threads[i].getThreadGroup() == group) {
+                    System.err.println(prefix + "| " + threads[i]);
+                }
+            }
+        } catch (Exception e) {
+            System.err.println(e);
+        }
+
+        try {
+            ThreadGroup groups[] = new ThreadGroup[group.activeGroupCount()];
+            for (int cnt = group.enumerate(groups), i=0; i<cnt; i++) {
+                dump(groups[i], prefix + "> ");
+            }
+        } catch (Exception e) {
+            System.err.println(e);
+        }
+    }
+    
+    private void start(String args[]) {
+        
+        factory.start(Integer.parseInt(args[1]));
+    }
+
+    private void stop(String args[]) {
+        
+        factory.stop(Integer.parseInt(args[1]));
+    }
+
+    private void unload(String args[]) {
+        
+        factory.dispose(Integer.parseInt(args[1]));
+    }
+    
+    /**
+     * command synopsys:<br>
+     * CREATE id parentWindowId className docBase docId codeBase<br>
+     *   NAME name_in_document<br>
+     *   PARAM name value<br>
+     * END<br>
+     * @param args - CREATE command split into tokens
+     */
+    private void create(String args[]) {
+        
+        int id;
+        long parentWindowId;
+        String className;
+        URL documentBase;
+        int docId;
+        URL codeBase;
+        String name = null;
+        HashMap parameters = new HashMap();
+        
+        try {
+            id = Integer.parseInt(args[1]);
+            parentWindowId = Long.parseLong(args[2]);
+            className = args[3];
+            documentBase = new URL(args[4]);
+            docId = Integer.parseInt(args[5]);
+            codeBase = new URL(args[6]);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+
+        try {
+            for (String line = reader.readLine(); line != null; line = reader.readLine()) {
+                if (line.equals("exit")) {
+                    exit();
+                }
+                if (line.equals("end")) {
+                    break;
+                }
+                String parts[] = line.split(" ");
+                if (parts[0].equals("param")) {
+                    parameters.put(parts[1], parts[2]);
+                } else if (parts[0].equals("name")) {
+                    name = parts[1];
+                }
+            }
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        
+        Parameters params = 
+                new Parameters(id,
+                               parentWindowId,
+                               documentBase,
+                               docId,
+                               codeBase,
+                               className,
+                               parameters,
+                               name,
+                               null); 
+
+        factory.createAndRun(params);
+    }
+    
+    void exit() {
+        try {
+            sendCommand("exit");
+            writer.close();
+            socket.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        System.exit(0);
+    }
+    
+    private void sendCommand(String cmd) {
+        writer.println(cmd);
+        writer.flush();
+    }
+
+    public void showDocument(int documentId, URL url, String target) {
+        sendCommand("show " + documentId + " " + url + " " + target);
+    }
+
+    public void showStatus(int documentId, String status) {
+        sendCommand("status " + documentId + " " + status);
+    }
+
+    public void appletResize(int appletId, int width, int height) {
+        sendCommand("resize " + appletId + " " + width + " " + height);
+    }    
+    
+    static class LineReader {
+        
+        private final StringBuffer buffer = new StringBuffer();
+        private final InputStream in;
+        private boolean eof = false;
+        
+        LineReader(InputStream is) {
+            in = is;
+        }
+
+        public String readLine() throws IOException {
+            if (eof) {
+                return null;
+            }
+            
+            int pos = buffer.indexOf("\n");
+            if (pos >= 0) {
+                return getLine(pos);
+            }
+
+            final int BUF_SIZE = 1024;
+            byte[] buf = new byte[BUF_SIZE];
+
+            int count = 0;
+            while( (count = in.read(buf, 0, BUF_SIZE)) > 0 ) {
+                buffer.append(new String(buf, 0, count));
+                pos = buffer.indexOf("\n");
+                if (pos >= 0) {
+                    return getLine(pos);
+                }
+            }
+            
+            eof = true;
+            return getRemainder();
+        }
+        
+        public void close() throws IOException {
+            in.close();
+        }
+
+        private String getLine(int endPos) {
+            if (endPos > 0) {
+                String result = buffer.substring(0, endPos);
+                buffer.delete(0, endPos + 1);
+                return result;
+            }
+            if (endPos == 0) {
+                buffer.delete(0, 1);
+            }
+            return new String();
+        }
+        
+        private String getRemainder() {
+            String result = buffer.toString();
+            buffer.delete(0, buffer.length());
+            return (result.length() > 0) ? result : null;
+        }
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Connection.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Document.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Document.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Document.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Document.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 Pavel Dolgov
+ * @version $Revision: 1.2 $
+ */  
+package org.apache.harmony.applet;
+
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Representation of browser's (or other host app's) document that contains applets
+ */
+
+final class Document {
+
+    final URL docBase;
+    final int id;
+    private final Set slices = Collections.synchronizedSet(new HashSet());
+    final Factory factory;
+
+    Document(Factory factory, URL url, int id) {
+        docBase = url;
+        this.id = id;
+        this.factory = factory;
+    }
+    
+    void add(DocumentSlice ds) {
+        slices.add(ds);
+    }
+    
+    void remove(DocumentSlice ds) {
+        synchronized(slices) {
+            slices.remove(ds);
+            if (slices.isEmpty()) {
+                factory.remove(this);
+            }
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Document.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/DocumentSlice.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/DocumentSlice.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/DocumentSlice.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/DocumentSlice.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,176 @@
+/*
+ *  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 Pavel Dolgov
+ * @version $Revision: 1.2 $
+ */
+package org.apache.harmony.applet;
+
+import java.applet.Applet;
+import java.applet.AppletContext;
+import java.applet.AudioClip;
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * Collection of applets running in one document and loaded from the same code base,
+ * implementation of <b>AppletContext</b> interface
+ */
+final class DocumentSlice implements AppletContext {
+
+    final CodeBase codeBase;
+    final Document document;
+    
+    private final ArrayList proxies = new ArrayList();
+    private final HashMap streams = new HashMap();
+    
+    
+    DocumentSlice(Document doc, CodeBase codeBase) {
+        this.document = doc;
+        this.codeBase = codeBase;
+    }
+    
+    void add(Proxy p) {
+        synchronized (proxies) {
+            proxies.add(p);
+        }
+        codeBase.factory.add(p);
+    }
+    
+    void remove(Proxy p) {
+        codeBase.factory.remove(p);
+
+        boolean empty = false;
+        synchronized (proxies) {
+            proxies.remove(p);
+            empty = (proxies.size() == 0);
+        }
+        if (empty) {
+            codeBase.remove(this);
+            document.remove(this);
+        }
+    }
+    /*
+     * @see java.applet.AppletContext#getApplet(java.lang.String)
+     */
+    public Applet getApplet(String name) {
+        
+        synchronized (proxies) {
+            for (Iterator it = proxies.iterator(); it.hasNext();) {
+                Proxy p = (Proxy)it.next();
+                if (p.params.name.equals(name)) {
+                    return p.getApplet();
+                }
+            }
+            return null;
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.applet.AppletContext#getApplets()
+     */
+    public Enumeration getApplets() {
+        
+        synchronized (proxies) {
+            ArrayList applets = new ArrayList();
+            for (Iterator it = proxies.iterator(); it.hasNext();) {
+                Proxy p = (Proxy)it.next();
+                Applet a = p.getApplet();
+                if (a != null) {
+                    applets.add(a);
+                }
+            }
+            return Collections.enumeration(applets);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.applet.AppletContext#getAudioClip(java.net.URL)
+     */
+    public AudioClip getAudioClip(URL url) {
+        return new AudioClipImpl(url);
+    }
+
+    /* (non-Javadoc)
+     * @see java.applet.AppletContext#getImage(java.net.URL)
+     */
+    public Image getImage(URL url) {
+        return Toolkit.getDefaultToolkit().getImage(url);
+    }
+
+    /* (non-Javadoc)
+     * @see java.applet.AppletContext#getStream(java.lang.String)
+     */
+    public InputStream getStream(String key) {
+
+        synchronized (streams) {
+            return (InputStream)streams.get(key);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.applet.AppletContext#getStreamKeys()
+     */
+    public Iterator getStreamKeys() {
+
+        synchronized (streams) {
+            ArrayList keys = new ArrayList();
+            for(Iterator i = streams.keySet().iterator(); i.hasNext(); ) {
+                keys.add(i.next());
+            }
+            return keys.iterator();
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.applet.AppletContext#setStream(java.lang.String, java.io.InputStream)
+     */
+    public void setStream(String key, InputStream stream) throws IOException {
+
+        synchronized (streams) {
+            streams.put(key, stream);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.applet.AppletContext#showDocument(java.net.URL, java.lang.String)
+     */
+    public void showDocument(URL url, String target) {
+        codeBase.factory.showDocument(this, url, target);
+    }
+
+    /* (non-Javadoc)
+     * @see java.applet.AppletContext#showDocument(java.net.URL)
+     */
+    public void showDocument(URL url) {
+        this.showDocument(url, null);
+    }
+
+    /* (non-Javadoc)
+     * @see java.applet.AppletContext#showStatus(java.lang.String)
+     */
+    public void showStatus(String status) {
+        codeBase.factory.showStatus(this, status);
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/DocumentSlice.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Factory.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Factory.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Factory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Factory.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,158 @@
+/*
+ *  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 Pavel Dolgov
+ * @version $Revision: 1.2 $
+ */
+package org.apache.harmony.applet;
+
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Applet context factory
+ */
+final class Factory {
+    
+    private final Callback callback;
+    private final Map codeBases = Collections.synchronizedMap(new HashMap());
+    private final Map allProxies = Collections.synchronizedMap(new HashMap());
+    private final Map documents = Collections.synchronizedMap(new HashMap());
+    
+    Factory(Callback callback) {
+        this.callback = callback;
+    }
+    
+    CodeBase getCodeBase(URL url) {
+        synchronized(codeBases) {
+            CodeBase cb = (CodeBase)codeBases.get(url);
+            if (cb == null) {
+                cb = new CodeBase(url, this);
+                codeBases.put(url, cb);
+            }
+            return cb;
+        }
+    }
+    
+    void remove(CodeBase codeBase) {
+        codeBases.remove(codeBase.codeBase);
+    }
+
+    void remove(Document doc) {
+        documents.remove(new Integer(doc.id));
+    }
+
+    void dispose(int id) {
+        Proxy p = (Proxy)allProxies.get(new Integer(id));
+        if (p == null) {
+            return;
+        }
+        p.docSlice.remove(p);
+        p.dispose();
+        
+    }
+    
+    Document getDocument(URL docBase, int docId) {
+        synchronized(documents) {
+            Document doc;
+            Integer objDocId = new Integer(docId);
+            doc = (Document)documents.get(objDocId);
+            if (doc == null) {
+                doc = new Document(this, docBase, docId);
+                documents.put(objDocId, doc);
+            }
+            return doc;
+        }
+    }
+    
+    void createAndRun(Parameters params) {
+        
+        CodeBase codeBase = getCodeBase(params.codeBase);
+        Document doc = getDocument(params.documentBase, params.documentId);
+        DocumentSlice ds = codeBase.getDocumentSlice(doc);
+        doc.add(ds);
+        
+        Proxy p = new Proxy(ds, params);
+        p.create();
+    }
+    
+    void start(int id) {
+        Proxy p = (Proxy)allProxies.get(new Integer(id));
+        if (p != null) {
+            p.start();
+        }
+    }
+    
+    void stop(int id) {
+        Proxy p = (Proxy)allProxies.get(new Integer(id));
+        if (p != null) {
+            p.stop();
+        }
+    }
+    
+    void init(int id) {
+        Proxy p = (Proxy)allProxies.get(new Integer(id));
+        if (p != null) {
+            p.init();
+        }
+    }
+    
+    void destroy(int id) {
+        Proxy p = (Proxy)allProxies.get(new Integer(id));
+        if (p != null) {
+            p.destroy();
+        }
+    }
+    
+    void appletResize(Proxy p, int width, int height) {
+        callback.appletResize(p.params.id, width, height);
+    }
+    
+    void showStatus(DocumentSlice ds, String status) {
+        callback.showStatus(ds.document.id, status);
+    }
+    
+    void showDocument(DocumentSlice ds, URL url, String target) {
+        callback.showDocument(ds.document.id, url, target);
+    }
+
+    void add(Proxy p) {
+        allProxies.put(new Integer(p.params.id), p);
+    }
+    
+    void remove(Proxy p) {
+        allProxies.remove(new Integer(p.params.id));
+    }
+    
+    void dump() {
+        for (Iterator it = allProxies.values().iterator(); it.hasNext(); ) {
+            Proxy p = (Proxy)it.next();
+            System.err.println("app " + p.params.id + " " + 
+                    " cb " + p.docSlice.codeBase.hashCode() + " " +
+                    " doc " + p.params.documentId + " " +
+                    p.params.codeBase + p.params.className + " " + 
+                    (p.isActive() ? "active" : "stopped"));
+        }
+        for (Iterator it = codeBases.values().iterator(); it.hasNext(); ) {
+            CodeBase cb = (CodeBase)it.next();
+            System.err.println("cb " + cb.hashCode() + " " + cb.threadGroup);
+        }
+    }
+}
+

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Factory.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Launcher.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Launcher.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Launcher.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Launcher.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,311 @@
+/*
+ *  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 Pavel Dolgov
+ * @version $Revision: 1.3 $
+ */
+package org.apache.harmony.applet;
+
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+
+/**
+ * Standalone applet launcher
+ */
+public final class Launcher implements Callback {
+    
+    private final Factory factory;
+    
+    private final Frame frame;
+    private final Panel placeholder;
+    private final Label status;
+    
+    private final int appletId = 1;
+    private final int documentId = 2;
+    
+    private URL codeBase;
+    private String className;
+    
+    private Launcher() {
+        frame = createFrame();
+        placeholder = (Panel)frame.getComponent(1);
+        status = (Label)((Container)frame.getComponent(2)).getComponent(0);
+
+        factory = new Factory(this);
+    }
+
+    public static void main(String[] args) {
+
+        if (args.length < 2) {
+            System.err.println("Two parameters required: <code_base_url> <class_name>");
+            return;
+        }
+        
+        Launcher launcher = new Launcher();
+        try {
+            launcher.show(new URL(args[0]), args[1]);
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void showDocument(int documentId, URL url, String target) {
+        System.err.println("showDocument " + url + " " + target);
+    }
+
+    public void showStatus(int documentId, String status) {
+        this.status.setText(status);
+    }
+
+    public void appletResize(int appletId, int width, int height) {
+        if (appletId != this.appletId) {
+            return;
+        }
+        
+        int dw = width - placeholder.getWidth();
+        int dh = height - placeholder.getHeight();
+        
+        frame.setSize(frame.getWidth() + dw, frame.getHeight() + dh);
+        frame.invalidate();
+        frame.validate();
+    }
+    
+    private Frame createFrame() {
+        Frame f = new Frame("Applet viewer");
+        f.setSize(500, 400);
+        f.setLayout(new ThreeTierLayout());
+        f.setBackground(SystemColor.control);
+        
+        Panel panel = new Panel();
+        f.add(panel, "north");
+        
+        Button button = new Button(" Start ");
+        button.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                factory.start(appletId);
+            }});
+        panel.add(button);
+        
+        button = new Button(" Stop ");
+        button.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                factory.stop(appletId);
+            }});
+        panel.add(button);
+        
+        button = new Button(" Restart ");
+        button.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                factory.stop(appletId);
+                factory.destroy(appletId);
+                factory.init(appletId);
+                factory.start(appletId);
+            }});
+        panel.add(button);
+        
+        button = new Button(" Reload ");
+        button.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                Launcher.this.hide();
+                Launcher.this.show();
+            }});
+        panel.add(button);
+        
+        button = new Button(" Exit ");
+        button.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                Launcher.this.hide();
+                frame.dispose();
+            }});
+        panel.add(button);
+        
+        Panel place = new Panel();
+        place.setName("placeholder");
+        place.setLayout(new BorderLayout());
+        place.setVisible(false);
+        f.add(place, "center");
+        
+        Label status = new Label("status");
+        status.setName("status");
+        
+        Container statusBar = new SunkenBar(3, 3);
+        statusBar.add(status);
+        f.add(statusBar, "south");
+        
+        
+        f.addWindowListener(new WindowAdapter() {
+            public void windowClosing(WindowEvent e) {
+                Launcher.this.hide();
+                e.getWindow().dispose();
+            }
+        });
+
+        return f;
+    }
+    
+    
+    void show(URL codeBase, String className) {
+        this.codeBase = codeBase;
+        this.className = className;
+        show();
+    }
+    
+    private void show() {
+        
+        URL documentBase = null;
+        
+        try {
+            documentBase = new URL(codeBase.toString() + className + ".html");
+        } catch (MalformedURLException e) {
+            throw new RuntimeException(e);
+        }
+        
+        Parameters params = 
+            new Parameters(appletId,
+                           0,
+                           documentBase,
+                           documentId,
+                           codeBase,
+                           className,
+                           new HashMap(),
+                           className,
+                           placeholder); 
+        
+        frame.setVisible(true);
+        factory.createAndRun(params);
+    }
+    
+    void hide() {
+        factory.stop(appletId);
+        factory.destroy(appletId);
+        factory.dispose(appletId);
+    }
+    
+    private static class SunkenBar extends Container {
+        
+        private static final long serialVersionUID = -8850392912011177434L;
+
+        private final int offset;
+        private final int margin;
+
+        SunkenBar(int offset, int margin) {
+            this.offset = offset;
+            this.margin = margin;
+        }
+        
+        public void paint(Graphics g) {
+
+            super.paint(g);
+
+            int w = getWidth(), h = getHeight();
+            
+            g.setColor(SystemColor.controlShadow);
+            g.drawLine(offset, offset, w - offset, offset);
+            g.drawLine(offset, offset, offset, h - offset);
+
+            g.setColor(SystemColor.controlHighlight);
+            g.drawLine(offset, h - offset, w - offset, h - offset);
+            g.drawLine(w - offset, offset, w - offset, h - offset);
+        }
+
+        public void layout() {
+            Component child = getComponent(0);
+
+            child.setBounds(offset + margin, offset+1, getWidth() - 2*(offset + margin), getHeight() - 2*offset-1);
+        }
+        
+        public Dimension getPreferredSize() {
+            Component child = getComponent(0);
+            Dimension size = child.getPreferredSize();
+            size.width += 2*(offset+margin);
+            return size;
+        }
+    }
+
+    private static class ThreeTierLayout implements LayoutManager { 
+        private final Component items[] = new Component[3];
+
+        public void addLayoutComponent(String name, Component comp) {
+            if (name.equals("north")) {
+                items[0] = comp;
+            } else if (name.equals("center")) {
+                items[1] = comp;
+            } else if (name.equals("south")) {
+                items[2] = comp;
+            } 
+        }
+
+        public void layoutContainer(Container parent) {
+            Insets insets = parent.getInsets();
+            int width = parent.getWidth() - insets.left - insets.right;
+            int height = parent.getHeight()  - insets.top - insets.bottom;
+
+            int h0 = items[0].getPreferredSize().height;
+            items[0].setBounds(insets.left, insets.top, width, h0);
+            
+            int h2 = items[2].getPreferredSize().height;
+            items[2].setBounds(insets.left, insets.top + height - h2, width, h2);
+            
+            int h1 = height - h0 - h2; 
+            items[1].setBounds(insets.left, insets.top + h0, width, h1);
+        }
+
+        public Dimension minimumLayoutSize(Container parent) {
+            Dimension result = new Dimension();
+            for (int i=0; i<3; i++) {
+                if (items[i] == null) {
+                    continue;
+                }
+                Dimension size = items[i].getMinimumSize();
+                if (result.width < size.width) {
+                    result.width = size.width;
+                }
+                result.height += size.height;
+            }
+            return result;
+        }
+
+        public Dimension preferredLayoutSize(Container parent) {
+            Dimension result = new Dimension();
+            for (int i=0; i<3; i++) {
+                if (items[i] == null) {
+                    continue;
+                }
+                Dimension size = items[i].getPreferredSize();
+                if (result.width < size.width) {
+                    result.width = size.width;
+                }
+                result.height += size.height;
+            }
+            return result;
+        }
+
+        public void removeLayoutComponent(Component comp) {
+            for (int i=0; i<3; i++) {
+                if (items[i] == comp) {
+                    items[i] = null;
+                }
+            }
+        }
+        
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Launcher.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Parameters.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Parameters.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Parameters.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Parameters.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,74 @@
+/*
+ *  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 Pavel Dolgov
+ * @version $Revision: 1.2 $
+ */
+package org.apache.harmony.applet;
+
+import java.net.URL;
+import java.util.Map;
+
+/**
+ * Applet's startup parameters
+ */
+final class Parameters {
+
+    /** applet parameters provided by &lt;param&gt; tags */
+    final Map parameters;
+    /** the location the document comes from */
+    final URL documentBase;
+    /** document's id from the host application */
+    final int documentId;
+    /** the location applet comes from */
+    final URL codeBase;
+    /** applet's id from host application */
+    final int id;
+    /** applet's class name (without suffix '.class') */
+    final String className;
+    /** applet's name in the document */
+    final String name;
+    /** host app's window to put applet into */
+    final long parentWindowId;
+    /** Java app's Container to put applet into */
+    final Object container;
+
+    Parameters( int id,
+                long parentWindowId,
+                URL documentBase,
+                int documentId,
+                URL codeBase,
+                String className,
+                Map parameters,
+                String name,
+                Object container) {
+
+        this.id = id;
+        this.parentWindowId = parentWindowId;
+        this.parameters = parameters;
+        this.documentBase = documentBase;
+        this.documentId = documentId;
+        this.codeBase = codeBase;
+        this.className = className;
+        this.name = name;
+        this.container = container;
+    }
+
+    String getParameter(String name) {
+        return (String)parameters.get(name);
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Parameters.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Proxy.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Proxy.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Proxy.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Proxy.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,260 @@
+/*
+ *  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 Pavel Dolgov
+ * @version $Revision: 1.2 $
+ */
+package org.apache.harmony.applet;
+
+import java.applet.Applet;
+import java.applet.AppletContext;
+import java.applet.AppletStub;
+import java.awt.Container;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.net.URL;
+
+import org.apache.harmony.awt.ComponentInternals;
+
+
+/**
+ * Applet's state and parameters, implementation <b>AppletStub</b> interface
+ */
+class Proxy implements AppletStub {
+
+    final DocumentSlice docSlice;
+    final Parameters params;
+    
+    private final AppletThread mainThread;
+    private Applet applet;
+    private Container parent;
+    private boolean active;
+    
+    Proxy(DocumentSlice ds, Parameters params) {
+        this.docSlice = ds;
+        this.params = params;
+        
+        mainThread = new AppletThread(this);
+        ds.add(this);
+    }
+    
+    Applet getApplet() {
+        return applet;
+    }
+    
+    void create() {
+        if (Thread.currentThread() == mainThread) {
+            createImpl();
+        } else {
+            if (!mainThread.isAlive()) {
+                mainThread.start();
+            }
+            mainThread.postCommand(new Command("create") {
+                public void run() {
+                    createImpl();
+                }});
+        }        
+    }
+    
+    private void createImpl() {
+        Toolkit toolkit = Toolkit.getDefaultToolkit();
+        if (toolkit == null) {
+            throw new InternalError("Toolkit is null");
+        }
+        
+        if ((params.container != null) && (params.container instanceof Container)) { 
+
+            parent = (Container)params.container;
+        } else {
+            
+            ComponentInternals ci = ComponentInternals.getComponentInternals();
+            parent = ci.attachNativeWindow(params.parentWindowId);
+        }
+
+        applet = createApplet();
+        applet.setStub(this);
+
+        parent.add(applet);
+        parent.validate();
+
+        initImpl();
+        startImpl();
+
+        parent.setVisible(true);
+    }
+        
+    void start() {
+        if (Thread.currentThread() == mainThread) {
+            startImpl();
+        } else {
+            mainThread.postCommand(new Command("start") {
+                public void run() {
+                    startImpl();
+                }});
+        }
+    }
+    
+    private void startImpl() {
+        if (applet != null) {
+            applet.start();
+            active = true;
+            docSlice.showStatus("Applet started");
+        }
+    }
+    
+    void stop () {
+        if (Thread.currentThread() == mainThread) {
+            stopImpl();
+        } else {
+            mainThread.postCommand(new Command("stop") {
+                public void run() {
+                    stopImpl();
+                }});
+        }
+    }
+    
+    private void stopImpl() {
+        if (applet != null) {
+            active = false;
+            applet.stop();
+            docSlice.showStatus("Applet stopped");
+        }
+    }
+    
+    void init() {
+        if (Thread.currentThread() == mainThread) {
+            initImpl();
+        } else {
+            mainThread.postCommand(new Command("init") {
+                public void run() {
+                    initImpl();
+                }});
+        }
+    }
+    
+    private void initImpl() {
+        if (applet != null) {
+            applet.init();
+            docSlice.showStatus("Applet initialized");
+        }
+    }
+    
+    void destroy() {
+        if (Thread.currentThread() == mainThread) {
+            destroyImpl();
+        } else {
+            mainThread.postCommand(new Command("destroy") {
+                public void run() {
+                    destroyImpl();
+                }});
+        }
+    }
+    
+    private void destroyImpl() {
+        if (applet != null) {
+            applet.destroy();
+            docSlice.showStatus("Applet destroyed");
+        }
+    }
+    
+    void dispose() {
+        if (Thread.currentThread() == mainThread) {
+            disposeImpl();
+        } else {
+            mainThread.postCommand(new Command("dispose") {
+                public void run() {
+                    disposeImpl();
+                }});
+        }
+    }
+    
+    private void disposeImpl() {
+        if (applet != null) {
+            parent.setVisible(false);
+            parent.remove(applet);
+            if (parent instanceof Window) {
+                ((Window)parent).dispose();
+            }
+            applet.stop();
+            applet.destroy();
+            applet = null;
+            parent = null;
+        }
+
+        mainThread.exit();
+    }
+    
+    private Applet createApplet() {
+        Class appletClass;
+        try {
+            appletClass = docSlice.codeBase.classLoader.loadClass(params.className);
+        } catch (ClassNotFoundException e) {
+            throw new RuntimeException(e);
+        }
+
+        try {
+            return (Applet)appletClass.newInstance();
+
+        } catch (InstantiationException e) {
+            throw new RuntimeException(e);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see java.applet.AppletStub#getCodeBase()
+     */
+    public URL getCodeBase() {
+        return docSlice.codeBase.codeBase;
+    }
+
+    /* (non-Javadoc)
+     * @see java.applet.AppletStub#appletResize(int, int)
+     */
+    public void appletResize(int width, int height) {
+        docSlice.codeBase.factory.appletResize(this, width, height);
+    }
+
+    /* (non-Javadoc)
+     * @see java.applet.AppletStub#getAppletContext()
+     */
+    public AppletContext getAppletContext() {
+        return docSlice;
+    }
+
+    /* (non-Javadoc)
+     * @see java.applet.AppletStub#getDocumentBase()
+     */
+    public URL getDocumentBase() {
+        return docSlice.document.docBase;
+    }
+
+    /* (non-Javadoc)
+     * @see java.applet.AppletStub#getParameter(java.lang.String)
+     */
+    public String getParameter(String name) {
+        return params.getParameter(name);
+    }
+
+    /* (non-Javadoc)
+     * @see java.applet.AppletStub#isActive()
+     */
+    public boolean isActive() {
+        return active;
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/applet/src/main/java/org/apache/harmony/applet/Proxy.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/awt/src/main/java/common/java/awt/print/PrinterGraphics.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/awt/src/main/java/common/java/awt/print/PrinterGraphics.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/awt/src/main/java/common/java/awt/print/PrinterGraphics.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/awt/src/main/java/common/java/awt/print/PrinterGraphics.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,26 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software 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 Igor A. Pyankov
+ * @version $Revision: 1.1 $
+ */
+package java.awt.print;
+
+public interface PrinterGraphics {
+
+    public abstract PrinterJob getPrinterJob();
+
+}
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/awt/src/main/java/common/java/awt/print/PrinterGraphics.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/awt/src/main/java/common/java/awt/print/PrinterJob.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/awt/src/main/java/common/java/awt/print/PrinterJob.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/awt/src/main/java/common/java/awt/print/PrinterJob.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/awt/src/main/java/common/java/awt/print/PrinterJob.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,160 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software 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 Igor A. Pyankov
+ * @version $Revision: 1.1 $
+ */
+package java.awt.print;
+
+import java.awt.AWTError;
+import java.awt.HeadlessException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.StreamPrintServiceFactory;
+import javax.print.attribute.PrintRequestAttributeSet;
+
+public abstract class PrinterJob {
+
+    /* abstract section */
+    public abstract void cancel();
+
+    public abstract void setPrintable(Printable painter);
+
+    public abstract void setPrintable(Printable painter, PageFormat format);
+
+    public abstract void setPageable(Pageable document)
+            throws NullPointerException;
+
+    public abstract void print() throws PrinterException;
+
+    public abstract void setJobName(String jobName);
+
+    public abstract void setCopies(int copies);
+
+    public abstract int getCopies();
+
+    public abstract boolean printDialog() throws HeadlessException;
+
+    public abstract boolean isCancelled();
+
+    public abstract String getUserName();
+
+    public abstract String getJobName();
+
+    public abstract PageFormat pageDialog(PageFormat page)
+            throws HeadlessException;
+
+    public abstract PageFormat defaultPage(PageFormat page);
+
+    public abstract PageFormat validatePage(PageFormat page);
+
+    /* static section */
+    public static PrinterJob getPrinterJob(){
+
+        SecurityManager securitymanager = System.getSecurityManager();
+        if(securitymanager != null) {
+            securitymanager.checkPrintJobAccess();
+        }
+        /* This code has been developed according to API documentation
+         * for Priviledged Blocks. 
+         */
+        return (PrinterJob) AccessController.doPrivileged(
+                new PrivilegedAction() {
+            public Object run() {
+                String s;
+                s = System.getProperty("java.awt.printerjob");
+
+                if (s == null || s.equals("")){
+                    s = "org.apache.harmony.x.print.awt.PSPrinterJob";
+                }
+                try {
+                    return (PrinterJob) Class.forName(s).newInstance();
+                } catch (ClassNotFoundException cnfe) {
+                    throw new AWTError(
+                            "Default class for PrinterJob is not found");
+                } catch (IllegalAccessException iae) {
+                    throw new AWTError(
+                            "No access to default class for PrinterJob");
+                } catch (InstantiationException ie) {
+                    throw new AWTError(
+                            "Instantiation exception for PrinterJob");
+                }
+            }
+        });
+    }
+
+
+    public static PrintService[] lookupPrintServices(){
+       return PrintServiceLookup.lookupPrintServices(
+           javax.print.DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
+    }
+
+    public static StreamPrintServiceFactory[] lookupStreamPrintServices(
+            String mimeType) {
+        return StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
+                javax.print.DocFlavor.SERVICE_FORMATTED.PAGEABLE, mimeType);
+    }
+
+    /* public section*/
+    public PrinterJob() {
+        super();
+     }
+
+     public PageFormat defaultPage(){
+        return defaultPage(new PageFormat());
+     }
+
+    public PrintService getPrintService(){
+        return null;
+    }
+
+    public void print(PrintRequestAttributeSet attributes)
+            throws PrinterException {
+        // This implementation ignores the attribute set.
+        print();
+    }
+
+    public boolean printDialog(PrintRequestAttributeSet attributes)
+            throws HeadlessException {
+        if (attributes == null) {
+            throw new NullPointerException(
+                    "The parameter 'attributes' is null");
+        }
+        //This implementation ignores the attribute set.
+        return printDialog();
+    }
+
+    public void setPrintService(PrintService printservice)
+            throws PrinterException {
+        throw new PrinterException(printservice.toString()
+                    + "is not supported");
+    }
+
+    public PageFormat pageDialog(PrintRequestAttributeSet attributes)
+        throws HeadlessException {
+        //This implementation ignores the attribute set.
+        if(attributes == null) {
+            throw new NullPointerException(
+                    "The parameter 'attributes' is null");
+        }
+        return pageDialog(defaultPage());
+    }
+
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/awt/src/main/java/common/java/awt/print/PrinterJob.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/IIOException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/IIOException.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/IIOException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/IIOException.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,36 @@
+/*
+ *  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;
+
+import java.io.IOException;
+
+public class IIOException extends IOException {
+
+    private static final long serialVersionUID = -3216210718638985251L;
+
+    public IIOException(String message) {
+        super(message);
+    }
+
+    public IIOException(String message, Throwable cause) {
+        super(message);
+        initCause(cause);
+    }
+}

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

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/IIOImage.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/IIOImage.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/IIOImage.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/IIOImage.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,110 @@
+/*
+ *  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;
+
+import javax.imageio.metadata.IIOMetadata;
+import java.awt.image.RenderedImage;
+import java.awt.image.Raster;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class IIOImage {
+
+    protected RenderedImage image;
+    protected Raster raster;
+    protected List thumbnails;
+    protected IIOMetadata metadata;
+
+
+    public IIOImage(RenderedImage image, List thumbnails, IIOMetadata metadata) {
+        if (image == null) {
+            throw new IllegalArgumentException("image should not be NULL");
+        }
+        this.raster = null;
+        this.image = image;
+        this.thumbnails = thumbnails;
+        this.metadata = metadata;
+    }
+
+    public IIOImage(Raster raster, List thumbnails, IIOMetadata metadata) {
+        if (raster == null) {
+            throw new IllegalArgumentException("raster should not be NULL");
+        }
+        this.image = null;
+        this.raster = raster;
+        this.thumbnails = thumbnails;
+        this.metadata = metadata;
+    }
+
+    public RenderedImage getRenderedImage() {
+        return image;
+    }
+
+    public void setRenderedImage(RenderedImage image) {
+        if (image == null) {
+            throw new IllegalArgumentException("image should not be NULL");
+        }
+        raster = null;
+        this.image = image;
+    }
+
+    public boolean hasRaster() {
+        return raster != null;
+    }
+
+    public Raster getRaster() {
+        return raster;
+    }
+
+    public void setRaster(Raster raster) {
+        if (raster == null) {
+            throw new IllegalArgumentException("raster should not be NULL");
+        }
+        image = null;
+        this.raster = raster;
+    }
+
+    public int getNumThumbnails() {
+        return thumbnails != null ? thumbnails.size() : 0;
+    }
+
+    public BufferedImage getThumbnail(int index) {
+        if (thumbnails != null) {
+            return (BufferedImage) thumbnails.get(index);
+        }
+        throw new IndexOutOfBoundsException("no thumbnails were set");
+    }
+
+    public List getThumbnails() {
+        return thumbnails;
+    }
+
+    public void setThumbnails(List thumbnails) {
+        this.thumbnails = thumbnails;
+    }
+
+    public IIOMetadata getMetadata() {
+        return metadata;
+    }
+
+    public void setMetadata(IIOMetadata metadata) {
+        this.metadata = metadata;
+    }
+}

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

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/IIOParam.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/IIOParam.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/IIOParam.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/IIOParam.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,176 @@
+/*
+ *  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;
+
+import java.awt.*;
+
+public abstract class IIOParam {
+    protected Rectangle sourceRegion;
+    protected int sourceXSubsampling;
+    protected int sourceYSubsampling;
+    protected int subsamplingXOffset;
+    protected int subsamplingYOffset;
+    protected int[] sourceBands;
+    protected ImageTypeSpecifier destinationType;
+    protected Point destinationOffset;
+    protected IIOParamController defaultController;
+    protected IIOParamController controller;
+
+    protected IIOParam() {}
+
+    public void setSourceRegion(Rectangle sourceRegion) {
+        if (sourceRegion != null) {
+            if (sourceRegion.x < 0) {
+                throw new IllegalArgumentException("x < 0");
+            }
+            if (sourceRegion.y < 0) {
+                throw new IllegalArgumentException("y < 0");
+            }
+            if (sourceRegion.width <= 0) {
+                throw new IllegalArgumentException("width <= 0");
+            }
+            if (sourceRegion.height <= 0) {
+                throw new IllegalArgumentException("height <= 0");
+            }
+
+            if (sourceRegion.width <= subsamplingXOffset) {
+                throw new IllegalArgumentException("width <= subsamplingXOffset");
+            }
+
+            if (sourceRegion.height <= subsamplingYOffset) {
+                throw new IllegalArgumentException("height <= subsamplingXOffset");
+            }
+            //-- clone it to avoid unexpected modifications
+            this.sourceRegion = (Rectangle) sourceRegion.clone();
+        } else {
+            this.sourceRegion = null;
+        }
+    }
+
+    public Rectangle getSourceRegion() {
+        //-- clone it to avoid unexpected modifications
+        return (Rectangle) sourceRegion.clone();
+    }
+
+    public void setSourceSubsampling(int sourceXSubsampling,
+                                 int sourceYSubsampling,
+                                 int subsamplingXOffset,
+                                 int subsamplingYOffset) {
+
+        if (sourceXSubsampling <= 0) {
+            throw new IllegalArgumentException("sourceXSubsampling <= 0");
+        }
+        if (sourceYSubsampling <= 0) {
+            throw new IllegalArgumentException("sourceYSubsampling <= 0");
+        }
+
+        if (subsamplingXOffset <= 0 || subsamplingXOffset >= sourceXSubsampling) {
+            throw new IllegalArgumentException("subsamplingXOffset is wrong");
+        }
+
+        if (subsamplingYOffset <= 0 || subsamplingYOffset >= sourceYSubsampling) {
+            throw new IllegalArgumentException("subsamplingYOffset is wrong");
+        }
+
+        //-- does region contain pixels
+        if (sourceRegion != null) {
+            if (sourceRegion.width <= subsamplingXOffset ||
+                    sourceRegion.height <= subsamplingYOffset) {
+                throw new IllegalArgumentException("there are no pixels in region");
+            }
+        }
+
+        this.sourceXSubsampling = sourceXSubsampling;
+        this.sourceYSubsampling = sourceYSubsampling;
+        this.subsamplingXOffset = subsamplingXOffset;
+        this.subsamplingYOffset = subsamplingYOffset;
+    }
+
+    public int getSourceXSubsampling() {
+        return sourceXSubsampling;
+    }
+
+    public int getSourceYSubsampling() {
+        return sourceYSubsampling;
+    }
+
+    public int getSubsamplingXOffset() {
+        return subsamplingXOffset;
+    }
+
+    public int getSubsamplingYOffset() {
+        return subsamplingYOffset;
+    }
+
+    public void setSourceBands(int[] sourceBands) {
+        // TODO implement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+
+    public int[] getSourceBands() {
+        // TODO implement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+
+    public void setDestinationType(ImageTypeSpecifier destinationType) {
+        // TODO implement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+
+    public ImageTypeSpecifier getDestinationType() {
+        // TODO implement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+
+    public void setDestinationOffset(Point destinationOffset) {
+        // TODO implement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+
+    public Point getDestinationOffset() {
+        // TODO implement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+
+    public void setController(IIOParamController controller) {
+        // TODO implement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+
+    public IIOParamController getController() {
+        // TODO implement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+
+    public IIOParamController getDefaultController() {
+        // TODO implement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+
+    public boolean hasController() {
+        // TODO implement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+
+    public boolean activateController() {
+        // TODO implement
+        throw new UnsupportedOperationException("not implemented yet");
+    }
+}

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

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/IIOParamController.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/IIOParamController.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/IIOParamController.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/IIOParamController.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,30 @@
+/*
+ *  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;
+
+/**
+ * @author Sergey I. Salishev
+ * @version $Revision: 1.2 $
+ */
+public interface IIOParamController {
+
+    boolean activate(IIOParam param);
+}
+

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

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/ImageIO.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/ImageIO.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/ImageIO.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/ImageIO.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,413 @@
+/*
+ *  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;
+
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageOutputStream;
+import javax.imageio.spi.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.Arrays;
+import java.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.net.URL;
+
+public final class ImageIO {
+
+    private static final IIORegistry registry = IIORegistry.getDefaultInstance();
+
+    private ImageIO() {}
+    
+
+    public static void scanForPlugins() {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static void setUseCache(boolean useCache) {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static boolean getUseCache() {
+        // TODO implement
+        return false;
+    }
+
+    public static void setCacheDirectory(File cacheDirectory) {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static File getCacheDirectory() {
+        // TODO implement
+        //-- null indicates system-dep default temporary directory
+        return null;
+    }
+
+    public static ImageInputStream createImageInputStream(Object input)
+            throws IOException {
+
+        if (input == null) {
+            throw new IllegalArgumentException("input source cannot be NULL");
+        }
+
+        Iterator it = registry.getServiceProviders(ImageInputStreamSpi.class, true);
+
+        while (it.hasNext()) {
+            ImageInputStreamSpi spi = (ImageInputStreamSpi) it.next();
+            if (spi.getInputClass().isInstance(input)) {
+                return spi.createInputStreamInstance(input);
+            }
+        }
+        return null;
+    }
+
+    public static ImageOutputStream createImageOutputStream(Object output)
+            throws IOException {
+        if (output == null) {
+            throw new IllegalArgumentException("output destination cannot be NULL");
+        }
+
+        Iterator it = registry.getServiceProviders(ImageOutputStreamSpi.class, true);
+
+        while (it.hasNext()) {
+            ImageOutputStreamSpi spi = (ImageOutputStreamSpi) it.next();
+            if (spi.getOutputClass().isInstance(output)) {
+                return spi.createOutputStreamInstance(output);
+            }
+        }
+        return null;
+    }
+
+    public static String[] getReaderFormatNames() {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static String[] getReaderMIMETypes() {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static Iterator getImageReaders(Object input) {
+        if (input == null) {
+            throw new NullPointerException("input cannot be NULL");
+        }
+
+        Iterator it = registry.getServiceProviders(ImageReaderSpi.class,
+                new CanReadFilter(input), true);
+
+        return new SpiIteratorToReadersIteratorWrapper(it);
+    }
+
+    public static Iterator getImageReadersByFormatName(String formatName) {
+        if (formatName == null) {
+            throw new NullPointerException("format name cannot be NULL");
+        }
+
+        Iterator it = registry.getServiceProviders(ImageReaderSpi.class,
+                new FormatFilter(formatName), true);
+
+        return new SpiIteratorToReadersIteratorWrapper(it);
+    }
+
+    public static Iterator getImageReadersBySuffix(String fileSuffix) {
+        if (fileSuffix == null) {
+            throw new NullPointerException("suffix cannot be NULL");
+        }
+        Iterator it = registry.getServiceProviders(ImageReaderSpi.class,
+                new SuffixFilter(fileSuffix), true);
+
+        return new SpiIteratorToReadersIteratorWrapper(it);
+    }
+
+    public static Iterator getImageReadersByMIMEType(String MIMEType) {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static String[] getWriterFormatNames() {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static String[] getWriterMIMETypes() {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static Iterator getImageWritersByFormatName(String formatName) {
+        if (formatName == null) {
+            throw new NullPointerException("format name cannot be NULL");
+        }
+
+        Iterator it = registry.getServiceProviders(ImageWriterSpi.class,
+                new FormatFilter(formatName), true);
+
+        return new SpiIteratorToWritersIteratorWrapper(it);
+    }
+
+    public static Iterator getImageWritersBySuffix(String fileSuffix) {
+        if (fileSuffix == null) {
+            throw new NullPointerException("suffix cannot be NULL");
+        }
+        Iterator it = registry.getServiceProviders(ImageWriterSpi.class,
+                new SuffixFilter(fileSuffix), true);
+        return new SpiIteratorToWritersIteratorWrapper(it);
+    }
+
+    public static Iterator getImageWritersByMIMEType(String MIMEType) {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static ImageWriter getImageWriter(ImageReader reader) {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static ImageReader getImageReader(ImageWriter writer) {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static Iterator getImageWriters(ImageTypeSpecifier type,
+                                           String formatName) {
+        if (type == null) {
+            throw new NullPointerException("type cannot be NULL");
+        }
+
+        if (formatName == null) {
+            throw new NullPointerException("format name cannot be NULL");
+        }
+
+        Iterator it = registry.getServiceProviders(ImageWriterSpi.class,
+                new FormatAndEncodeFilter(type, formatName), true);
+
+        return new SpiIteratorToWritersIteratorWrapper(it);
+    }
+
+    public static Iterator getImageTranscoders(ImageReader reader,
+                                               ImageWriter writer) {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static BufferedImage read(File input)
+            throws IOException {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static BufferedImage read(InputStream input)
+            throws IOException {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static BufferedImage read(URL input)
+            throws IOException {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static BufferedImage read(ImageInputStream stream)
+            throws IOException {
+        throw new UnsupportedOperationException("Not supported yet");
+    }
+
+    public static boolean write(RenderedImage im,
+                                String formatName,
+                                ImageOutputStream output)
+            throws IOException {
+
+        if (im == null) {
+            throw new IllegalArgumentException("image cannot be NULL");
+        }
+        if (formatName == null) {
+            throw new IllegalArgumentException("format name cannot be NULL");
+        }
+        if (output == null) {
+            throw new IllegalArgumentException("output cannot be NULL");
+        }
+
+        Iterator it = getImageWriters(ImageTypeSpecifier.createFromRenderedImage(im), formatName);
+        if (it.hasNext()) {
+            ImageWriter writer = (ImageWriter) it.next();
+            writer.setOutput(output);
+            writer.write(im);
+            output.flush();
+            writer.dispose();
+            return true;
+        }
+        return false;
+    }
+
+    public static boolean write(RenderedImage im,
+                                String formatName,
+                                File output)
+            throws IOException {
+
+        if (output == null) {
+            throw new IllegalArgumentException("output cannot be NULL");
+        }
+
+        if (output.exists()) {
+            output.delete();
+        }
+
+        ImageOutputStream ios = createImageOutputStream(output);
+        boolean rt = write(im, formatName, ios);
+        ios.close();
+        return rt;
+    }
+
+    public static boolean write(RenderedImage im,
+                                String formatName,
+                                OutputStream output)
+            throws IOException {
+
+        if (output == null) {
+            throw new IllegalArgumentException("output cannot be NULL");
+        }
+
+        ImageOutputStream ios = createImageOutputStream(output);
+        boolean rt = write(im, formatName, ios);
+        ios.close();
+        return rt;
+    }
+
+
+    /**
+     * Filter to match spi by format name
+     */
+    static class FormatFilter implements ServiceRegistry.Filter {
+        private String name;
+
+        public FormatFilter(String name) {
+            this.name = name;
+        }
+
+        public boolean filter(Object provider) {
+            ImageReaderWriterSpi spi = (ImageReaderWriterSpi) provider;
+            return Arrays.asList(spi.getFormatNames()).contains(name);
+        }
+    }
+
+    /**
+     * Filter to match spi by format name and encoding possibility
+     */
+    static class FormatAndEncodeFilter extends FormatFilter {
+
+        private ImageTypeSpecifier type;
+
+        public FormatAndEncodeFilter(ImageTypeSpecifier type, String name) {
+            super(name);
+            this.type = type;
+        }
+
+        public boolean filter(Object provider) {
+            ImageWriterSpi spi = (ImageWriterSpi) provider;
+            return super.filter(provider) && spi.canEncodeImage(type);
+        }
+    }
+
+    /**
+     * Filter to match spi by suffix
+     */
+    static class SuffixFilter implements ServiceRegistry.Filter {
+        private String suf;
+
+        public SuffixFilter(String suf) {
+            this.suf = suf;
+        }
+
+        public boolean filter(Object provider) {
+            ImageReaderWriterSpi spi = (ImageReaderWriterSpi) provider;
+            return Arrays.asList(spi.getFileSuffixes()).contains(suf);
+        }
+    }
+
+    /**
+     * Filter to match spi by decoding possibility
+     */
+    static class CanReadFilter implements ServiceRegistry.Filter {
+        private Object input;
+
+        public CanReadFilter(Object input) {
+            this.input = input;
+        }
+
+        public boolean filter(Object provider) {
+            ImageReaderSpi spi = (ImageReaderSpi) provider;
+            try {
+                return spi.canDecodeInput(input);
+            } catch (IOException e) {
+                return false;
+            }
+        }
+    }
+
+    /**
+     * Wraps Spi's iterator to ImageWriter iterator
+     */
+    static class SpiIteratorToWritersIteratorWrapper implements Iterator {
+
+        private Iterator backend;
+
+        public SpiIteratorToWritersIteratorWrapper(Iterator backend) {
+            this.backend = backend;
+        }
+
+        public Object next() {
+            try {
+                return ((ImageWriterSpi) backend.next()).createWriterInstance();
+            } catch (IOException e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+
+        public boolean hasNext() {
+            return backend.hasNext();
+        }
+
+        public void remove() {
+            throw new UnsupportedOperationException("Use deregisterServiceprovider instead of Iterator.remove()");
+        }
+    }
+
+    /**
+     * Wraps spi's iterator to ImageReader iterator
+     */
+    static class SpiIteratorToReadersIteratorWrapper implements Iterator {
+        private Iterator backend;
+
+        public SpiIteratorToReadersIteratorWrapper(Iterator backend) {
+            this.backend = backend;
+        }
+
+        public Object next() {
+            try {
+                return ((ImageReaderSpi) backend.next()).createReaderInstance();
+            } catch (IOException e) {
+                e.printStackTrace();
+                return null;
+            }
+        }
+
+        public boolean hasNext() {
+            return backend.hasNext();
+        }
+
+        public void remove() {
+            throw new UnsupportedOperationException("Use deregisterServiceprovider instead of Iterator.remove()");
+        }
+    }
+}

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

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/ImageReadParam.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/ImageReadParam.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/ImageReadParam.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/java/javax/imageio/ImageReadParam.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,93 @@
+/*
+ *  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;
+
+import java.awt.Dimension;
+import java.awt.image.BufferedImage;
+
+/**
+ * @author Sergey I. Salishev
+ * @version $Revision: 1.2 $
+ */
+public class ImageReadParam extends IIOParam {
+
+    protected boolean canSetSourceRenderSize;
+    protected BufferedImage destination;
+    protected int[] destinationBands;
+    protected int minProgressivePass;
+    protected int numProgressivePasses;
+    protected Dimension sourceRenderSize;
+
+    public boolean canSetSourceRenderSize() {
+        return canSetSourceRenderSize;
+    }
+
+    public BufferedImage getDestination() {
+        return destination;
+    }
+
+    public int[] getDestinationBands() {
+        return destinationBands;
+    }
+
+    public int getSourceMaxProgressivePass() {
+        if (getSourceNumProgressivePasses() == Integer.MAX_VALUE) {
+            return Integer.MAX_VALUE;
+        }
+        return getSourceMinProgressivePass() + getSourceNumProgressivePasses() - 1;
+    }
+
+    public int getSourceMinProgressivePass() {
+        return minProgressivePass;
+    }
+
+    public int getSourceNumProgressivePasses() {
+        return numProgressivePasses;
+    }
+
+    public Dimension getSourceRenderSize() {
+        return sourceRenderSize;
+    }
+
+    public void setDestination(BufferedImage destination) {
+        this.destination = destination;
+    }
+
+    public void setDestinationBands(int[] destinationBands) {
+        this.destinationBands = destinationBands;
+    }
+
+    public void setDestinationType(ImageTypeSpecifier destinationType) {
+        this.destinationType = destinationType;
+    }
+
+    public void setSourceProgressivePasses(int minPass, int numPasses) {
+        minProgressivePass = minPass;
+        numProgressivePasses = numPasses;
+    }
+
+    public void setSourceRenderSize(Dimension size) throws UnsupportedOperationException {
+        if (!canSetSourceRenderSize) {
+            throw new UnsupportedOperationException("can't set source renderer size");
+        }
+        sourceRenderSize = size;        
+    }
+}
+

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