public final class ConverterManager extends Object
This class enables additional conversion classes to be added via
addInstantConverter(InstantConverter)
, which may replace an
existing converter. Similar methods exist for duration, time period and
interval converters.
This class is threadsafe, so adding/removing converters can be done at any time. Updating the set of converters is relatively expensive, and so should not be performed often.
The default instant converters are:
Modifier | Constructor and Description |
---|---|
protected |
ConverterManager()
Restricted constructor.
|
Modifier and Type | Method and Description |
---|---|
DurationConverter |
addDurationConverter(DurationConverter converter)
Adds a converter to the set of converters.
|
InstantConverter |
addInstantConverter(InstantConverter converter)
Adds a converter to the set of converters.
|
IntervalConverter |
addIntervalConverter(IntervalConverter converter)
Adds a converter to the set of converters.
|
PartialConverter |
addPartialConverter(PartialConverter converter)
Adds a converter to the set of converters.
|
PeriodConverter |
addPeriodConverter(PeriodConverter converter)
Adds a converter to the set of converters.
|
DurationConverter |
getDurationConverter(Object object)
Gets the best converter for the object specified.
|
DurationConverter[] |
getDurationConverters()
Gets a copy of the list of converters.
|
static ConverterManager |
getInstance() |
InstantConverter |
getInstantConverter(Object object)
Gets the best converter for the object specified.
|
InstantConverter[] |
getInstantConverters()
Gets a copy of the set of converters.
|
IntervalConverter |
getIntervalConverter(Object object)
Gets the best converter for the object specified.
|
IntervalConverter[] |
getIntervalConverters()
Gets a copy of the list of converters.
|
PartialConverter |
getPartialConverter(Object object)
Gets the best converter for the object specified.
|
PartialConverter[] |
getPartialConverters()
Gets a copy of the set of converters.
|
PeriodConverter |
getPeriodConverter(Object object)
Gets the best converter for the object specified.
|
PeriodConverter[] |
getPeriodConverters()
Gets a copy of the list of converters.
|
DurationConverter |
removeDurationConverter(DurationConverter converter)
Removes a converter from the set of converters.
|
InstantConverter |
removeInstantConverter(InstantConverter converter)
Removes a converter from the set of converters.
|
IntervalConverter |
removeIntervalConverter(IntervalConverter converter)
Removes a converter from the set of converters.
|
PartialConverter |
removePartialConverter(PartialConverter converter)
Removes a converter from the set of converters.
|
PeriodConverter |
removePeriodConverter(PeriodConverter converter)
Removes a converter from the set of converters.
|
String |
toString()
Gets a debug representation of the object.
|
public static ConverterManager getInstance()
public InstantConverter getInstantConverter(Object object)
object
- the object to convertIllegalArgumentException
- if no suitable converterIllegalStateException
- if multiple converters match the type
equally wellpublic InstantConverter[] getInstantConverters()
public InstantConverter addInstantConverter(InstantConverter converter) throws SecurityException
The order in which converters are added is not relevant. The best converter is selected by examining the object hierarchy.
converter
- the converter to add, null ignoredSecurityException
- if the security manager rejects the changepublic InstantConverter removeInstantConverter(InstantConverter converter) throws SecurityException
converter
- the converter to remove, null ignoredSecurityException
- if the security manager rejects the changepublic PartialConverter getPartialConverter(Object object)
object
- the object to convertIllegalArgumentException
- if no suitable converterIllegalStateException
- if multiple converters match the type
equally wellpublic PartialConverter[] getPartialConverters()
public PartialConverter addPartialConverter(PartialConverter converter) throws SecurityException
The order in which converters are added is not relevant. The best converter is selected by examining the object hierarchy.
converter
- the converter to add, null ignoredSecurityException
- if the security manager rejects the changepublic PartialConverter removePartialConverter(PartialConverter converter) throws SecurityException
converter
- the converter to remove, null ignoredSecurityException
- if the security manager rejects the changepublic DurationConverter getDurationConverter(Object object)
object
- the object to convertIllegalArgumentException
- if no suitable converterIllegalStateException
- if multiple converters match the type
equally wellpublic DurationConverter[] getDurationConverters()
public DurationConverter addDurationConverter(DurationConverter converter) throws SecurityException
The order in which converters are added is not relevant. The best converter is selected by examining the object hierarchy.
converter
- the converter to add, null ignoredSecurityException
- if the security manager rejects the changepublic DurationConverter removeDurationConverter(DurationConverter converter) throws SecurityException
converter
- the converter to remove, null ignoredSecurityException
- if the security manager rejects the changepublic PeriodConverter getPeriodConverter(Object object)
object
- the object to convertIllegalArgumentException
- if no suitable converterIllegalStateException
- if multiple converters match the type
equally wellpublic PeriodConverter[] getPeriodConverters()
public PeriodConverter addPeriodConverter(PeriodConverter converter) throws SecurityException
The order in which converters are added is not relevant. The best converter is selected by examining the object hierarchy.
converter
- the converter to add, null ignoredSecurityException
- if the security manager rejects the changepublic PeriodConverter removePeriodConverter(PeriodConverter converter) throws SecurityException
converter
- the converter to remove, null ignoredSecurityException
- if the security manager rejects the changepublic IntervalConverter getIntervalConverter(Object object)
object
- the object to convertIllegalArgumentException
- if no suitable converterIllegalStateException
- if multiple converters match the type
equally wellpublic IntervalConverter[] getIntervalConverters()
public IntervalConverter addIntervalConverter(IntervalConverter converter) throws SecurityException
The order in which converters are added is not relevant. The best converter is selected by examining the object hierarchy.
converter
- the converter to add, null ignoredSecurityException
- if the security manager rejects the changepublic IntervalConverter removeIntervalConverter(IntervalConverter converter) throws SecurityException
converter
- the converter to remove, null ignoredSecurityException
- if the security manager rejects the changeCopyright © 2002–2024 Joda.org. All rights reserved.