1 13 14 package com.go.trove.net; 15 16 import java.io.*; 17 import java.net.*; 18 import java.lang.ref.*; 19 20 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 InterruptedIOException getCause() { 56 return mCause; 57 } 58 59 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 } 87 | Popular Tags |