public final class ConverterManager
extends java.lang.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 and Type | Field and Description |
|---|---|
private ConverterSet |
iDurationConverters |
private ConverterSet |
iInstantConverters |
private ConverterSet |
iIntervalConverters |
private static ConverterManager |
INSTANCE
Singleton instance, lazily loaded to avoid class loading.
|
private ConverterSet |
iPartialConverters |
private ConverterSet |
iPeriodConverters |
| 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.
|
private void |
checkAlterDurationConverters()
Checks whether the user has permission 'ConverterManager.alterDurationConverters'.
|
private void |
checkAlterInstantConverters()
Checks whether the user has permission 'ConverterManager.alterInstantConverters'.
|
private void |
checkAlterIntervalConverters()
Checks whether the user has permission 'ConverterManager.alterIntervalConverters'.
|
private void |
checkAlterPartialConverters()
Checks whether the user has permission 'ConverterManager.alterPartialConverters'.
|
private void |
checkAlterPeriodConverters()
Checks whether the user has permission 'ConverterManager.alterPeriodConverters'.
|
DurationConverter |
getDurationConverter(java.lang.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(java.lang.Object object)
Gets the best converter for the object specified.
|
InstantConverter[] |
getInstantConverters()
Gets a copy of the set of converters.
|
IntervalConverter |
getIntervalConverter(java.lang.Object object)
Gets the best converter for the object specified.
|
IntervalConverter[] |
getIntervalConverters()
Gets a copy of the list of converters.
|
PartialConverter |
getPartialConverter(java.lang.Object object)
Gets the best converter for the object specified.
|
PartialConverter[] |
getPartialConverters()
Gets a copy of the set of converters.
|
PeriodConverter |
getPeriodConverter(java.lang.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.
|
java.lang.String |
toString()
Gets a debug representation of the object.
|
private static ConverterManager INSTANCE
private ConverterSet iInstantConverters
private ConverterSet iPartialConverters
private ConverterSet iDurationConverters
private ConverterSet iPeriodConverters
private ConverterSet iIntervalConverters
public static ConverterManager getInstance()
public InstantConverter getInstantConverter(java.lang.Object object)
object - the object to convertjava.lang.IllegalArgumentException - if no suitable converterjava.lang.IllegalStateException - if multiple converters match the type
equally wellpublic InstantConverter[] getInstantConverters()
public InstantConverter addInstantConverter(InstantConverter converter) throws java.lang.SecurityException
The order in which converters are added is not relevent. The best converter is selected by examining the object hierarchy.
converter - the converter to add, null ignoredjava.lang.SecurityExceptionpublic InstantConverter removeInstantConverter(InstantConverter converter) throws java.lang.SecurityException
converter - the converter to remove, null ignoredjava.lang.SecurityExceptionprivate void checkAlterInstantConverters()
throws java.lang.SecurityException
java.lang.SecurityException - if the user does not have the permissionpublic PartialConverter getPartialConverter(java.lang.Object object)
object - the object to convertjava.lang.IllegalArgumentException - if no suitable converterjava.lang.IllegalStateException - if multiple converters match the type
equally wellpublic PartialConverter[] getPartialConverters()
public PartialConverter addPartialConverter(PartialConverter converter) throws java.lang.SecurityException
The order in which converters are added is not relevent. The best converter is selected by examining the object hierarchy.
converter - the converter to add, null ignoredjava.lang.SecurityExceptionpublic PartialConverter removePartialConverter(PartialConverter converter) throws java.lang.SecurityException
converter - the converter to remove, null ignoredjava.lang.SecurityExceptionprivate void checkAlterPartialConverters()
throws java.lang.SecurityException
java.lang.SecurityException - if the user does not have the permissionpublic DurationConverter getDurationConverter(java.lang.Object object)
object - the object to convertjava.lang.IllegalArgumentException - if no suitable converterjava.lang.IllegalStateException - if multiple converters match the type
equally wellpublic DurationConverter[] getDurationConverters()
public DurationConverter addDurationConverter(DurationConverter converter) throws java.lang.SecurityException
The order in which converters are added is not relevent. The best converter is selected by examining the object hierarchy.
converter - the converter to add, null ignoredjava.lang.SecurityExceptionpublic DurationConverter removeDurationConverter(DurationConverter converter) throws java.lang.SecurityException
converter - the converter to remove, null ignoredjava.lang.SecurityExceptionprivate void checkAlterDurationConverters()
throws java.lang.SecurityException
java.lang.SecurityException - if the user does not have the permissionpublic PeriodConverter getPeriodConverter(java.lang.Object object)
object - the object to convertjava.lang.IllegalArgumentException - if no suitable converterjava.lang.IllegalStateException - if multiple converters match the type
equally wellpublic PeriodConverter[] getPeriodConverters()
public PeriodConverter addPeriodConverter(PeriodConverter converter) throws java.lang.SecurityException
The order in which converters are added is not relevent. The best converter is selected by examining the object hierarchy.
converter - the converter to add, null ignoredjava.lang.SecurityExceptionpublic PeriodConverter removePeriodConverter(PeriodConverter converter) throws java.lang.SecurityException
converter - the converter to remove, null ignoredjava.lang.SecurityExceptionprivate void checkAlterPeriodConverters()
throws java.lang.SecurityException
java.lang.SecurityException - if the user does not have the permissionpublic IntervalConverter getIntervalConverter(java.lang.Object object)
object - the object to convertjava.lang.IllegalArgumentException - if no suitable converterjava.lang.IllegalStateException - if multiple converters match the type
equally wellpublic IntervalConverter[] getIntervalConverters()
public IntervalConverter addIntervalConverter(IntervalConverter converter) throws java.lang.SecurityException
The order in which converters are added is not relevent. The best converter is selected by examining the object hierarchy.
converter - the converter to add, null ignoredjava.lang.SecurityExceptionpublic IntervalConverter removeIntervalConverter(IntervalConverter converter) throws java.lang.SecurityException
converter - the converter to remove, null ignoredjava.lang.SecurityExceptionprivate void checkAlterIntervalConverters()
throws java.lang.SecurityException
java.lang.SecurityException - if the user does not have the permissionpublic java.lang.String toString()
toString in class java.lang.Object