# HG changeset patch # User Jaroslav Tulach # Date 1233506492 -3600 # Node ID 03a451fc2256219e9471ce24652ef7e951a82d3b # Parent d8bb07520edd2fd5ff589aef30214c86f14c1cce Marking code snippets for the trycatchredo example diff -r d8bb07520edd -r 03a451fc2256 samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/SaveAction.java --- a/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/SaveAction.java Sun Feb 01 16:30:09 2009 +0100 +++ b/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/SaveAction.java Sun Feb 01 17:41:32 2009 +0100 @@ -24,6 +24,7 @@ public void actionPerformed(ActionEvent ev) { assert EventQueue.isDispatchThread(); + // BEGIN: trycatchredo.SaveAction try { OutputStream os = where.openConnection().getOutputStream(); os.write(what.toString().getBytes()); @@ -31,5 +32,6 @@ } catch (IOException ex) { JOptionPane.showMessageDialog(null, ex); } + // END: trycatchredo.SaveAction } } diff -r d8bb07520edd -r 03a451fc2256 samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/SaveActionWithQuery.java --- a/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/SaveActionWithQuery.java Sun Feb 01 16:30:09 2009 +0100 +++ b/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/SaveActionWithQuery.java Sun Feb 01 17:41:32 2009 +0100 @@ -25,6 +25,7 @@ public void actionPerformed(ActionEvent ev) { assert EventQueue.isDispatchThread(); + // BEGIN: trycatchredo.SaveActionWithQuery for (;;) { try { OutputStream os = where.openConnection().getOutputStream(); @@ -46,6 +47,7 @@ } break; } + // END: trycatchredo.SaveActionWithQuery } private static void setVisible(JDialog d, JOptionPane p) { diff -r d8bb07520edd -r 03a451fc2256 samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/UserQuestionException.java --- a/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/UserQuestionException.java Sun Feb 01 16:30:09 2009 +0100 +++ b/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/UserQuestionException.java Sun Feb 01 17:41:32 2009 +0100 @@ -3,6 +3,7 @@ import java.io.IOException; import javax.swing.JOptionPane; +// BEGIN: trycatchredo.UserQuestionException /** Specialized I/O exception to request some kind of user confirmation. * A code that needs to ask user shall not attempt to open a dialog itself, * rather it shall emit this exception and let its callers show the dialog @@ -13,7 +14,9 @@ */ public abstract class UserQuestionException extends IOException { /** Description of the dialog to show to the user. Whoever catches - * this exception shall use {@link #getQuestionPane()}.{@link JOptionPane#createDialog(java.lang.String)} + * this exception shall use + * {@link #getQuestionPane()}. + * {@link JOptionPane#createDialog(java.lang.String)} * to construct and display the dialog. * * @return the pane to display to user @@ -27,3 +30,4 @@ */ public abstract void confirm(Object option); } +// END: trycatchredo.UserQuestionException \ No newline at end of file diff -r d8bb07520edd -r 03a451fc2256 samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/usage/QueryStream.java --- a/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/usage/QueryStream.java Sun Feb 01 16:30:09 2009 +0100 +++ b/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/usage/QueryStream.java Sun Feb 01 17:41:32 2009 +0100 @@ -6,13 +6,15 @@ import java.io.OutputStream; import javax.swing.JOptionPane; +// BEGIN: trycatchredo.stream public final class QueryStream extends OutputStream { private ByteArrayOutputStream arr = new ByteArrayOutputStream(); /** this field can be manipulated by the QueryException */ Boolean reverse; @Override - public synchronized void write(byte[] b, int off, int len) throws IOException { + public synchronized void write(byte[] b, int off, int len) + throws IOException { if (reverse == null) { throw new QueryException(); } @@ -63,3 +65,4 @@ } } } +// END: trycatchredo.stream