|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.tm4j.topicmap.utils.HelperBase
Abstract base class for bean-like helper classes. Provides support
for both vetoable and non-vetoable property change interaction,
and for logging. When subclassing this class, it is highly recommended
to put any initialization routines into the init()
, method,
rather than into the subclass constructor. See HelperBase()
and init()
for details.
This class and all its subclasses support at least one bound property,
"logger", which represents the jakarta-commons Log
that
is to receive and dispatch logging messages. This may be
set using setLogger(Log)
.
Changes to this bound property are vetoable and may be rolled
back by a registered VetoableChangeListener
. For additional
properties which a subclass may support, please refer to the
subclass documentation.
Constructor Summary | |
HelperBase()
Default no-arg constructor. |
Method Summary | |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a new listener for non-vetoable property changes. |
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Adds a new listener for non-vetoable changes to a specific property. |
void |
addVetoableChangeListener(java.lang.String propertyName,
java.beans.VetoableChangeListener listener)
Adds a new listener for vetoable changes to a specific property. |
void |
addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Adds a new listener for vetoable property changes. |
protected void |
debug(java.lang.Object message)
Logs a message using a logging level of "debug". |
protected void |
error(java.lang.Object message)
Logs a message using a logging level of "error". |
protected void |
error(java.lang.Object message,
java.lang.Throwable t)
Logs a message, and information concerning an error or exception, using a logging level of "error". |
protected void |
fatal(java.lang.Object message)
Logs a message using a logging level of "fatal". |
protected void |
fatal(java.lang.Object message,
java.lang.Throwable t)
Logs a message, and information concerning an error or exception, using a logging level of "fatal". |
protected void |
firePropertyChange(java.lang.String propertyName,
boolean oldValue,
boolean newValue)
Notifies registered PropertyChangeListener s
that a non-vetoable change to a property has occurred. |
protected void |
firePropertyChange(java.lang.String propertyName,
int oldValue,
int newValue)
Notifies registered PropertyChangeListener s
that a non-vetoable change to a property has occurred. |
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Notifies registered PropertyChangeListener s
that a non-vetoable change to a property has occurred. |
protected void |
fireVetoableChange(java.lang.String propertyName,
boolean oldValue,
boolean newValue)
Notifies registered VetoableChangeListener s
that a vetoable change to a property has occurred. |
protected void |
fireVetoableChange(java.lang.String propertyName,
int oldValue,
int newValue)
Notifies registered VetoableChangeListener s
that a vetoable change to a property has occurred. |
protected void |
fireVetoableChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Notifies registered VetoableChangeListener s
that a vetoable change to a property has occurred. |
protected org.apache.commons.logging.Log |
getLogger()
Retrieves the registered logger. |
protected boolean |
hasLogger()
Determines if the current instance has a registered logger. |
protected void |
info(java.lang.Object message)
Logs a message using a logging level of "info". |
protected abstract void |
init()
Initializes the instance. |
protected void |
logVetoedChange(java.beans.PropertyVetoException exc)
Logs a message about an attempted property change that has been vetoed by a registered VetoableChangeListener , and
has therefore been rolled back. |
void |
removeLogger()
Removes (unregisters) a registered logger. |
void |
setLogger(org.apache.commons.logging.Log newLogger)
Registers a logger. |
void |
trace(java.lang.Object message)
Logs a message using a logging level of "trace". |
protected void |
warn(java.lang.Object message)
Logs a message using a logging level of "warn". |
protected void |
warn(java.lang.Object message,
java.lang.Throwable t)
Logs a message, and information concerning an error or exception, using a logging level of "warn". |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public HelperBase()
init()
. Any exceptions
thrown by init()
are caught and cause a
RuntimeException
to be thrown, with specific information
about the exception being logged at the "fatal" level.
Subclasses should ensure that their own no-arg
constructors invoke super()
to ensure proper
initialization. However, it is a better idea to override
init()
, which is invoked by the default constructor,
than to provide a subclass no-arg constructor.
java.lang.RuntimeException
- if the subclass-specific initialization
fails.Method Detail |
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- the new listener to be registered.public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
propertyName
- the property which the listener monitors for changes.listener
- the new listener to be registered.public void addVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)
propertyName
- the property which the listener monitors for changes.listener
- the new listener to be registered.public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- the new listener to be registered.protected void debug(java.lang.Object message)
setLogger(Log)
method.
message
- the message being loggedprotected void error(java.lang.Object message)
setLogger(Log)
method.
message
- the message being loggedprotected void error(java.lang.Object message, java.lang.Throwable t)
setLogger(Log)
method.
message
- the message being loggedt
- the error condition being loggedprotected void fatal(java.lang.Object message)
System.err
. You can register a logger
using the setLogger(Log)
method.
message
- the message being loggedprotected void fatal(java.lang.Object message, java.lang.Throwable t)
System.err
. You can register a logger
using the setLogger(Log)
method.
message
- the message being loggedt
- the error condition being loggedprotected void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
PropertyChangeListener
s
that a non-vetoable change to a property has occurred.
propertyName
- the string identifying the property.oldValue
- the original property value.newValue
- the new property value.protected void firePropertyChange(java.lang.String propertyName, int oldValue, int newValue)
PropertyChangeListener
s
that a non-vetoable change to a property has occurred.
propertyName
- the string identifying the property.oldValue
- the original property value.newValue
- the new property value.protected void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
PropertyChangeListener
s
that a non-vetoable change to a property has occurred.
propertyName
- the string identifying the property.oldValue
- the original property value.newValue
- the new property value.protected void fireVetoableChange(java.lang.String propertyName, boolean oldValue, boolean newValue) throws java.beans.PropertyVetoException
VetoableChangeListener
s
that a vetoable change to a property has occurred. Note that if the
change is not vetoed, any registered PropertyChangeListener
s
are notified of the property change as well.
propertyName
- the string identifying the property.oldValue
- the original property value.newValue
- the new property value.
java.beans.PropertyVetoException
- signifies that a registered
VetoableChangeListener
has requested that the change be rolled
back.protected void fireVetoableChange(java.lang.String propertyName, int oldValue, int newValue) throws java.beans.PropertyVetoException
VetoableChangeListener
s
that a vetoable change to a property has occurred. Note that if the
change is not vetoed, any registered PropertyChangeListener
s
are notified of the property change as well.
propertyName
- the string identifying the property.oldValue
- the original property value.newValue
- the new property value.
java.beans.PropertyVetoException
- signifies that a registered
VetoableChangeListener
has requested that the change be rolled
back.protected void fireVetoableChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue) throws java.beans.PropertyVetoException
VetoableChangeListener
s
that a vetoable change to a property has occurred. Note that if the
change is not vetoed, any registered PropertyChangeListener
s
are notified of the property change as well.
propertyName
- the string identifying the property.oldValue
- the original property value.newValue
- the new property value.
java.beans.PropertyVetoException
- signifies that a registered
VetoableChangeListener
has requested that the change be rolled
back.protected org.apache.commons.logging.Log getLogger()
Log
, or null
if
no logger has been registered.protected boolean hasLogger()
true
if the instance is currently configured
for logging, false otherwise.protected void info(java.lang.Object message)
setLogger(Log)
method.
message
- the message being loggedprotected abstract void init() throws java.lang.Exception
java.lang.Exception
- if the initialization fails.protected void logVetoedChange(java.beans.PropertyVetoException exc)
VetoableChangeListener
, and
has therefore been rolled back.
The message is logged at the "warn" level.
exc
- the PropertyVetoException
a VetoableChangeListener
threw when it deemed a particular property change inappropriate or invalid.public void removeLogger()
setLogger(null)
.
public void setLogger(org.apache.commons.logging.Log newLogger)
VetoableChangeListener
may determine that the property change is inappropriate or invalid,
and ask for it to be rolled back. In that case, the property's
original value is restored, and a warning is issued to the
originally registered logger.
newLogger
- the jakarta-commons Log
to register.public void trace(java.lang.Object message)
setLogger(Log)
method.
message
- the message being loggedprotected void warn(java.lang.Object message)
setLogger(Log)
method.
message
- the message being loggedprotected void warn(java.lang.Object message, java.lang.Throwable t)
setLogger(Log)
method.
message
- the message being loggedt
- the error condition being logged
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |