Class TLcyCompositeDomainObjectConverter
ALcyDomainObjectConverter
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> T
Creates an adapter object foraDomainObject
contained inaSourceModel
, which will be an instance ofaDesiredClass
.void
addDomainObjectConverter
(ALcyDomainObjectConverter aDomainObjectConverter) Add a domain object converter to this composite converter with the default priority, which is defined by thePRIORITY_DEFAULT
field.void
addDomainObjectConverter
(ALcyDomainObjectConverter aDomainObjectConverter, int aPriority) Add a domain object converter to this composite converter with priorityaPriority
.boolean
Indicates whether this converter can create an adapter object foraDomainObject
, which will be an instance ofaDesiredClass
.boolean
canConvert
(Object aDomainObject, ILcdModel aSourceModel, ILcdModel aTargetModel, Class aCanAdaptToClass) Indicates whether this converter is capable of converting a domain objectaDomainObject
ofaSourceModel
into a domain object for the modelaTargetModel
.convert
(Object aDomainObject, ILcdModel aSourceModel, ILcdModel aTargetModel, Class aCanAdaptToClass) Converts a domain objectaDomainObject
ofaSourceModel
into a domain object for the modelaTargetModel
.getDomainObjectConverter
(int aIndex) Retrieve the domain object converter at indexaIndex
.int
Returns the number of domain object converters contained in this composite converter.int
getDomainObjectConverterPriority
(int aIndex) Returns the priority, associated with the converter at indexaIndex
.void
removeDomainObjectConverter
(ALcyDomainObjectConverter aDomainObjectConverter) Remove the domain object converteraDomainObjectConverter
from this composite converter.Methods inherited from class com.luciad.lucy.model.ALcyDomainObjectConverter
canConvert, convert
-
Constructor Details
-
Method Details
-
canAdapt
Description copied from class:ALcyDomainObjectConverter
Indicates whether this converter can create an adapter object for
aDomainObject
, which will be an instance ofaDesiredClass
. The objectaDomainObject
is 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
aDomainObject
can be created, it must returnfalse
when 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 theconvert
method should be used instead.- Specified by:
canAdapt
in classALcyDomainObjectConverter
- Parameters:
aDomainObject
- the original objectaSourceModel
- the model containingaDomainObject
aDesiredClass
- the class of the adapter object- Returns:
true
when this converter can perform the adapt operation
-
adapt
Description copied from class:ALcyDomainObjectConverter
Creates an adapter object for
aDomainObject
contained 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
IllegalArgumentException
must 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 thecanAdapt
method first.- Specified by:
adapt
in classALcyDomainObjectConverter
- Parameters:
aDomainObject
- the original objectaSourceModel
- the model containingaDomainObject
aDesiredClass
- 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:ALcyDomainObjectConverter
Indicates whether this converter is capable of converting a domain object
aDomainObject
ofaSourceModel
into a domain object for the modelaTargetModel
. The parameteraCanAdaptToClass
is passed to this method to check if the creation of a new domain object is possible in such a way that theadapt
method 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
aCanAdaptToClass
is not important,Object.class
should be passed as parameter or theALcyDomainObjectConverter.canConvert(Object, com.luciad.model.ILcdModel, com.luciad.model.ILcdModel)
method can be used instead.- Specified by:
canConvert
in classALcyDomainObjectConverter
- Parameters:
aDomainObject
- the original domain objectaSourceModel
- the model containingaDomainObject
aTargetModel
- 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:
true
when 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:ALcyDomainObjectConverter
Converts a domain object
aDomainObject
ofaSourceModel
into a domain object for the modelaTargetModel
. The parameteraCanAdaptToClass
will influence the creation of the new domain object in such a way that theadapt
method 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
aCanAdaptToClass
is not important,Object.class
should be passed as parameter or theALcyDomainObjectConverter.convert(Object, com.luciad.model.ILcdModel, com.luciad.model.ILcdModel)
method can be used instead.An
IllegalArgumentException
must 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 ofaCanAdaptToClass
afterwards. It is possible to check in advance if this converter is capable of converting the domain object by calling thecanConvert
method first.- Specified by:
convert
in classALcyDomainObjectConverter
- Parameters:
aDomainObject
- the original domain objectaSourceModel
- the model containingaDomainObject
aTargetModel
- 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 ofaCanAdaptToClass
afterwards.TLcdOutOfBoundsException
- when restoring the state for the target model failed because the coordinates could not be properly converted from the sourceILcdModelReference
to the targetILcdModelReference
.
-
addDomainObjectConverter
Add a domain object converter to this composite converter with the default priority, which is defined by thePRIORITY_DEFAULT
field.- 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 converteraDomainObjectConverter
from this composite converter. WhenaDomainObjectConverter
is 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
-