xbn.output
Class OWWrapper

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.output.OWriter
              |
              +--xbn.output.OWWrapper

public abstract class OWWrapper
extends OWriter

The base class for an OWriter that can wrap around objects like java.io.OutputStreams and java.io.Writer. See OutputStream and Writer.

Source code:  OWWrapper.java.


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
OWWrapper()
          Create a OWWrapper with default settings.
OWWrapper(boolean b_autoFlush)
          Create a OWWrapper.
OWWrapper(boolean b_autoFlush, boolean b_suppressFinalizeIOX)
          Create a OWWrapper.
OWWrapper(boolean b_autoFlush, boolean b_closeInFinalize, boolean b_suppressFinalizeIOX)
          Create a OWWrapper.
 
Method Summary
 boolean doAutoFlush()
          Should the [writer/stream] be automatically flushed, after each output?
 boolean doFlushCloseInFinalize()
          Should the [writer/stream] be flushed and closed in finalize?.
 boolean doSuppressFinalizeIOX()
          If an IOException should occur in finalize, should it be suppressed?
protected  void finalize()
          Flush, close and then null the [writer/stream].
abstract  void flush()
          Manually flush the [writer/stream] by calling flush().
abstract  void newln()
          Write a newline only, to the [writer/stream] via println().
 void setAutoFlush(boolean b_autoFlush)
          Define if flush should be called at the end of every write function.
 void setFlushCloseInFinalize(boolean b_closeInFinalize)
          When this class is finalized, should the [writer/stream] be flushed and closed?.
 void setSuppressFinalizeIOX(boolean b_suppressFinalizeIOX)
          Define if an IOException should be suppressed, should one occur in finalize.
abstract  void write(String s_message)
          Write a line of output to the [writer/stream] via println(java.lang.String).
abstract  void writeNoln(String s_message)
          Write a line of output to the [writer/stream] via print(java.lang.String).
 
Methods inherited from class xbn.output.OWriter
isActive
 
Methods inherited from class xbn.XBNObject
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OWWrapper

public OWWrapper()

Create a OWWrapper with default settings.

Equal to OWWrapper(false, false, false)


OWWrapper

public OWWrapper(boolean b_autoFlush)

Create a OWWrapper.

Equal to OWWrapper(b_autoFlush, true)


OWWrapper

public OWWrapper(boolean b_autoFlush,
                 boolean b_suppressFinalizeIOX)

Create a OWWrapper.

Equal to OWWrapper(b_autoFlush, true, b_suppressFinalizeIOX)


OWWrapper

public OWWrapper(boolean b_autoFlush,
                 boolean b_closeInFinalize,
                 boolean b_suppressFinalizeIOX)

Create a OWWrapper.

Parameters:
b_autoFlush - Should the stream be flushed after every output? Passed directly to setAutoFlush.
b_closeInFinalize - Should the [writer/stream] be closed in finalize? Passed directly to setFlushCloseInFinalize.
b_suppressFinalizeIOX - Should IOExceptions in finalize be suppressed? Passed directly to setSuppressFinalizeIOX.
Method Detail

setFlushCloseInFinalize

public final void setFlushCloseInFinalize(boolean b_closeInFinalize)

When this class is finalized, should the [writer/stream] be flushed and closed?. See doFlushCloseInFinalize.

Parameters:
b_closeInFinalize - If true, the [writer/stream] will be closed during finalize. If false, If it will not be closed.

doFlushCloseInFinalize

public boolean doFlushCloseInFinalize()

Should the [writer/stream] be flushed and closed in finalize?. See setFlushCloseInFinalize.

Note that this setting does not affect flushing. No matter what, the stream is flushed, before (potentially) being closed.

Returns:
true If the [writer/stream] will be closed during finalize.
false If it will not be closed.

setAutoFlush

public final void setAutoFlush(boolean b_autoFlush)

Define if flush should be called at the end of every write function.

Get with doSuppressFinalizeIOX

Parameters:
b_suppressFinalizeIOX - If true, do suppress any IOException that should occur in finalize. If false, don't.

setSuppressFinalizeIOX

public final void setSuppressFinalizeIOX(boolean b_suppressFinalizeIOX)

Define if an IOException should be suppressed, should one occur in finalize.

Get with doSuppressFinalizeIOX

Parameters:
b_suppressFinalizeIOX - If true, do suppress IOExceptions that occur in finalize. If false, don't.

doAutoFlush

public boolean doAutoFlush()

Should the [writer/stream] be automatically flushed, after each output?

Set with setAutoFlush

Regardless of this setting, flush is always called in finalize.

Returns:
b_autoFlush exactly as provided to setAutoFlush. If...

doSuppressFinalizeIOX

public boolean doSuppressFinalizeIOX()

If an IOException should occur in finalize, should it be suppressed?

Set with setSuppressFinalizeIOX

Returns:
b_suppressFinalizeIOX exactly as provided to setSuppressFinalizeIOX. If...
  • ...true: If an IOException occurs in the middle of finalize, it is suppressed. In other words, you'll never know the error occurred.
  • ...false: If an IOException occurs in the middle of finalize, throw an AssertException, saying that an IOException was thrown.

write

public abstract void write(String s_message)

Write a line of output to the [writer/stream] via println(java.lang.String).

After output is written, if doAutoFlush equals true, call flush.

Overrides:
write in class OWriter
Parameters:
s_message - The message to output.
Throws:
AssertException - If an IOException is thrown for any reason.

writeNoln

public abstract void writeNoln(String s_message)

Write a line of output to the [writer/stream] via print(java.lang.String).

After output is written, if doAutoFlush equals true, call flush.

Overrides:
writeNoln in class OWriter
Parameters:
s_message - The message to output.
Throws:
AssertException - If an IOException is thrown for any reason.

newln

public abstract void newln()

Write a newline only, to the [writer/stream] via println().

After output is written, if doAutoFlush equals true, call flush.

Overrides:
newln in class OWriter
Parameters:
s_message - The message to output.
Throws:
AssertException - If an IOException is thrown for any reason.

flush

public abstract void flush()

Manually flush the [writer/stream] by calling flush().


finalize

protected void finalize()
                 throws Throwable

Flush, close and then null the [writer/stream].

flush and close (only if doFlushCloseInFinalize equals true).

Note: The OWWrapper version of this function must be overridden by you--in order to actually flush and close the [writer/stream], and you must call this function (via super.finalize()) in your implementation.

Overrides:
finalize in class Object
Throws:
AssertException - If doSuppressFinalizeIOX is true and an IOException is thrown for any reason. Note that java.lang.Object.finalize is definitely called, even in the event of an IOException.



Copyright 1997-2003, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.

 

http://sourceforge.net/projects/xbnjava

 

SourceForge.net Logo