com.gargoylesoftware.base.trace

Class TraceChannel

public class TraceChannel extends Object

This class represents a "channel" that diagnostic messages can be written to. The channel will contain zero or more TraceWriters which will be responsible for handling the messages.

Version: $Revision: 1.3 $

Author: Mike Bowler

Field Summary
booleanisEnabled_
Stringname_
PropertyChangeSupportpropertyChangeSupport_
SettraceWriters_
Constructor Summary
TraceChannel(String name)
Create a trace channel with the specified name.
Method Summary
voidaddPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener.
voidaddTraceWriter(TraceWriter writer)
Add a trace writer.
protected voidassertNotNull(String fieldName, Object fieldValue)
Verify that the specified value is not null.
StringgetName()
Return the name of this trace channel.
SetgetTraceWriters()
Return a collection of trace writers
booleanisEnabled()
Return true if this channel is enabled.
voidremovePropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener.
voidremoveTraceWriter(TraceWriter writer)
Remove a trace writer.
voidsetEnabled(boolean isEnabled)
Set whether or not this channel is enabled.
StringtoString()
Return a string representation of this object.

Field Detail

isEnabled_

private boolean isEnabled_

name_

private final String name_

propertyChangeSupport_

private PropertyChangeSupport propertyChangeSupport_

traceWriters_

private final Set traceWriters_

Constructor Detail

TraceChannel

public TraceChannel(String name)
Create a trace channel with the specified name.

Parameters: name The name of the channel.

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener.

Parameters: listener The new listener

addTraceWriter

public void addTraceWriter(TraceWriter writer)
Add a trace writer.

Parameters: writer A trace writer

assertNotNull

protected final void assertNotNull(String fieldName, Object fieldValue)
Verify that the specified value is not null. If it is then throw an exception

Parameters: fieldName The name of the field to check fieldValue The value of the field to check

Throws: DetailedNullPointerException If fieldValue is null

getName

public final String getName()
Return the name of this trace channel.

Returns: the name.

getTraceWriters

Set getTraceWriters()
Return a collection of trace writers

Returns: The trace writers

isEnabled

public boolean isEnabled()
Return true if this channel is enabled.

Returns: true if this channel is enabled.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener.

Parameters: listener The listener to remove

removeTraceWriter

public void removeTraceWriter(TraceWriter writer)
Remove a trace writer.

Parameters: writer A trace writer

setEnabled

public void setEnabled(boolean isEnabled)
Set whether or not this channel is enabled. If it is not enabled then any requests sent to this channel will be discarded.

Parameters: isEnabled true if this channel should be enabled.

toString

public String toString()
Return a string representation of this object.

Returns: a string representation of this object.