Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

oracle.adfnmc.java.util.logging
Class StreamHandler

java.lang.Object
  extended by oracle.adfnmc.java.util.logging.Handler
      extended by oracle.adfnmc.java.util.logging.StreamHandler
Direct Known Subclasses:
ConsoleHandler, FileHandler

public class StreamHandler
extends Handler

A StreamHandler object writes log messages to an output stream, that is, an object of type java.io.OutputStream.

A StreamHandler reads the following properties from the log manager to initialize itself:

This class is not thread-safe.


Field Summary
 
Fields inherited from class oracle.adfnmc.java.util.logging.Handler
prefix
 
Constructor Summary
StreamHandler()
          Constructs a StreamHandler object.
StreamHandler(java.io.OutputStream os, Formatter formatter)
          Constructs a StreamHandler object with the supplied output stream and formatter.
 
Method Summary
 void close()
          Closes this handler.
 void flush()
          Flushes any buffered output.
 boolean isLoggable(LogRecord record)
          Determines whether the supplied log record need to be logged.
 void publish(LogRecord record)
          Accepts an actual logging request.
 void setEncoding(java.lang.String encoding)
          Sets the character encoding used by this handler.
protected  void setOutputStream(java.io.OutputStream os)
          Sets the output stream this handler writes to.
 
Methods inherited from class oracle.adfnmc.java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, reportError, setErrorManager, setFilter, setFormatter, setLevel, setPrefix
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamHandler

public StreamHandler()
Constructs a StreamHandler object. The new stream handler does not have an associated output stream.


StreamHandler

public StreamHandler(java.io.OutputStream os,
                     Formatter formatter)
Constructs a StreamHandler object with the supplied output stream and formatter.

Parameters:
os - the output stream this handler writes to
formatter - the formatter this handler uses to format the output
Method Detail

setOutputStream

protected void setOutputStream(java.io.OutputStream os)
Sets the output stream this handler writes to. If there's an existing output stream, the tail string of the associated formatter will be written to it. Then it will be flushed and closed.

Parameters:
os - the new output stream
Throws:
java.lang.SecurityException - If a security manager determines that the caller does not have the required permission.

setEncoding

public void setEncoding(java.lang.String encoding)
                 throws java.lang.SecurityException,
                        java.io.UnsupportedEncodingException
Sets the character encoding used by this handler. A null value indicates the using of the default encoding.

Overrides:
setEncoding in class Handler
Parameters:
encoding - the character encoding to set
Throws:
java.lang.SecurityException - If a security manager determines that the caller does not have the required permission.
java.io.UnsupportedEncodingException - If the specified encoding is not supported by the runtime.

close

public void close()
Closes this handler. The tail string of the formatter associated with this handler will be written out. A flush operation a subsequent close operation will then be performed upon the outputstream. Client applications should not use a handler after closing it.

Specified by:
close in class Handler
Throws:
java.lang.SecurityException - If a security manager determines that the caller does not have the required permission.

flush

public void flush()
Flushes any buffered output.

Specified by:
flush in class Handler

publish

public void publish(LogRecord record)
Accepts an actual logging request. The log record will be formatted and written to the output stream if the following three conditions are met: If it is the first time a log record need to be written out, the head string of the formatter associated with this handler will be written out first.

Specified by:
publish in class Handler
Parameters:
record - the log record to be logged

isLoggable

public boolean isLoggable(LogRecord record)
Determines whether the supplied log record need to be logged. The logging levels will be checked as well as the filter. The output stream of this handler is also checked. If it's null, this method returns false.

Overrides:
isLoggable in class Handler
Parameters:
record - the log record to be checked
Returns:
true if the supplied log record need to be logged, otherwise false

Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.