Mercurial > hg > blitz_stable
comparison src/com/go/trove/net/CheckedInterruptedIOException.java @ 0:3dc0c5604566
Initial checkin of blitz 2.0 fcs - no installer yet.
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sat, 21 Mar 2009 11:00:06 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3dc0c5604566 |
---|---|
1 /* | |
2 * CheckedInterruptedIOException.java | |
3 * | |
4 * Copyright (c) 2000 Walt Disney Internet Group. All Rights Reserved. | |
5 * | |
6 * Original author: Brian S O'Neill | |
7 * | |
8 * $Workfile:: CheckedInterruptedIOException.java $ | |
9 * $Author: dan $ | |
10 * $Revision: 1.1 $ | |
11 * $Date: Mon, 13 Oct 2003 12:20:39 +0100 $ | |
12 */ | |
13 | |
14 package com.go.trove.net; | |
15 | |
16 import java.io.*; | |
17 import java.net.*; | |
18 import java.lang.ref.*; | |
19 | |
20 /****************************************************************************** | |
21 * | |
22 * @author Brian S O'Neill | |
23 * @version | |
24 * <!--$$Revision: 1.1 $-->, <!--$$JustDate:--> 01/01/22 <!-- $--> | |
25 */ | |
26 public class CheckedInterruptedIOException extends InterruptedIOException { | |
27 static CheckedInterruptedIOException create | |
28 (InterruptedIOException cause, Socket source) { | |
29 if (cause instanceof CheckedInterruptedIOException) { | |
30 return (CheckedInterruptedIOException)cause; | |
31 } | |
32 else { | |
33 return new CheckedInterruptedIOException(cause, source); | |
34 } | |
35 } | |
36 | |
37 private InterruptedIOException mCause; | |
38 private String mMessagePrefix; | |
39 private Reference mSource; | |
40 | |
41 private CheckedInterruptedIOException(InterruptedIOException cause, | |
42 Socket source) { | |
43 this(cause, source, cause.getMessage()); | |
44 } | |
45 | |
46 private CheckedInterruptedIOException(InterruptedIOException cause, | |
47 Socket source, String message) { | |
48 super(CheckedSocketException.createMessagePrefix(source) + | |
49 ' ' + message); | |
50 mCause = cause; | |
51 mMessagePrefix = CheckedSocketException.createMessagePrefix(source); | |
52 mSource = new WeakReference(source); | |
53 } | |
54 | |
55 public Throwable getCause() { | |
56 return mCause; | |
57 } | |
58 | |
59 /** | |
60 * Returns null if source socket has been reclaimed by the garbage | |
61 * collector. | |
62 */ | |
63 public Socket getSource() { | |
64 return (Socket)mSource.get(); | |
65 } | |
66 | |
67 public void printStackTrace() { | |
68 printStackTrace(System.err); | |
69 } | |
70 | |
71 public void printStackTrace(PrintStream ps) { | |
72 synchronized (ps) { | |
73 ps.print(mMessagePrefix); | |
74 ps.print(": "); | |
75 mCause.printStackTrace(ps); | |
76 } | |
77 } | |
78 | |
79 public void printStackTrace(PrintWriter pw) { | |
80 synchronized (pw) { | |
81 pw.print(mMessagePrefix); | |
82 pw.print(": "); | |
83 mCause.printStackTrace(pw); | |
84 } | |
85 } | |
86 } |