Class TLcdModelHeightProviderFactoryUtil

java.lang.Object
com.luciad.util.height.TLcdModelHeightProviderFactoryUtil

public class TLcdModelHeightProviderFactoryUtil extends Object
Utility class containing convenience methods for implementing ILcdModelHeightProviderFactory. The methods simplify handling required and optional properties.

Sample code

A height provider factory could use the convenience methods as follows, when implementing the interface:


 public ILcdHeightProvider createHeightProvider(ILcdModel           aModel,
                                                Map<String, Object> aRequiredPropertiesSFCT,
                                                Map<String, Object> aOptionalProperties)
   throws TLcdMissingPropertyException, TLcdUnsupportedPropertyException {

   // Retrieve a property that is necessary for this height provider.
   // Throw a TLcdMissingPropertyException if it is missing.
   Integer someProperty1 = (Integer)TLcdModelHeightProviderFactoryUtil.
     retrieveNecessaryProperty(KEY_SOME_PROPERTY1, aRequiredPropertiesSFCT, aOptionalProperties);
   ...

   // Retrieve a property that is just a hint for this height provider.
   Integer someProperty2 = (Integer)TLcdModelHeightProviderFactoryUtil.
     retrieveProperty(KEY_SOME_PROPERTY2, aRequiredPropertiesSFCT, aOptionalProperties);
   if (someProperty2 != null) {
     ...
   }

   // Delegate to another height provider factory.
   ILcdModelHeightProviderFactory delegateFactory = ...;

   Map<String, Object> requiredProperties = TLcdModelHeightProviderFactoryUtil.
     copyProperties(aRequiredPropertiesSFCT);

   ILcdHeightProvider heightProvider =
     delegateFactory.createHeightProvider(aModel, requiredProperties, aOptionalProperties);

   ...

   // Check that all properties required by the caller have been consumed.
   // Throw a TLcdUnsupportedPropertyException if it's not the case.
   TLcdModelHeightProviderFactoryUtil.verifyRequiredProperties(requiredProperties);
   ...
 }
 
Since:
9.1
  • Method Details

    • copyProperties

      public static Map<String,Object> copyProperties(Map<String,Object> aProperties)
      Returns a copy of the given properties.
      Parameters:
      aProperties - the given properties.
      Returns:
      a copy of the given properties.
    • containsProperty

      public static boolean containsProperty(String aPropertyName, Map<String,Object> aRequiredProperties, Map<String,Object> aOptionalProperties)
      Checks if a property exists with the given name.
      Parameters:
      aPropertyName - the property name.
      aRequiredProperties - the required properties.
      aOptionalProperties - the optional properties.
      Returns:
      true if a property exists with the given name. This property can either be required or optional.
    • verifyRequiredProperties

      public static void verifyRequiredProperties(Map<String,Object> aRequiredProperties) throws TLcdUnsupportedPropertyException
      Checks if no required properties exist and throws a TLcdUnsupportedPropertyException otherwise.
      Parameters:
      aRequiredProperties - the required properties.
      Throws:
      TLcdUnsupportedPropertyException - when the list of required properties is not empty.
    • retrieveNecessaryProperty

      public static Object retrieveNecessaryProperty(String aPropertyName, Map<String,Object> aRequiredProperties, Map<String,Object> aOptionalProperties) throws TLcdMissingPropertyException
      Returns the property with the given name. If no property with this name exists, a TLcdMissingPropertyException is thrown.
      Parameters:
      aPropertyName - the property name.
      aRequiredProperties - the required properties.
      aOptionalProperties - the optional properties.
      Returns:
      the property with the given name.
      Throws:
      TLcdMissingPropertyException - if no property with the given name exists.
    • retrieveProperty

      public static Object retrieveProperty(String aPropertyName, Map<String,Object> aRequiredProperties, Map<String,Object> aOptionalProperties)
      Returns the property with the given name. If such property exists, and if it is a required property, this property is removed from the list of required properties.
      Parameters:
      aPropertyName - the property name.
      aRequiredProperties - the required properties.
      aOptionalProperties - the optional properties.
      Returns:
      the property with the given name, or null if no such property exists.
    • getProperty

      public static Object getProperty(String aPropertyName, Map<String,Object> aRequiredProperties, Map<String,Object> aOptionalProperties)
      Returns the property with the given name.
      Parameters:
      aPropertyName - the property name.
      aRequiredProperties - the required properties.
      aOptionalProperties - the optional properties.
      Returns:
      the property with the given name, or null if no such property exists.
    • replaceProperty

      public static void replaceProperty(String aPropertyName, Object aNewProperty, Map<String,Object> aRequiredProperties, Map<String,Object> aOptionalProperties)
      Replaces all properties with the given name with the given property object. The replaced properties can be optional as well as required.
      Parameters:
      aPropertyName - the property name.
      aNewProperty - the property object that replaces the existing properties with the given name.
      aRequiredProperties - the required properties.
      aOptionalProperties - the optional properties.