Package com.gargoylesoftware.base.trace
Class TraceChannel
- java.lang.Object
-
- com.gargoylesoftware.base.trace.TraceChannel
-
public class TraceChannel extends java.lang.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 $
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
isEnabled_
private java.lang.String
name_
private java.beans.PropertyChangeSupport
propertyChangeSupport_
private java.util.Set
traceWriters_
-
Constructor Summary
Constructors Constructor Description TraceChannel(java.lang.String name)
Create a trace channel with the specified name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a property change listener.void
addTraceWriter(TraceWriter writer)
Add a trace writer.protected void
assertNotNull(java.lang.String fieldName, java.lang.Object fieldValue)
Verify that the specified value is not null.java.lang.String
getName()
Return the name of this trace channel.(package private) java.util.Set
getTraceWriters()
Return a collection of trace writersboolean
isEnabled()
Return true if this channel is enabled.void
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a property change listener.void
removeTraceWriter(TraceWriter writer)
Remove a trace writer.void
setEnabled(boolean isEnabled)
Set whether or not this channel is enabled.java.lang.String
toString()
Return a string representation of this object.
-
-
-
Method Detail
-
getName
public final java.lang.String getName()
Return the name of this trace channel.- Returns:
- the name.
-
toString
public java.lang.String toString()
Return a string representation of this object.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of this object.
-
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.
-
isEnabled
public boolean isEnabled()
Return true if this channel is enabled.- Returns:
- true if this channel is enabled.
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a property change listener.- Parameters:
listener
- The new listener
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a property change listener.- Parameters:
listener
- The listener to remove
-
getTraceWriters
java.util.Set getTraceWriters()
Return a collection of trace writers- Returns:
- The trace writers
-
addTraceWriter
public void addTraceWriter(TraceWriter writer)
Add a trace writer.- Parameters:
writer
- A trace writer
-
removeTraceWriter
public void removeTraceWriter(TraceWriter writer)
Remove a trace writer.- Parameters:
writer
- A trace writer
-
assertNotNull
protected final void assertNotNull(java.lang.String fieldName, java.lang.Object fieldValue) throws DetailedNullPointerException
Verify that the specified value is not null. If it is then throw an exception- Parameters:
fieldName
- The name of the field to checkfieldValue
- The value of the field to check- Throws:
DetailedNullPointerException
- If fieldValue is null
-
-