Class TLcyCompositeDomainObjectConverter
ALcyDomainObjectConverter.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TCreates an adapter object foraDomainObjectcontained inaSourceModel, which will be an instance ofaDesiredClass.voidaddDomainObjectConverter(ALcyDomainObjectConverter aDomainObjectConverter) Add a domain object converter to this composite converter with the default priority, which is defined by thePRIORITY_DEFAULTfield.voidaddDomainObjectConverter(ALcyDomainObjectConverter aDomainObjectConverter, int aPriority) Add a domain object converter to this composite converter with priorityaPriority.booleanIndicates whether this converter can create an adapter object foraDomainObject, which will be an instance ofaDesiredClass.booleancanConvert(Object aDomainObject, ILcdModel aSourceModel, ILcdModel aTargetModel, Class aCanAdaptToClass) Indicates whether this converter is capable of converting a domain objectaDomainObjectofaSourceModelinto a domain object for the modelaTargetModel.convert(Object aDomainObject, ILcdModel aSourceModel, ILcdModel aTargetModel, Class aCanAdaptToClass) Converts a domain objectaDomainObjectofaSourceModelinto a domain object for the modelaTargetModel.getDomainObjectConverter(int aIndex) Retrieve the domain object converter at indexaIndex.intReturns the number of domain object converters contained in this composite converter.intgetDomainObjectConverterPriority(int aIndex) Returns the priority, associated with the converter at indexaIndex.voidremoveDomainObjectConverter(ALcyDomainObjectConverter aDomainObjectConverter) Remove the domain object converteraDomainObjectConverterfrom this composite converter.Methods inherited from class com.luciad.lucy.model.ALcyDomainObjectConverter
canConvert, convert
-
Constructor Details
-
TLcyCompositeDomainObjectConverter
public TLcyCompositeDomainObjectConverter()
-
-
Method Details
-
canAdapt
Description copied from class:ALcyDomainObjectConverterIndicates whether this converter can create an adapter object for
aDomainObject, which will be an instance ofaDesiredClass. The objectaDomainObjectis contained inaSourceModel.The adapter object and the domain object are linked, which means changes made to the adapter object will be passed on to the original object and vice versa.
Since this method indicates whether an adapter object for
aDomainObjectcan be created, it must returnfalsewhen the adapter object adds information to theaDomainObject. The adapter object may only contain less information than the original object. For example a sphere can be adapted to a circle, since this simply removes the height information. Adapting a circle to a sphere should not be possible, since the adapter object (the sphere) contains information that is not available in the original object (the height). For such cases theconvertmethod should be used instead.- Specified by:
canAdaptin classALcyDomainObjectConverter- Parameters:
aDomainObject- the original objectaSourceModel- the model containingaDomainObjectaDesiredClass- the class of the adapter object- Returns:
truewhen this converter can perform the adapt operation
-
adapt
Description copied from class:ALcyDomainObjectConverterCreates an adapter object for
aDomainObjectcontained inaSourceModel, which will be an instance ofaDesiredClass.The adapter object and the domain object are linked, which means changes made to the adapter object will be passed on to the original object and vice versa.
An
IllegalArgumentExceptionmust be thrown when the converter cannot handle the domain object, or could not adapt the domain object to an instance ofaDesiredClass. It is possible to check in advance if this converter is capable of creating an adapter object for the domain object by calling thecanAdaptmethod first.- Specified by:
adaptin classALcyDomainObjectConverter- Parameters:
aDomainObject- the original objectaSourceModel- the model containingaDomainObjectaDesiredClass- the class of the adapter object- Returns:
- the adapter object for
aDomainObject, which is an instance ofaDesiredClass
-
canConvert
public boolean canConvert(Object aDomainObject, ILcdModel aSourceModel, ILcdModel aTargetModel, Class aCanAdaptToClass) Description copied from class:ALcyDomainObjectConverterIndicates whether this converter is capable of converting a domain object
aDomainObjectofaSourceModelinto a domain object for the modelaTargetModel. The parameteraCanAdaptToClassis passed to this method to check if the creation of a new domain object is possible in such a way that theadaptmethod called with that new domain object will return an object of instanceaCanAdaptToClass.Notice that the source and target model may be the same. When the
aCanAdaptToClassis not important,Object.classshould be passed as parameter or theALcyDomainObjectConverter.canConvert(Object, com.luciad.model.ILcdModel, com.luciad.model.ILcdModel)method can be used instead.- Specified by:
canConvertin classALcyDomainObjectConverter- Parameters:
aDomainObject- the original domain objectaSourceModel- the model containingaDomainObjectaTargetModel- the model for which a new domain object should be created.aCanAdaptToClass- adapting the resulting new domain object to this class should be possible- Returns:
truewhen the conversion can be done by this converter
-
convert
public Object convert(Object aDomainObject, ILcdModel aSourceModel, ILcdModel aTargetModel, Class aCanAdaptToClass) throws IllegalArgumentException, TLcdOutOfBoundsException Description copied from class:ALcyDomainObjectConverterConverts a domain object
aDomainObjectofaSourceModelinto a domain object for the modelaTargetModel. The parameteraCanAdaptToClasswill influence the creation of the new domain object in such a way that theadaptmethod called with that new domain object will return an object of instanceaCanAdaptToClass.Note that the source and target model may be the same. When the
aCanAdaptToClassis not important,Object.classshould be passed as parameter or theALcyDomainObjectConverter.convert(Object, com.luciad.model.ILcdModel, com.luciad.model.ILcdModel)method can be used instead.An
IllegalArgumentExceptionmust be thrown when the converter cannot handle the domain object, or could not convert the domain object in such a way that the resulting domain object is adaptable to an instance ofaCanAdaptToClassafterwards. It is possible to check in advance if this converter is capable of converting the domain object by calling thecanConvertmethod first.- Specified by:
convertin classALcyDomainObjectConverter- Parameters:
aDomainObject- the original domain objectaSourceModel- the model containingaDomainObjectaTargetModel- the model for which a new domain object should be created.aCanAdaptToClass- adapting the resulting new domain object to this class should be possible- Returns:
- a new domain object for the model
aTargetModel, which can be adapted to an instance ofaCanAdaptToClass - Throws:
IllegalArgumentException- when the converter could not handle the domain object, or could not convert the domain object in such a way that the resulting domain object is adaptable to an instance ofaCanAdaptToClassafterwards.TLcdOutOfBoundsException- when restoring the state for the target model failed because the coordinates could not be properly converted from the sourceILcdModelReferenceto the targetILcdModelReference.
-
addDomainObjectConverter
Add a domain object converter to this composite converter with the default priority, which is defined by thePRIORITY_DEFAULTfield.- Parameters:
aDomainObjectConverter- the domain object converter to add
-
addDomainObjectConverter
public void addDomainObjectConverter(ALcyDomainObjectConverter aDomainObjectConverter, int aPriority) Add a domain object converter to this composite converter with priorityaPriority.- Parameters:
aDomainObjectConverter- the domain object converter to addaPriority- the priority foraDomainObjectConverter. The lower this value, the higher the priority
-
removeDomainObjectConverter
Remove the domain object converteraDomainObjectConverterfrom this composite converter. WhenaDomainObjectConverteris not found, nothing happens and no error will be thrown.- Parameters:
aDomainObjectConverter- the domain object converter to remove.
-
getDomainObjectConverterCount
public int getDomainObjectConverterCount()Returns the number of domain object converters contained in this composite converter.- Returns:
- the number of domain object converters contained in this composite converter
-
getDomainObjectConverter
Retrieve the domain object converter at indexaIndex. This index must be a number between 0 and (getDomainObjectConverterCount-1)- Parameters:
aIndex- index of the converter to retrieve. Must be a number between 0 and (getDomainObjectConverterCount-1)- Returns:
- the domain object converter at index
aIndex
-
getDomainObjectConverterPriority
public int getDomainObjectConverterPriority(int aIndex) Returns the priority, associated with the converter at indexaIndex. This index must be a number between 0 and (getDomainObjectConverterCount-1)- Parameters:
aIndex- index of the converter for which the priority is asked. Must be a number between 0 and (getDomainObjectConverterCount-1)- Returns:
- the priority associated with the converter at index
aIndex
-