Class TLcyCompositeDomainObjectConverter

java.lang.Object
com.luciad.lucy.model.ALcyDomainObjectConverter
com.luciad.lucy.model.TLcyCompositeDomainObjectConverter

public class TLcyCompositeDomainObjectConverter extends ALcyDomainObjectConverter
Composite implementation of ALcyDomainObjectConverter.
  • Constructor Details

    • TLcyCompositeDomainObjectConverter

      public TLcyCompositeDomainObjectConverter()
  • Method Details

    • canAdapt

      public boolean canAdapt(Object aDomainObject, ILcdModel aSourceModel, Class aDesiredClass)
      Description copied from class: ALcyDomainObjectConverter

      Indicates whether this converter can create an adapter object for aDomainObject, which will be an instance of aDesiredClass. The object aDomainObject is contained in aSourceModel.

      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 return false when the adapter object adds information to the aDomainObject. 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 the convert method should be used instead.

      Specified by:
      canAdapt in class ALcyDomainObjectConverter
      Parameters:
      aDomainObject - the original object
      aSourceModel - the model containing aDomainObject
      aDesiredClass - the class of the adapter object
      Returns:
      true when this converter can perform the adapt operation
    • adapt

      public <T> T adapt(Object aDomainObject, ILcdModel aSourceModel, Class<T> aDesiredClass)
      Description copied from class: ALcyDomainObjectConverter

      Creates an adapter object for aDomainObject contained in aSourceModel, which will be an instance of aDesiredClass.

      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 of aDesiredClass. It is possible to check in advance if this converter is capable of creating an adapter object for the domain object by calling the canAdapt method first.

      Specified by:
      adapt in class ALcyDomainObjectConverter
      Parameters:
      aDomainObject - the original object
      aSourceModel - the model containing aDomainObject
      aDesiredClass - the class of the adapter object
      Returns:
      the adapter object for aDomainObject, which is an instance of aDesiredClass
    • 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 of aSourceModel into a domain object for the model aTargetModel. The parameter aCanAdaptToClass is passed to this method to check if the creation of a new domain object is possible in such a way that the adapt method called with that new domain object will return an object of instance aCanAdaptToClass.

      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 the ALcyDomainObjectConverter.canConvert(Object, com.luciad.model.ILcdModel, com.luciad.model.ILcdModel) method can be used instead.

      Specified by:
      canConvert in class ALcyDomainObjectConverter
      Parameters:
      aDomainObject - the original domain object
      aSourceModel - the model containing aDomainObject
      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 of aSourceModel into a domain object for the model aTargetModel. The parameter aCanAdaptToClass will influence the creation of the new domain object in such a way that the adapt method called with that new domain object will return an object of instance aCanAdaptToClass.

      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 the ALcyDomainObjectConverter.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 of aCanAdaptToClass afterwards. It is possible to check in advance if this converter is capable of converting the domain object by calling the canConvert method first.

      Specified by:
      convert in class ALcyDomainObjectConverter
      Parameters:
      aDomainObject - the original domain object
      aSourceModel - the model containing aDomainObject
      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 of aCanAdaptToClass
      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 of aCanAdaptToClass afterwards.
      TLcdOutOfBoundsException - when restoring the state for the target model failed because the coordinates could not be properly converted from the source ILcdModelReference to the target ILcdModelReference.
    • addDomainObjectConverter

      public void addDomainObjectConverter(ALcyDomainObjectConverter aDomainObjectConverter)
      Add a domain object converter to this composite converter with the default priority, which is defined by the PRIORITY_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 priority aPriority.
      Parameters:
      aDomainObjectConverter - the domain object converter to add
      aPriority - the priority for aDomainObjectConverter. The lower this value, the higher the priority
    • removeDomainObjectConverter

      public void removeDomainObjectConverter(ALcyDomainObjectConverter aDomainObjectConverter)
      Remove the domain object converter aDomainObjectConverter from this composite converter. When aDomainObjectConverter 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

      public ALcyDomainObjectConverter getDomainObjectConverter(int aIndex)
      Retrieve the domain object converter at index aIndex. 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 index aIndex. 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