站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 common API Documentation 英文版文档

AutoResetObjectOutputStream (JBoss/Common API) - JBoss 4.0.1 sp1 common API Documentation 英文版文档


org.jboss.util.stream
Class AutoResetObjectOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byjava.io.ObjectOutputStream
          extended byorg.jboss.util.stream.ObjectOutputStreamAdapter
              extended byorg.jboss.util.stream.AutoResetObjectOutputStream
All Implemented Interfaces:
DataOutput, ObjectOutput, ObjectStreamConstants

public class AutoResetObjectOutputStream
extends ObjectOutputStreamAdapter

An ObjectOutputStream that will auto reset after n objects have been written to the underlying stream.

Concurrency

This class is not synchronized.

Version:
$Revision: 1.1 $
Author:
Jason Dillon

Nested Class Summary
 
Nested classes inherited from class java.io.ObjectOutputStream
ObjectOutputStream.PutField
 
Field Summary
protected  int after
          Number of objects to write before resetting.
protected  int count
          Number of objects written so far.
 
Fields inherited from class org.jboss.util.stream.ObjectOutputStreamAdapter
out
 
Fields inherited from interface java.io.ObjectStreamConstants
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING
 
Constructor Summary
AutoResetObjectOutputStream(ObjectOutputStream out, int after)
          Construct a new AutoResetObjectOutputStream.
 
Method Summary
 int getCount()
          Get the number of objects written to the stream so far.
 int getResetAfter()
          Get the number of objects that must be written before resetting the stream.
 void reset()
          Resets the object counter as well as the nested stream.
 void setResetAfter(int after)
          Set the number of objects that must be written before resetting the stream.
protected  void writeObjectOverride(Object obj)
          Write the given object and reset if the number of objects written (including this one) exceeds the after count.
 
Methods inherited from class org.jboss.util.stream.ObjectOutputStreamAdapter
close, defaultWriteObject, flush, putFields, useProtocolVersion, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFields, writeFloat, writeInt, writeLong, writeShort, writeUTF
 
Methods inherited from class java.io.ObjectOutputStream
annotateClass, annotateProxyClass, drain, enableReplaceObject, replaceObject, writeClassDescriptor, writeObject, writeStreamHeader, writeUnshared
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

after

protected int after
Number of objects to write before resetting.


count

protected int count
Number of objects written so far.

Constructor Detail

AutoResetObjectOutputStream

public AutoResetObjectOutputStream(ObjectOutputStream out,
                                   int after)
                            throws IOException
Construct a new AutoResetObjectOutputStream.

Parameters:
out - An ObjectOutputStream stream.
after - Number of objects to write before resetting.
Throws:
IllegalArgumentException - After <= 0
IOException - Any exception thrown by the underlying OutputStream.
Method Detail

setResetAfter

public void setResetAfter(int after)
Set the number of objects that must be written before resetting the stream.

Parameters:
after - Number of objects to write before resetting.
Throws:
IllegalArgumentException - After <= 0

getResetAfter

public final int getResetAfter()
Get the number of objects that must be written before resetting the stream.

Returns:
Number of objects to write before resetting.

getCount

public final int getCount()
Get the number of objects written to the stream so far.

Returns:
The number of objects written to the stream so far.

writeObjectOverride

protected void writeObjectOverride(Object obj)
                            throws IOException
Write the given object and reset if the number of objects written (including this one) exceeds the after count.

Overrides:
writeObjectOverride in class ObjectOutputStreamAdapter
Parameters:
obj - Object to write.
Throws:
IOException - Any exception thrown by the underlying stream.

reset

public void reset()
           throws IOException
Resets the object counter as well as the nested stream.

Overrides:
reset in class ObjectOutputStreamAdapter
Throws:
IOException


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.