Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.management
Class TraceListener

    java.lang.Object
      |
      +--com.sun.management.TraceListener

public class TraceListener
extends java.lang.Object
implements NotificationListener

An object of this class can be used to receive events sent out by the class Trace, and all information received will be saved to a file specified, or write to user screen.

Field Summary
`protected boolean` | `formated`
`protected boolean` | `needTobeClosed`
`protected java.io.PrintStream` | `out`

Constructor Summary
`TraceListener()` Construct a default trace listener.
`TraceListener(java.io.PrintStream ps)` Construct a trace listener with a specified output stream without format.
`TraceListener(java.lang.String fileName)` Construct a trace listener with a file specified to save all information received without format.

Method Summary
`void` | `handleNotification(Notification notif, java.lang.Object handback)` Called by the class Trace to get trace information.
`void` | `setFile(java.lang.String fileName)` Specify a file to save information received
`void` | `setFormated(boolean f)` Choose a format to output trace information.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### out

    protected java.io.PrintStream out

### needTobeClosed

    protected boolean needTobeClosed

### formated

    protected boolean formated

Constructor Detail

### TraceListener

    public TraceListener()

  Construct a default trace listener. All information will printed on screen (System.out) without format.

### TraceListener

    public TraceListener(java.io.PrintStream ps)
                  throws java.lang.IllegalArgumentException

  Construct a trace listener with a specified output stream without format.
  Parameters:
    `ps` - a PrintStream object used to print trace information.

    For example, it can take value as System.out or System.err.

    `ps` - An PrintStream object used to print out trace information.
  Throws:
    java.lang.IllegalArgumentException - thrown if the parameter ps is null.

### TraceListener

    public TraceListener(java.lang.String fileName)
                  throws java.io.IOException

  Construct a trace listener with a file specified to save all information received without format.
  Parameters:
    `fileName` - the file used to save information.
  Throws:
    java.io.IOException - thrown if failed to open the file.

Method Detail

### setFormated

    public void setFormated(boolean f)

  Choose a format to output trace information.
  Parameters:
    `f` - if true, all messages will be printed out.

### handleNotification

    public void handleNotification(Notification notif,
                                   java.lang.Object handback)

  Called by the class Trace to get trace information.
  Specified by:
    handleNotification in interface NotificationListener

### setFile

    public void setFile(java.lang.String fileName)
                 throws java.io.IOException

  Specify a file to save information received
  Parameters:
    `fileName` - the file used to save information. It will replace the old file or the PrintStream object setted before.
  Throws:
    java.io.IOException - thrown if failed to open the file.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD