クラス org.objectweb.cjdbc.common.util.LoggingOutputStream

すべてのメンバ一覧

説明

An OutputStream that flushes out to a Category.

Note that no data is written out to the Category until the stream is flushed or closed.

作者:
Jim Moore

Nicolas Modrzyk

参照:
Category

LoggingOutputStream.java45 行で定義されています。

Public メソッド

 LoggingOutputStream (Category cat, Priority priority) throws IllegalArgumentException
void close ()
void write (final int b) throws IOException
void flush ()

Static Public 変数

final int DEFAULT_BUFFER_LENGTH = 2048

Protected 変数

boolean hasBeenClosed = false
byte[] buf
int count
Category category
Priority priority

Static Protected 変数

final String LINE_SEPERATOR

Private メソッド

 LoggingOutputStream ()
void reset ()

Private 変数

int bufLength


コンストラクタとデストラクタ

org.objectweb.cjdbc.common.util.LoggingOutputStream.LoggingOutputStream  )  [private]
 

LoggingOutputStream.java80 行で定義されています。

00081 { 00082 // illegal 00083 }

org.objectweb.cjdbc.common.util.LoggingOutputStream.LoggingOutputStream Category  cat,
Priority  priority
throws IllegalArgumentException
 

Creates the LoggingOutputStream to flush to the given Category.

引数:
cat the Category to write to
priority the Priority to use when writing to the Category
例外:
IllegalArgumentException if cat == null or priority == null
LoggingOutputStream.java92 行で定義されています。

参照先 org.objectweb.cjdbc.common.util.LoggingOutputStream.buf, org.objectweb.cjdbc.common.util.LoggingOutputStream.bufLength, org.objectweb.cjdbc.common.util.LoggingOutputStream.category, org.objectweb.cjdbc.common.util.LoggingOutputStream.count, org.objectweb.cjdbc.common.util.LoggingOutputStream.DEFAULT_BUFFER_LENGTH, と org.objectweb.cjdbc.common.util.LoggingOutputStream.priority.

00094 { 00095 if (cat == null) 00096 { 00097 throw new IllegalArgumentException("cat == null"); 00098 } 00099 if (priority == null) 00100 { 00101 throw new IllegalArgumentException("priority == null"); 00102 } 00103 this.priority = priority; 00104 category = cat; 00105 bufLength = DEFAULT_BUFFER_LENGTH; 00106 buf = new byte[DEFAULT_BUFFER_LENGTH]; 00107 count = 0; 00108 }


メソッド

void org.objectweb.cjdbc.common.util.LoggingOutputStream.close  ) 
 

Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened. LoggingOutputStream.java116 行で定義されています。

参照先 org.objectweb.cjdbc.common.util.LoggingOutputStream.flush(), と org.objectweb.cjdbc.common.util.LoggingOutputStream.hasBeenClosed.

00117 { 00118 flush(); 00119 hasBeenClosed = true; 00120 }

void org.objectweb.cjdbc.common.util.LoggingOutputStream.flush  ) 
 

Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination. LoggingOutputStream.java164 行で定義されています。

参照先 org.objectweb.cjdbc.common.util.LoggingOutputStream.buf, org.objectweb.cjdbc.common.util.LoggingOutputStream.category, org.objectweb.cjdbc.common.util.LoggingOutputStream.count, org.objectweb.cjdbc.common.util.LoggingOutputStream.LINE_SEPERATOR, org.objectweb.cjdbc.common.util.LoggingOutputStream.priority, と org.objectweb.cjdbc.common.util.LoggingOutputStream.reset().

参照元 org.objectweb.cjdbc.common.util.LoggingOutputStream.close().

00165 { 00166 if (count == 0) 00167 { 00168 return; 00169 } 00170 // don't print out blank lines; flushing from PrintStream puts out these 00171 if (count == LINE_SEPERATOR.length()) 00172 { 00173 if (((char) buf[0]) == LINE_SEPERATOR.charAt(0) && ((count == 1) || // <- 00174 // Unix 00175 // & 00176 // Mac, 00177 // -> 00178 // Windows 00179 ((count == 2) && ((char) buf[1]) == LINE_SEPERATOR.charAt(1)))) 00180 { 00181 reset(); 00182 return; 00183 } 00184 } 00185 final byte[] theBytes = new byte[count]; 00186 System.arraycopy(buf, 0, theBytes, 0, count); 00187 00188 // ADDED: We don't want blank lines at all 00189 String bytes = new String(theBytes).trim(); 00190 int line = -1; 00191 while((line = bytes.indexOf(LINE_SEPERATOR))!=-1) 00192 { 00193 bytes = bytes.substring(0, line) + bytes.substring(line+LINE_SEPERATOR.length()); 00194 } 00195 // END ADDED 00196 00197 category.log(priority, bytes); 00198 reset(); 00199 }

void org.objectweb.cjdbc.common.util.LoggingOutputStream.reset  )  [private]
 

LoggingOutputStream.java201 行で定義されています。

参照先 org.objectweb.cjdbc.common.util.LoggingOutputStream.count.

参照元 org.objectweb.cjdbc.common.util.LoggingOutputStream.flush().

00202 { 00203 // not resetting the buffer -- assuming that if it grew that it 00204 // will likely grow similarly again 00205 count = 0; 00206 }

void org.objectweb.cjdbc.common.util.LoggingOutputStream.write final int  b  )  throws IOException
 

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

引数:
b the byte to write
例外:
IOException if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
LoggingOutputStream.java132 行で定義されています。

参照先 org.objectweb.cjdbc.common.util.LoggingOutputStream.buf, org.objectweb.cjdbc.common.util.LoggingOutputStream.bufLength, org.objectweb.cjdbc.common.util.LoggingOutputStream.count, org.objectweb.cjdbc.common.util.LoggingOutputStream.DEFAULT_BUFFER_LENGTH, と org.objectweb.cjdbc.common.util.LoggingOutputStream.hasBeenClosed.

00133 { 00134 if (hasBeenClosed) 00135 { 00136 throw new IOException("The stream has been closed."); 00137 } 00138 // don't log nulls 00139 if (b == 0) 00140 { 00141 return; 00142 } 00143 // would this be writing past the buffer? 00144 if (count == bufLength) 00145 { 00146 // grow the buffer 00147 final int newBufLength = bufLength + DEFAULT_BUFFER_LENGTH; 00148 final byte[] newBuf = new byte[newBufLength]; 00149 System.arraycopy(buf, 0, newBuf, 0, bufLength); 00150 buf = newBuf; 00151 bufLength = newBufLength; 00152 } 00153 buf[count] = (byte) b; 00154 count++; 00155 }


変数

byte [] org.objectweb.cjdbc.common.util.LoggingOutputStream.buf [protected]
 

The internal buffer where data is stored. LoggingOutputStream.java56 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.LoggingOutputStream.flush(), org.objectweb.cjdbc.common.util.LoggingOutputStream.LoggingOutputStream(), と org.objectweb.cjdbc.common.util.LoggingOutputStream.write().

int org.objectweb.cjdbc.common.util.LoggingOutputStream.bufLength [private]
 

Remembers the size of the buffer for speed. LoggingOutputStream.java66 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.LoggingOutputStream.LoggingOutputStream(), と org.objectweb.cjdbc.common.util.LoggingOutputStream.write().

Category org.objectweb.cjdbc.common.util.LoggingOutputStream.category [protected]
 

The category to write to. LoggingOutputStream.java74 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.LoggingOutputStream.flush(), と org.objectweb.cjdbc.common.util.LoggingOutputStream.LoggingOutputStream().

int org.objectweb.cjdbc.common.util.LoggingOutputStream.count [protected]
 

The number of valid bytes in the buffer. This value is always in the range 0 through buf.length; elements buf[0] through buf[count-1] contain valid byte data. LoggingOutputStream.java62 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.LoggingOutputStream.flush(), org.objectweb.cjdbc.common.util.LoggingOutputStream.LoggingOutputStream(), org.objectweb.cjdbc.common.util.LoggingOutputStream.reset(), と org.objectweb.cjdbc.common.util.LoggingOutputStream.write().

final int org.objectweb.cjdbc.common.util.LoggingOutputStream.DEFAULT_BUFFER_LENGTH = 2048 [static]
 

The default number of bytes in the buffer. =2048 LoggingOutputStream.java70 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.LoggingOutputStream.LoggingOutputStream(), と org.objectweb.cjdbc.common.util.LoggingOutputStream.write().

boolean org.objectweb.cjdbc.common.util.LoggingOutputStream.hasBeenClosed = false [protected]
 

Used to maintain the contract of close(). LoggingOutputStream.java52 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.LoggingOutputStream.close(), と org.objectweb.cjdbc.common.util.LoggingOutputStream.write().

final String org.objectweb.cjdbc.common.util.LoggingOutputStream.LINE_SEPERATOR [static, protected]
 

初期値:

System .getProperty("line.separator")
LoggingOutputStream.java47 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.LoggingOutputStream.flush().

Priority org.objectweb.cjdbc.common.util.LoggingOutputStream.priority [protected]
 

The priority to use when writing to the Category. LoggingOutputStream.java78 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.LoggingOutputStream.flush(), と org.objectweb.cjdbc.common.util.LoggingOutputStream.LoggingOutputStream().


このクラスの説明は次のファイルから生成されました:
CJDBCversion1.0.4に対してTue Oct 12 15:16:19 2004に生成されました。 doxygen 1.3.8