1 21 22 package org.apache.derby.client.am; 23 24 import java.io.InputStream ; 25 import java.io.FilterInputStream ; 26 27 import java.io.IOException ; 28 import org.apache.derby.shared.common.i18n.MessageUtil; 29 import org.apache.derby.shared.common.reference.MessageId; 30 31 class CloseFilterInputStream extends FilterInputStream { 32 33 private static final String ALREADY_CLOSED_ERR_MESSAGE = 34 SqlException.getMessageUtil().getTextMessage( 35 MessageId.CONN_ALREADY_CLOSED); 36 37 private boolean closed; 38 39 public CloseFilterInputStream(InputStream is){ 40 41 super(is); 42 closed = false; 43 44 } 45 46 47 public int read() 48 throws IOException { 49 50 if(closed){ 51 throw new IOException (ALREADY_CLOSED_ERR_MESSAGE); 52 } 53 54 return super.read(); 55 56 } 57 58 59 public int read(byte[] b) 60 throws IOException { 61 62 if(closed){ 63 throw new IOException (ALREADY_CLOSED_ERR_MESSAGE); 64 } 65 66 return super.read(b); 67 68 } 69 70 71 public int read(byte[] b, 72 int off, 73 int len) 74 throws IOException { 75 76 if(closed){ 77 throw new IOException (ALREADY_CLOSED_ERR_MESSAGE); 78 } 79 80 return super.read(b, off, len); 81 82 } 83 84 85 public long skip(long n) 86 throws IOException { 87 88 if(closed){ 89 throw new IOException (ALREADY_CLOSED_ERR_MESSAGE); 90 } 91 92 return super.skip(n); 93 94 } 95 96 97 public int available() 98 throws IOException { 99 100 if(closed){ 101 throw new IOException (ALREADY_CLOSED_ERR_MESSAGE); 102 } 103 104 return super.available(); 105 106 } 107 108 109 public void close() 110 throws IOException { 111 112 super.close(); 113 closed = true; 114 115 } 116 117 118 } 119 | Popular Tags |