samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/usage/Main.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sun, 01 Feb 2009 16:29:46 +0100
changeset 312 0678c9589013
permissions -rw-r--r--
Renaming the project to 'Try Catch Redo'
jtulach@312
     1
package org.apidesign.exceptions.trycatchredo.usage;
jtulach@312
     2
jtulach@312
     3
import java.awt.EventQueue;
jtulach@312
     4
import java.awt.event.ActionEvent;
jtulach@312
     5
import java.net.URL;
jtulach@312
     6
import javax.swing.Action;
jtulach@312
     7
import org.apidesign.exceptions.trycatchredo.api.IOManager;
jtulach@312
     8
import org.apidesign.exceptions.trycatchredo.api.UserQuestionException;
jtulach@312
     9
jtulach@312
    10
/** Sample usage showing interactive storage capabilities of the
jtulach@312
    11
 * {@link UserQuestionException}
jtulach@312
    12
 *
jtulach@312
    13
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jtulach@312
    14
 */
jtulach@312
    15
public class Main {
jtulach@312
    16
    public static void main(String[] args) throws Exception {
jtulach@312
    17
        MemoryURL.initialize();
jtulach@312
    18
        
jtulach@312
    19
        for (int cnt = 0; cnt < 10; cnt++) {
jtulach@312
    20
            URL u = new URL("memory://" + cnt + "/queryEncoding.txt");
jtulach@312
    21
            MemoryURL.registerURL(u.toExternalForm(), "", new QueryStream());
jtulach@312
    22
            final Action a = IOManager.createSaveAction(u, "Ask a Question");
jtulach@312
    23
            EventQueue.invokeAndWait(new Runnable() {
jtulach@312
    24
                public void run() {
jtulach@312
    25
                    a.actionPerformed(new ActionEvent(this, 0, ""));
jtulach@312
    26
                }
jtulach@312
    27
            });
jtulach@312
    28
            String out = MemoryURL.getOutputForURL(u.toExternalForm());
jtulach@312
    29
jtulach@312
    30
            System.err.println(cnt + " output: " + out);
jtulach@312
    31
        }
jtulach@312
    32
jtulach@312
    33
        System.exit(0);
jtulach@312
    34
    }
jtulach@312
    35
}