DDR Simple API - PropertyValue and Enumerations

The PropertyValue interface publishes the method "getEnumeration()" to deal with property values that are an enumeration of several values, such as image formats. If a content adaptation solution needs to check if a Delivery Context supports "gif" it will need to do the following:

PropertyValue val = service.getPropertyValue(evidence,"supportedImageFormats");

String[] imageFormats = val.getEnumeration();

gifSupported = false;

for(int j = 0; j < imageFormats.length; j++) {
    if(imageFormats[j].equals("gif")) {
       gifSupported = true;
    }
}

As it is seen this is a very inconvenient way to do a more than common  operation. Also it will force develoeprs to copy & paste this code over all the applications

Proposed Amendment:

+ Add a contains method on the PropertyValue interface that returns true or false depending on the values of the enumeration

boolean gifSupported = service.getPropertyValue(evidence,"supportedImageFormats").contains("gif");

José Manuel Cantera
Senior Technologist
Telefónica I+D

Received on Tuesday, 15 April 2008 09:26:34 UTC