java.lang.Object
com.telenav.kivakit.core.messaging.broadcasters.Multicaster
com.telenav.kivakit.core.messaging.repeaters.BaseRepeater
com.telenav.kivakit.conversion.BaseConverter<From,To>
- Type Parameters:
From
- The type to convert fromTo
- The type to convert to
- All Implemented Interfaces:
Converter<From,
,To> Broadcaster
,Listener
,Repeater
,Transceiver
,Receiver
,Transmitter
,NamedObject
- Direct Known Subclasses:
BaseStringConverter
,BaseTwoWayConverter
,ObjectConverter
Base class for implementing converters. The inherited
Converter.convert(Object)
method converts from the
'From' type to the To type. Whether the conversion allows null values or not can be specified with allowNull(boolean)
. Converters are used extensively in KivaKit for tasks as diverse as switch parsing and
populating objects from properties files.
Since this class extends BaseRepeater
and implements the Repeater
interface, it can both hear
messages broadcast by sub-converters and broadcast messages about the conversion itself.
For example, if there is a problem with a conversion, Transceiver.problem(String, Object...)
(which Repeater
indirectly extends) can broadcast a Problem
message to any clients of the converter. Similarly
Warning
and Glitch
messages can be broadcast with Transceiver.warning(String, Object...)
and Transceiver.glitch(String, Object...)
.
- Author:
- jonathanl (shibo)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class com.telenav.kivakit.core.messaging.repeaters.BaseRepeater
onMessage, onReceive
Methods inherited from class com.telenav.kivakit.core.messaging.broadcasters.Multicaster
addListener, clearListeners, debugClassContext, debugCodeContext, debugCodeContext, hasListeners, isDeaf, isTransmitting, listenerChain, listeners, listenerTree, messageSource, messageSource, objectName, removeListener, transmit, withoutTransmitting
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.telenav.kivakit.core.messaging.Broadcaster
addListener, addListener, clearListeners, copyListeners, hasListeners, listeners, messageSource, messageSource, onTransmit, onTransmitted, onTransmitting, removeListener, silence, transmit, transmit, transmitAll
Methods inherited from interface com.telenav.kivakit.conversion.Converter
convertOrDefault, join, join
Methods inherited from interface com.telenav.kivakit.core.messaging.Listener
isDeaf, listenTo, listenTo, onMessage
Methods inherited from interface com.telenav.kivakit.interfaces.naming.NamedObject
hasSyntheticName, objectName, objectName
Methods inherited from interface com.telenav.kivakit.interfaces.messaging.Receiver
isReceiving
Methods inherited from interface com.telenav.kivakit.core.messaging.Repeater
isRepeating, onReceive, receive
Methods inherited from interface com.telenav.kivakit.core.messaging.Transceiver
announce, debug, debugClassContext, debugCodeContext, debugCodeContext, fatal, fatal, glitch, glitch, glitch, glitch, halted, halted, ifDebug, illegalArgument, illegalState, illegalState, information, isDebugOn, narrate, problem, problem, problem, problem, problemIfNull, quibble, quibble, quibble, quibble, trace, trace, trace, trace, warning, warning, warning, warning
Methods inherited from interface com.telenav.kivakit.interfaces.messaging.Transmitter
isTransmitting, withoutTransmitting
-
Constructor Details
-
Method Details
-
allowNull
- Parameters:
allowNull
- True if null values should be converted to null
-
allowsNull
public boolean allowsNull()- Returns:
- True if this converter allows null values, false if a problem will be broadcast when a null value is encountered.
-
convert
Converts from the <From> type to the <To> type. If the 'from' value is null and the converter allows null values, null will be returned. If the value is null and the converter does not allow null values a problem will be broadcast. Any exceptions that occur during conversion are caught and broadcast as problems. -
onConvert
The method to override to provide the conversion -
problemBroadcastFrequency
- Returns:
- The maximum
Frequency
to broadcast problems at, for example, every minute or once an hour
-
subclass
-