You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2014/05/27 08:55:34 UTC

svn commit: r1597711 - in /stanbol/trunk: ./ enhancement-engines/ enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/ enhancer/ enhancer/generic/servicesapi/ enhancer/generic/servicesapi/src/main/java/org...

Author: rwesten
Date: Tue May 27 06:55:34 2014
New Revision: 1597711

URL: http://svn.apache.org/r1597711
Log:
merged r1597575 to trunk (impl for STANBOL-1334; STANBOL-1346)

Modified:
    stanbol/trunk/   (props changed)
    stanbol/trunk/enhancement-engines/   (props changed)
    stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/DereferenceConstants.java
    stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/DereferenceContext.java
    stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/DereferenceEngineConfig.java
    stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/EntityDereferenceEngine.java
    stanbol/trunk/enhancer/   (props changed)
    stanbol/trunk/enhancer/generic/servicesapi/   (props changed)
    stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/EnhancementEngineHelper.java
    stanbol/trunk/enhancer/generic/servicesapi/src/test/java/org/apache/stanbol/enhancer/serviceapi/helper/EnhancementEngineHelperTest.java

Propchange: stanbol/trunk/
------------------------------------------------------------------------------
  Merged /stanbol/branches/release-0.12:r1597575

Propchange: stanbol/trunk/enhancement-engines/
------------------------------------------------------------------------------
  Merged /stanbol/branches/release-0.12/enhancement-engines:r1597575

Modified: stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/DereferenceConstants.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/DereferenceConstants.java?rev=1597711&r1=1597710&r2=1597711&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/DereferenceConstants.java (original)
+++ stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/DereferenceConstants.java Tue May 27 06:55:34 2014
@@ -16,9 +16,13 @@
  */
 package org.apache.stanbol.enhancer.engines.dereference;
 
+import java.util.Collections;
+import java.util.Set;
+
 import org.apache.clerezza.rdf.core.Language;
 import org.apache.clerezza.rdf.core.PlainLiteral;
 import org.apache.clerezza.rdf.core.Triple;
+import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.stanbol.enhancer.servicesapi.rdf.Properties;
 
 /**
@@ -27,7 +31,7 @@ import org.apache.stanbol.enhancer.servi
  *
  */
 public interface DereferenceConstants {
-    
+        
     /**
      * Property that allows to enable/disable the filtering of {@link Triple}s
      * with {@link PlainLiteral} {@link Triple#getObject() objects} based on
@@ -70,7 +74,14 @@ public interface DereferenceConstants {
      * @since 0.12.1 (<a href="https://issues.apache.org/jira/browse/STANBOL-1334">STANBOL-1334</a>)
      */
     String ENTITY_REFERENCES = "enhancer.engines.dereference.references";
-    
+    /**
+     * By default the {@link Properties#ENTITY_REFERENCES} is used for
+     * dereferencing entities.
+     * @since 0.12.1 (<a href="https://issues.apache.org/jira/browse/STANBOL-1334">STANBOL-1334</a>)
+     */
+    Set<UriRef> DEFAULT_ENTITY_REFERENCES = Collections.unmodifiableSet(
+        Collections.singleton(Properties.ENHANCER_ENTITY_REFERENCE));
+
     /**
      * Property used to configure the fields that should be dereferenced.<p>
      * DereferenceEngines need to support a list of URIs but may also support more

Modified: stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/DereferenceContext.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/DereferenceContext.java?rev=1597711&r1=1597710&r2=1597711&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/DereferenceContext.java (original)
+++ stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/DereferenceContext.java Tue May 27 06:55:34 2014
@@ -3,6 +3,7 @@ package org.apache.stanbol.enhancer.engi
 import static org.apache.stanbol.enhancer.engines.dereference.DereferenceConstants.DEREFERENCE_ENTITIES_LANGUAGES;
 import static org.apache.stanbol.enhancer.engines.dereference.DereferenceConstants.NO_LANGUAGE_KEY;
 
+import java.io.ObjectInputStream.GetField;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -12,8 +13,12 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.commons.lang.StringUtils;
+import org.apache.stanbol.commons.namespaceprefix.NamespaceMappingUtils;
+import org.apache.stanbol.commons.namespaceprefix.NamespacePrefixService;
 import org.apache.stanbol.commons.stanboltools.offline.OfflineMode;
+import org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -43,6 +48,7 @@ public class DereferenceContext {
     private Set<String> languages;
     private List<String> fields;
     private String program;
+    private HashSet<UriRef> entityReferences;
     
     
     
@@ -63,9 +69,38 @@ public class DereferenceContext {
             ep == null ? null : (Collection<String>)ep.get(INTERNAL_ACCEPT_LANGUAGES));
         parseFields(ep == null ? null : ep.get(DereferenceConstants.DEREFERENCE_ENTITIES_FIELDS));
         parseLDPath(ep == null ? null : ep.get(DereferenceConstants.DEREFERENCE_ENTITIES_LDPATH));
+        parseEntityReferences(ep == null ? null : ep.get(DereferenceConstants.ENTITY_REFERENCES));
         //call the initialisation callback
         initialise();
     }
+    
+    private void parseEntityReferences(Object value) throws DereferenceConfigurationException {
+        Collection<String> entityRefProps;
+        try{
+            entityRefProps = EnhancementEngineHelper.parseConfigValues(value, String.class);
+        } catch (IllegalStateException e){
+            throw new DereferenceConfigurationException(e,
+                engine.getDereferencer().getClass(), 
+                DereferenceConstants.ENTITY_REFERENCES);
+        }
+        //start with the references present in the config
+        this.entityReferences = new HashSet<UriRef>(getConfig().getEntityReferences());
+        if(entityRefProps != null && !entityRefProps.isEmpty()){
+            NamespacePrefixService nps = engine.getConfig().getNsPrefixService();
+            for(String prop : entityRefProps){
+                if(!StringUtils.isBlank(prop)){
+                    try {
+                        entityReferences.add(new UriRef(
+                            NamespaceMappingUtils.getConfiguredUri(nps, prop)));
+                    } catch(IllegalArgumentException e){
+                        throw new DereferenceConfigurationException(e, 
+                            engine.getDereferencer().getClass(), 
+                            DereferenceConstants.ENTITY_REFERENCES);
+                    }
+                }
+            }
+        }
+    }
     /**
      * Parses the {@link DereferenceConstants#DEREFERENCE_ENTITIES_LANGUAGES}
      * from the parsed value, merges content- and accept-languages and finally 
@@ -245,6 +280,16 @@ public class DereferenceContext {
     public final String getLdPathProgram() {
         return program;
     }
+    /**
+     * The property URIs that may refer to Entities that need to be dereferenced.
+     * This is the union view over properties parsed as EnhancementProperties
+     * with properties configured with the engine
+     * @return the entity reference properties
+     * @see DereferenceEngineConfig#getEntityReferences()
+     */
+    public HashSet<UriRef> getEntityReferences() {
+        return entityReferences;
+    }
     
     /**
      * Getter for the languages that should be dereferenced. If 

Modified: stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/DereferenceEngineConfig.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/DereferenceEngineConfig.java?rev=1597711&r1=1597710&r2=1597711&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/DereferenceEngineConfig.java (original)
+++ stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/DereferenceEngineConfig.java Tue May 27 06:55:34 2014
@@ -2,15 +2,13 @@ package org.apache.stanbol.enhancer.engi
 
 import static org.apache.stanbol.enhancer.engines.dereference.DereferenceConstants.NO_LANGUAGE_KEY;
 import static org.apache.stanbol.commons.namespaceprefix.NamespaceMappingUtils.getConfiguredUri;
-import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_ENTITY_REFERENCE;
+import static org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper.getConfigValues;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Dictionary;
 import java.util.HashSet;
-import java.util.Hashtable;
 import java.util.List;
 import java.util.Locale;
 import java.util.Set;
@@ -19,6 +17,7 @@ import org.apache.clerezza.rdf.core.UriR
 import org.apache.commons.lang.StringUtils;
 import org.apache.stanbol.commons.namespaceprefix.NamespacePrefixService;
 import org.apache.stanbol.enhancer.servicesapi.EnhancementEngine;
+import org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper;
 import org.apache.stanbol.enhancer.servicesapi.rdf.Properties;
 import org.osgi.framework.Constants;
 import org.osgi.service.cm.ConfigurationException;
@@ -26,10 +25,12 @@ import org.osgi.service.cm.Configuration
 public class DereferenceEngineConfig implements DereferenceConstants {
 
     private final NamespacePrefixService nsPrefixService;
+
     private final Dictionary<String,Object> config;
     private String ldpath;
     private List<String> dereferenced;
-    private List<UriRef> entityReferences;
+    private Set<String> languages;
+    private Set<UriRef> entityReferences;
 
     /**
      * Creates a DereferenceEngine configuration based on a Dictionary. Typically
@@ -51,6 +52,14 @@ public class DereferenceEngineConfig imp
     }
     
     /**
+     * Getter for the {@link NamespacePrefixService}
+     * @return the service or <code>null</code> if not available
+     * @since 0.12.1
+     */
+    public NamespacePrefixService getNsPrefixService() {
+        return nsPrefixService;
+    }
+    /**
      * If filtering for non content language literals is active
      * @return the {@link DereferenceConstants#FILTER_CONTENT_LANGUAGES} state
      */
@@ -85,6 +94,8 @@ public class DereferenceEngineConfig imp
         }
         this.dereferenced = parseDereferenceFields();
         this.ldpath = parseLdPathProgram();
+        this.languages = parseLanguages();
+        //STANBOL-1334
         this.entityReferences = parseEntityReferences();
     }
 
@@ -116,54 +127,10 @@ public class DereferenceEngineConfig imp
      * is present
      * @since 0.12.1 (<a href="https://issues.apache.org/jira/browse/STANBOL-1334">STANBOL-1334</a>)
      */
-    public List<UriRef> getEntityReferences() {
+    public Set<UriRef> getEntityReferences() {
         return entityReferences;
     }
-    /**
-     * Parses the list of properties used to reference Entities from the
-     * {@link DereferenceConstants#ENTITY_REFERENCES} property
-     * @return the list of properties used to reference entities. If none are
-     * present this returns a singleton list containing 
-     * {@link Properties#ENHANCER_ENTITY_REFERENCE}
-     * @since 0.12.1 (<a href="https://issues.apache.org/jira/browse/STANBOL-1334">STANBOL-1334</a>)
-     */
-    public List<UriRef> parseEntityReferences() throws ConfigurationException {
-        Object value = config.get(ENTITY_REFERENCES);
-        final List<String> fields;
-        if(value instanceof String[]){
-            fields = Arrays.asList((String[])value);
-        } else if(value instanceof Collection<?>){
-            fields = new ArrayList<String>(((Collection<?>)value).size());
-            for(Object field : (Collection<?>)value){
-                if(field != null){
-                    fields.add(field.toString());
-                }
-            }
-        } else if(value instanceof String){
-            fields = Collections.singletonList((String)value);
-        } else if(value != null){ //unsupported type 
-            throw new ConfigurationException(ENTITY_REFERENCES, 
-                "Entity References MUST BE parsed as String[], Collection<String> or "
-                + "String (single value). The actual value '"+value+"'(type: '"+value.getClass() 
-                + "') is NOT supported");
-        } else { //not specified return the default
-            return Collections.singletonList(ENHANCER_ENTITY_REFERENCE);
-        }
-        //convert configured fields (incl. 'ns:local-name' configurations) to 
-        //full UriRef instances
-        List<UriRef> references = new ArrayList<UriRef>(fields.size());
-        for(String field : fields){
-            if(!StringUtils.isBlank(field)){
-                references.add(new UriRef(getConfiguredUri(nsPrefixService, 
-                    ENTITY_REFERENCES, field.trim())));
-            }
-        }
-        if(references.isEmpty()){ //no valid configuration left ... return the default
-            return Collections.singletonList(ENHANCER_ENTITY_REFERENCE); 
-        } else {
-            return references;
-        }
-    }
+
     /**
      * Getter for the list of dereferenced fields as configured by the 
      * {@link DereferenceConstants#DEREFERENCE_ENTITIES_FIELDS} property.<p>
@@ -188,30 +155,31 @@ public class DereferenceEngineConfig imp
      * @return the {@link List} with the unprocessed dereference fields as list
      */
     private List<String> parseDereferenceFields() throws ConfigurationException {
-        Object value = config.get(DEREFERENCE_ENTITIES_FIELDS);
-        final List<String> fields;
-        if(value instanceof String[]){
-            fields = Arrays.asList((String[])value);
-        } else if(value instanceof Collection<?>){
-            fields = new ArrayList<String>(((Collection<?>)value).size());
-            for(Object field : (Collection<?>)value){
-                if(field == null){
-                    fields.add(null);
-                } else {
-                    fields.add(field.toString());
+        List<String> fields = new ArrayList<String>();
+        getConfigValues(config, DEREFERENCE_ENTITIES_FIELDS, String.class, fields);
+        return fields;
+    }
+    /**
+     * Parses the URIs for the {@link DereferenceConstants#ENTITY_REFERENCE_PROPERTIES}
+     * @return
+     * @throws ConfigurationException
+     */
+    private Set<UriRef> parseEntityReferences() throws ConfigurationException {
+        Set<UriRef> entityRefPropUris;
+        Collection<String> entityProps = EnhancementEngineHelper.getConfigValues(
+            config, ENTITY_REFERENCES, String.class);
+        if(entityProps == null || entityProps.isEmpty()){
+            entityRefPropUris = DEFAULT_ENTITY_REFERENCES;
+        } else {
+            entityRefPropUris = new HashSet<UriRef>(entityProps.size());
+            for(String prop : entityProps){
+                if(!StringUtils.isBlank(prop)){
+                    entityRefPropUris.add(new UriRef(getConfiguredUri(nsPrefixService, 
+                        ENTITY_REFERENCES, prop.trim())));
                 }
             }
-        } else if(value instanceof String){
-            fields = Collections.singletonList((String)value);
-        } else if(value != null){
-            throw new ConfigurationException(DEREFERENCE_ENTITIES_FIELDS, 
-                "Dereference Entities Fields MUST BE parsed as String[], Collection<String> or "
-                + "String (single value). The actual value '"+value+"'(type: '"+value.getClass() 
-                + "') is NOT supported");
-        } else {//value == null
-            fields = Collections.emptyList();
         }
-        return fields;
+        return entityRefPropUris;
     }
     /**
      * Getter for the LDPath program as configured by the 
@@ -342,29 +310,23 @@ public class DereferenceEngineConfig imp
 	 * @return
 	 */
 	public Collection<String> getLanaguages(){
-	    Object value = config.get(DEREFERENCE_ENTITIES_LANGUAGES);
-	    if(value == null){
+	    return languages;
+	}
+	/**
+	 * parses the {@link DereferenceConstants#DEREFERENCE_ENTITIES_LANGUAGES} property
+	 * @return
+	 */
+	private Set<String> parseLanguages() throws ConfigurationException {
+	    Collection<String> values = EnhancementEngineHelper.getConfigValues(
+	        config, DEREFERENCE_ENTITIES_LANGUAGES, String.class);
+	    if(values == null){
 	        return null;
 	    } else {
-            Set<String> languages = new HashSet<String>();
-            if(value instanceof String){
-                addLanguage(languages, (String)value);
-            } else if(value instanceof String[]){
-                for(String lang : (String[])value){
-                    addLanguage(languages, lang);
-                }
-            } else if(value instanceof Collection<?>){
-                for(Object lang : (Collection<?>)value){
-                    if(lang instanceof String){
-                        addLanguage(languages, (String)lang);
-                    }
-                }           
-            }
-            if(languages.isEmpty()){
-                return null;
-            } else {
-                return languages;
-            }
+            Set<String> languages = new HashSet<String>(values.size());
+	        for(String value : values){
+	            addLanguage(languages, value);
+	        }
+	        return languages;
 	    }
 	}
 	

Modified: stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/EntityDereferenceEngine.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/EntityDereferenceEngine.java?rev=1597711&r1=1597710&r2=1597711&view=diff
==============================================================================
--- stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/EntityDereferenceEngine.java (original)
+++ stanbol/trunk/enhancement-engines/dereference/core/src/main/java/org/apache/stanbol/enhancer/engines/dereference/EntityDereferenceEngine.java Tue May 27 06:55:34 2014
@@ -251,7 +251,8 @@ public class EntityDereferenceEngine imp
             //parse the referenced entities from the graph
             //(2) read all Entities we need to dereference from the parsed contentItem
             Set<UriRef> checked = new HashSet<UriRef>();
-            for(UriRef referenceProperty : config.getEntityReferences()){
+            //since STANBOL-1334 the list of properties that refer to entities can be configured
+            for(UriRef referenceProperty : derefContext.getEntityReferences()){
                 Iterator<Triple> entityReferences = metadata.filter(null, referenceProperty, null);
                 while(entityReferences.hasNext()){
                     Triple triple = entityReferences.next();
@@ -267,7 +268,7 @@ public class EntityDereferenceEngine imp
                         }
                     } else if(log.isTraceEnabled()){
                         log.trace(" ... ignore Entity {} (referenced-by: {})",
-                            entityReferences, referenceProperty);
+                            entityReference, referenceProperty);
                     }
                 }
             }

Propchange: stanbol/trunk/enhancer/
------------------------------------------------------------------------------
  Merged /stanbol/branches/release-0.12/enhancer:r1597575

Propchange: stanbol/trunk/enhancer/generic/servicesapi/
------------------------------------------------------------------------------
  Merged /stanbol/branches/release-0.12/enhancer/generic/servicesapi:r1597575

Modified: stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/EnhancementEngineHelper.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/EnhancementEngineHelper.java?rev=1597711&r1=1597710&r2=1597711&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/EnhancementEngineHelper.java (original)
+++ stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/EnhancementEngineHelper.java Tue May 27 06:55:34 2014
@@ -54,15 +54,15 @@ import org.apache.clerezza.rdf.core.impl
 import org.apache.stanbol.enhancer.servicesapi.Chain;
 import org.apache.stanbol.enhancer.servicesapi.ContentItem;
 import org.apache.stanbol.enhancer.servicesapi.EnhancementEngine;
+import org.apache.stanbol.enhancer.servicesapi.EnhancementPropertyException;
 import org.apache.stanbol.enhancer.servicesapi.NoSuchPartException;
 import org.apache.stanbol.enhancer.servicesapi.ServiceProperties;
 import org.apache.stanbol.enhancer.servicesapi.rdf.ExecutionPlan;
 import org.apache.stanbol.enhancer.servicesapi.rdf.NamespaceEnum;
+import org.osgi.service.cm.ConfigurationException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.ibm.icu.impl.CalendarAstronomer.Equatorial;
-
 
 public final class EnhancementEngineHelper {
 
@@ -979,6 +979,81 @@ public final class EnhancementEngineHelp
     }
     
     /**
+     * Getter for all configuration values for the parsed property.<p>
+     * This does support arrays and {@link Collection}s for multiple values.
+     * In any other case a single value collection will be returned. <code>NULL</code>
+     * value contained in the parsed value will be silently removed.
+     * @param config the OSGI component configuration.
+     * @param property the configuration property
+     * @param type the desired type of the configuration values. The parsed type
+     * MUST define a {@link Constructor} taking a {@link String} as only parameter.
+     * @return the configuration values for the parsed property or <code>null</code>
+     * if the property was not contained in the parsed configuration
+     * @throws NullPointerException if the parsed type is <code>null</code>
+     * @throws IllegalArgumentException if the parsed type does not have a
+     * {@link Constructor} that takes a {@link String} as only parameter; if the
+     * {@link Constructor} is not visible or can not be instantiated (e.g.
+     * because the parsed type is an Interface or an abstract class).
+     * @throws ConfigurationException if the parsed type can not be instantiated
+     * if one of the parsed values (e.g. if {@link Float} is used as type and
+     * one of the parsed values is not a valid float).
+     * @since 0.12.1
+     */
+    public static <T> Collection<T> getConfigValues(Dictionary<String,Object> config,
+        String property, Class<T> type) throws ConfigurationException {
+        if(config == null){
+            throw new NullPointerException("The parsed Dictionary with the configuration MUST NOT be NULL!");
+        }
+        if(property == null){
+            throw new NullPointerException("The parsed configuration property MUST NOT be NULL!");
+        }
+        try {
+            return parseConfigValues(config.get(property),type);
+        } catch (IllegalStateException e){
+            throw new ConfigurationException(property, e.getMessage(),e);
+        }
+    }
+    /**
+     * Getter for all configuration values for the parsed enhancement property.<p>
+     * This does support arrays and {@link Collection}s for multiple values.
+     * In any other case a single value collection will be returned. <code>NULL</code>
+     * value contained in the parsed value will be silently removed.
+     * @param ee the enhancement engine (only used to report errors
+     * @param ci the content item (only used to report errors)
+     * @param enhProps the enhancement properties as parsed the the engine with
+     * the parsed content item
+     * @param enhProp the enhancement property
+     * @param type the desired type of the configuration values. The parsed type
+     * MUST define a {@link Constructor} taking a {@link String} as only parameter.
+     * @return the configuration values for the parsed property or <code>null</code>
+     * if the property was not contained in the parsed enhancement properties
+     * @throws NullPointerException if the parsed type is <code>null</code>
+     * @throws IllegalArgumentException if the parsed type does not have a
+     * {@link Constructor} that takes a {@link String} as only parameter; if the
+     * {@link Constructor} is not visible or can not be instantiated (e.g.
+     * because the parsed type is an Interface or an abstract class).
+     * @throws EnhancementPropertyException if the parsed type can not be instantiated
+     * if one of the parsed values (e.g. if {@link Float} is used as type and
+     * one of the parsed values is not a valid float).
+     * @since 0.12.1
+     */
+    public static <T> Collection<T> getConfigValues(EnhancementEngine ee,
+        ContentItem ci, Map<String,Object> enhProps, String enhProp, Class<T> type)
+        throws EnhancementPropertyException {
+        if(enhProp == null){
+            throw new NullPointerException("The parsed EnhancementProperty MUST NOT be NULL");
+        }
+        if(enhProps == null){
+            throw new NullPointerException("The parsed Map with the EnhancementProperties MUST NOT be NULL");
+        }
+        try {
+            return parseConfigValues(enhProps.get(enhProp), type);
+        } catch(IllegalStateException e){
+            throw new EnhancementPropertyException(ee, ci, enhProp, e.getMessage(),e);
+        }
+    }
+    
+    /**
      * Extracts multiple Configuration values from the parsed Object value.
      * This does support arrays and {@link Collection}s for multiple values.
      * In any other case a single value collection will be returned. <code>NULL</code>
@@ -999,9 +1074,87 @@ public final class EnhancementEngineHelp
      * one of the parsed values is not a valid float.
      * @since 0.12.1
      */
-    public static <T> Collection<T> getConfigValues(Object value, Class<T> type){
-        return getConfigValues(value, type, false);
+    public static <T> Collection<T> parseConfigValues(Object value, Class<T> type){
+        return parseConfigValues(value, type, false);
     }
+    
+    /**
+     * Getter for all configuration values for the parsed property.<p>
+     * This does support arrays and {@link Collection}s for multiple values.
+     * In any other case a single value collection will be returned.
+     * @param config the OSGI component configuration.
+     * @param property the configuration property
+     * @param type the desired type of the configuration values. The parsed type
+     * MUST define a {@link Constructor} taking a {@link String} as only parameter.
+     * @param preseveNullValues if <code>null</code> values in the parsed
+     * value should be preserved or removed.
+     * @return the configuration values for the parsed property or <code>null</code>
+     * if the property was not contained in the parsed configuration
+     * @throws NullPointerException if the parsed type is <code>null</code>
+     * @throws IllegalArgumentException if the parsed type does not have a
+     * {@link Constructor} that takes a {@link String} as only parameter; if the
+     * {@link Constructor} is not visible or can not be instantiated (e.g.
+     * because the parsed type is an Interface or an abstract class).
+     * @throws ConfigurationException if the parsed type can not be instantiated
+     * if one of the parsed values (e.g. if {@link Float} is used as type and
+     * one of the parsed values is not a valid float).
+     * @since 0.12.1
+     */
+    public static <T> Collection<T> getConfigValues(Dictionary<String,Object> config,
+        String property, Class<T> type, boolean preserveNullValues) throws ConfigurationException {
+        if(config == null){
+            throw new NullPointerException("The parsed Dictionary with the configuration MUST NOT be NULL!");
+        }
+        if(property == null){
+            throw new NullPointerException("The parsed configuration property MUST NOT be NULL!");
+        }
+        try {
+            return parseConfigValues(config.get(property),type, preserveNullValues);
+        } catch (IllegalStateException e){
+            throw new ConfigurationException(property, e.getMessage(),e);
+        }
+    }
+    /**
+     * Getter for all configuration values for the parsed enhancement property.<p>
+     * This does support arrays and {@link Collection}s for multiple values.
+     * In any other case a single value collection will be returned.
+     * @param ee the enhancement engine (only used to report errors
+     * @param ci the content item (only used to report errors)
+     * @param enhProps the enhancement properties as parsed the the engine with
+     * the parsed content item
+     * @param enhProp the enhancement property
+     * @param type the desired type of the configuration values. The parsed type
+     * MUST define a {@link Constructor} taking a {@link String} as only parameter.
+     * @param preseveNullValues if <code>null</code> values in the parsed
+     * value should be preserved or removed.
+     * @return the configuration values for the parsed property or <code>null</code>
+     * if the property was not contained in the parsed enhancement properties.
+     * @throws NullPointerException if the parsed type is <code>null</code>
+     * @throws IllegalArgumentException if the parsed type does not have a
+     * {@link Constructor} that takes a {@link String} as only parameter; if the
+     * {@link Constructor} is not visible or can not be instantiated (e.g.
+     * because the parsed type is an Interface or an abstract class).
+     * @throws EnhancementPropertyException if the parsed type can not be instantiated
+     * if one of the parsed values (e.g. if {@link Float} is used as type and
+     * one of the parsed values is not a valid float).
+     * @since 0.12.1
+     */
+    public static <T> Collection<T> getConfigValues(EnhancementEngine ee,
+        ContentItem ci, Map<String,Object> enhProps, String enhProp, Class<T> type,
+        boolean preserveNullValues) throws EnhancementPropertyException {
+        if(enhProp == null){
+            throw new NullPointerException("The parsed EnhancementProperty MUST NOT be NULL");
+        }
+        if(enhProps == null){
+            throw new NullPointerException("The parsed Map with the EnhancementProperties MUST NOT be NULL");
+        }
+        try {
+            return parseConfigValues(enhProps.get(enhProp), type, preserveNullValues);
+        } catch(IllegalStateException e){
+            throw new EnhancementPropertyException(ee, ci, enhProp, e.getMessage(),e);
+        }
+    }
+    
     /**
      * Extracts multiple Configuration values from the parsed Object value.
      * This does support arrays and {@link Collection}s for multiple values.
@@ -1024,8 +1177,225 @@ public final class EnhancementEngineHelp
      * one of the parsed values is not a valid float.
      * @since 0.12.1
      */
-    public static <T> Collection<T> getConfigValues(Object value, Class<T> type,
+    public static <T> Collection<T> parseConfigValues(Object value, Class<T> type,
         boolean preseveNullValues){
+        return parseConfigValues(value,type,  null, preseveNullValues);
+    }
+    /**
+     * Getter for all configuration values for the parsed property.<p>
+     * This does support arrays and {@link Collection}s for multiple values.
+     * In any other case a single value collection will be returned. <code>NULL</code>
+     * value contained in the parsed value will be silently removed.
+     * @param config the OSGI component configuration.
+     * @param property the configuration property
+     * @param type the desired type of the configuration values. The parsed type
+     * MUST define a {@link Constructor} taking a {@link String} as only parameter.
+     * @param configValues The collection to add the parsed configuration values
+     * to. If <code>null</code> an {@link ArrayList} will be used.
+     * @return the configuration values for the parsed property or <code>null</code>
+     * if the property was not contained in the parsed configuration
+     * @throws NullPointerException if the parsed type is <code>null</code>
+     * @throws IllegalArgumentException if the parsed type does not have a
+     * {@link Constructor} that takes a {@link String} as only parameter; if the
+     * {@link Constructor} is not visible or can not be instantiated (e.g.
+     * because the parsed type is an Interface or an abstract class).
+     * @throws ConfigurationException if the parsed type can not be instantiated
+     * if one of the parsed values (e.g. if {@link Float} is used as type and
+     * one of the parsed values is not a valid float).
+     * @since 0.12.1
+     */
+    public static <T> Collection<T> getConfigValues(Dictionary<String,Object> config,
+        String property, Class<T> type, Collection<T> configValues) throws ConfigurationException {
+        if(config == null){
+            throw new NullPointerException("The parsed Dictionary with the configuration MUST NOT be NULL!");
+        }
+        if(property == null){
+            throw new NullPointerException("The parsed configuration property MUST NOT be NULL!");
+        }
+        try {
+            return parseConfigValues(config.get(property),type, configValues);
+        } catch (IllegalStateException e){
+            throw new ConfigurationException(property, e.getMessage(),e);
+        }
+    }
+    /**
+     * Getter for all configuration values for the parsed enhancement property.<p>
+     * This does support arrays and {@link Collection}s for multiple values.
+     * In any other case a single value collection will be returned. <code>NULL</code>
+     * value contained in the parsed value will be silently removed.
+     * @param ee the enhancement engine (only used to report errors
+     * @param ci the content item (only used to report errors)
+     * @param enhProps the enhancement properties as parsed the the engine with
+     * the parsed content item
+     * @param enhProp the enhancement property
+     * @param type the desired type of the configuration values. The parsed type
+     * MUST define a {@link Constructor} taking a {@link String} as only parameter.
+     * @param configValues The collection to add the parsed configuration values
+     * to. If <code>null</code> an {@link ArrayList} will be used.
+     * @return the configuration values for the parsed property or <code>null</code>
+     * if the property was not contained in the parsed enhancement properties
+     * @throws NullPointerException if the parsed type is <code>null</code>
+     * @throws IllegalArgumentException if the parsed type does not have a
+     * {@link Constructor} that takes a {@link String} as only parameter; if the
+     * {@link Constructor} is not visible or can not be instantiated (e.g.
+     * because the parsed type is an Interface or an abstract class).
+     * @throws EnhancementPropertyException if the parsed type can not be instantiated
+     * if one of the parsed values (e.g. if {@link Float} is used as type and
+     * one of the parsed values is not a valid float).
+     * @since 0.12.1
+     */
+    public static <T> Collection<T> getConfigValues(EnhancementEngine ee,
+        ContentItem ci, Map<String,Object> enhProps, String enhProp, Class<T> type
+        ,Collection<T> configValues) throws EnhancementPropertyException {
+        if(enhProp == null){
+            throw new NullPointerException("The parsed EnhancementProperty MUST NOT be NULL");
+        }
+        if(enhProps == null){
+            throw new NullPointerException("The parsed Map with the EnhancementProperties MUST NOT be NULL");
+        }
+        try {
+            return parseConfigValues(enhProps.get(enhProp), type, configValues);
+        } catch(IllegalStateException e){
+            throw new EnhancementPropertyException(ee, ci, enhProp, e.getMessage(),e);
+        }
+    }
+
+    /**
+     * Extracts multiple Configuration values from the parsed Object value.
+     * This does support arrays and {@link Collection}s for multiple values.
+     * In any other case a single value collection will be returned.
+     * @param value the value. {@link Collection}s and Arrays are supported for
+     * multiple values. If the parsed value is of an other type a single value
+     * is assumed.
+     * @param type the desired type of the configuration values. The parsed type
+     * MUST define a {@link Constructor} taking a {@link String} as only parameter.
+     * @param configValues The collection to add the parsed configuration values
+     * to. If <code>null</code> an {@link ArrayList} will be used.
+     * @return the configuration values as parsed from the parsed value. 
+     * <code>null</code> if the parsed value was <code>null</code>.
+     * @throws NullPointerException if the parsed type is <code>null</code>
+     * @throws IllegalArgumentException if the parsed type does not have a
+     * {@link Constructor} that takes a {@link String} as only parameter; if the
+     * {@link Constructor} is not visible or can not be instantiated (e.g.
+     * because the parsed type is an Interface or an abstract class).
+     * @throws IllegalStateException if the parsed type can not be instantiated
+     * if one of the parsed values (e.g. if {@link Float} is used as type and
+     * one of the parsed values is not a valid float.
+     * @since 0.12.1
+     */
+    public static <T> Collection<T> parseConfigValues(Object value, 
+        Class<T> type, Collection<T> configValues){
+        return parseConfigValues(value, type, configValues,false);
+    }
+    
+    /**
+     * Getter for all configuration values for the parsed property.<p>
+     * This does support arrays and {@link Collection}s for multiple values.
+     * In any other case a single value collection will be returned.
+     * @param config the OSGI component configuration.
+     * @param property the configuration property
+     * @param type the desired type of the configuration values. The parsed type
+     * MUST define a {@link Constructor} taking a {@link String} as only parameter.
+     * @param configValues The collection to add the parsed configuration values
+     * to. If <code>null</code> an {@link ArrayList} will be used.
+     * @param preseveNullValues if <code>null</code> values in the parsed
+     * value should be preserved or removed.
+     * @return the configuration values for the parsed property or <code>null</code>
+     * if the property was not contained in the parsed configuration
+     * @throws NullPointerException if the parsed type is <code>null</code>
+     * @throws IllegalArgumentException if the parsed type does not have a
+     * {@link Constructor} that takes a {@link String} as only parameter; if the
+     * {@link Constructor} is not visible or can not be instantiated (e.g.
+     * because the parsed type is an Interface or an abstract class).
+     * @throws ConfigurationException if the parsed type can not be instantiated
+     * if one of the parsed values (e.g. if {@link Float} is used as type and
+     * one of the parsed values is not a valid float).
+     * @since 0.12.1
+     */
+    public static <T> Collection<T> getConfigValues(Dictionary<String,Object> config,
+        String property, Class<T> type, Collection<T> configValues, boolean preserveNullValues) 
+                throws ConfigurationException {
+        if(config == null){
+            throw new NullPointerException("The parsed Dictionary with the configuration MUST NOT be NULL!");
+        }
+        if(property == null){
+            throw new NullPointerException("The parsed configuration property MUST NOT be NULL!");
+        }
+        try {
+            return parseConfigValues(config.get(property),type, configValues, preserveNullValues);
+        } catch (IllegalStateException e){
+            throw new ConfigurationException(property, e.getMessage(),e);
+        }
+    }
+    /**
+     * Getter for all configuration values for the parsed enhancement property.<p>
+     * This does support arrays and {@link Collection}s for multiple values.
+     * In any other case a single value collection will be returned.
+     * @param ee the enhancement engine (only used to report errors
+     * @param ci the content item (only used to report errors)
+     * @param enhProps the enhancement properties as parsed the the engine with
+     * the parsed content item
+     * @param enhProp the enhancement property
+     * @param type the desired type of the configuration values. The parsed type
+     * MUST define a {@link Constructor} taking a {@link String} as only parameter.
+     * @param configValues The collection to add the parsed configuration values
+     * to. If <code>null</code> an {@link ArrayList} will be used.
+     * @param preseveNullValues if <code>null</code> values in the parsed
+     * value should be preserved or removed.
+     * @return the configuration values for the parsed property or <code>null</code>
+     * if the property was not contained in the parsed enhancement properties
+     * @throws NullPointerException if the parsed type is <code>null</code>
+     * @throws IllegalArgumentException if the parsed type does not have a
+     * {@link Constructor} that takes a {@link String} as only parameter; if the
+     * {@link Constructor} is not visible or can not be instantiated (e.g.
+     * because the parsed type is an Interface or an abstract class).
+     * @throws EnhancementPropertyException if the parsed type can not be instantiated
+     * if one of the parsed values (e.g. if {@link Float} is used as type and
+     * one of the parsed values is not a valid float).
+     * @since 0.12.1
+     */
+    public static <T> Collection<T> getConfigValues(EnhancementEngine ee,
+        ContentItem ci, Map<String,Object> enhProps, String enhProp, Class<T> type
+        ,Collection<T> configValues, boolean preserveNullValues) throws EnhancementPropertyException {
+        if(enhProp == null){
+            throw new NullPointerException("The parsed EnhancementProperty MUST NOT be NULL");
+        }
+        if(enhProps == null){
+            throw new NullPointerException("The parsed Map with the EnhancementProperties MUST NOT be NULL");
+        }
+        try {
+            return parseConfigValues(enhProps.get(enhProp), type, configValues, preserveNullValues);
+        } catch(IllegalStateException e){
+            throw new EnhancementPropertyException(ee, ci, enhProp, e.getMessage(),e);
+        }
+    }
+    /**
+     * Extracts multiple Configuration values from the parsed Object value.
+     * This does support arrays and {@link Collection}s for multiple values.
+     * In any other case a single value collection will be returned.
+     * @param value the value. {@link Collection}s and Arrays are supported for
+     * multiple values. If the parsed value is of an other type a single value
+     * is assumed.
+     * @param type the desired type of the configuration values. The parsed type
+     * MUST define a {@link Constructor} taking a {@link String} as only parameter.
+     * @param configValues The collection to add the parsed configuration values
+     * to. If <code>null</code> an {@link ArrayList} will be used.
+     * @param preseveNullValues if <code>null</code> values in the parsed
+     * value should be preserved or removed.
+     * @return the configuration values as parsed from the parsed value. 
+     * <code>null</code> if the parsed value was <code>null</code>.
+     * @throws NullPointerException if the parsed type is <code>null</code>
+     * @throws IllegalArgumentException if the parsed type does not have a
+     * {@link Constructor} that takes a {@link String} as only parameter; if the
+     * {@link Constructor} is not visible or can not be instantiated (e.g.
+     * because the parsed type is an Interface or an abstract class).
+     * @throws IllegalStateException if the parsed type can not be instantiated
+     * if one of the parsed values (e.g. if {@link Float} is used as type and
+     * one of the parsed values is not a valid float.
+     * @since 0.12.1
+     */
+    public static <T> Collection<T>  parseConfigValues(Object value, 
+        Class<T> type, Collection<T> configValues, boolean preseveNullValues){
         if(value == null){
             return null;
         }
@@ -1047,20 +1417,94 @@ public final class EnhancementEngineHelp
         } else {
             values = Collections.singleton(value);
         }
-        final Constructor<T> constructor = getConstigTypeConstructor(type);
-        Collection<T> configValues = new ArrayList<T>(values.size());
+        final Constructor<T> constructor = getConfigTypeConstructor(type);
+        if(configValues == null){
+            //no idea why I have to cast to C ...
+            configValues = new ArrayList<T>(values.size());
+        }
         for(Object o : values){
             if(o == null){
                 if(preseveNullValues){
                     configValues.add(null);
                 } //else skip 
             } else {
-                configValues.add(getConfigValue(o, type, constructor));
+                configValues.add(parseConfigValue(o, type, constructor));
             }
         }
         return configValues;
     }
-
+    /**
+     * Getter for the first configuration value
+     * @param config the OSGI component configuration
+     * @param property the configuration property
+     * @param type the desired type of the configuration values. The parsed type
+     * MUST define a {@link Constructor} taking a {@link String} as only parameter.
+     * @param preseveNullValues if <code>null</code> values in the parsed
+     * value should be preserved or removed.
+     * @return the configuration value as parsed from the parsed value
+     * @throws ConfigurationException if the parsed type can not be instantiated
+     * if one of the parsed values (e.g. if {@link Float} is used as type and
+     * one of the parsed values is not a valid float.
+     * @throws NullPointerException if the parsed {@link Dictionary} with the component
+     * configuration, the configuration property or the type is <code>null</code>
+     * @throws IllegalArgumentException if the parsed type does not have a
+     * {@link Constructor} that takes a {@link String} as only parameter; if the
+     * {@link Constructor} is not visible or can not be instantiated (e.g.
+     * because the parsed type is an Interface or an abstract class).
+     * @since 0.12.1
+     */
+    public static final <T> T getFirstConfigValue(Dictionary<String,Object> config,
+            String property,Class<T> type) throws ConfigurationException {
+        if(config == null){
+            throw new NullPointerException("The parsed configuration MUST NOT be NULL!");
+        }
+        if(property == null){
+            throw new NullPointerException("The pased configuration property MUST NOT be NULL!");
+        }
+        try {
+            return parseFirstConfigValue(config.get(property), type);
+        } catch(IllegalStateException e){
+            throw new ConfigurationException(property, e.getMessage(),e);
+        }
+    }
+    /**
+     * Getter for the first value of an EnhancementProperty
+     * @param ee the enhancement engine (only used for reporting errors)
+     * @param ci the content item (only used for reporting errors)
+     * @param enhProps the map with the enhancement properties
+     * @param enhProp the enhancement property
+     * @param type the desired type of the configuration values. The parsed type
+     * MUST define a {@link Constructor} taking a {@link String} as only parameter.
+     * @param preseveNullValues if <code>null</code> values in the parsed
+     * value should be preserved or removed.
+     * @return the configuration value as parsed from the parsed value
+     * @throws EnhancementPropertyException if the parsed type can not be instantiated
+     * if one of the parsed values (e.g. if {@link Float} is used as type and
+     * one of the parsed values is not a valid float.
+     * @throws NullPointerException if the parsed {@link Map} with the enhancement
+     * properties, the enhancement property or the type is <code>null</code>
+     * @throws IllegalArgumentException if the parsed type does not have a
+     * {@link Constructor} that takes a {@link String} as only parameter; if the
+     * {@link Constructor} is not visible or can not be instantiated (e.g.
+     * because the parsed type is an Interface or an abstract class).
+     * @since 0.12.1
+     */
+    public static final <T> T getFirstConfigValue(EnhancementEngine ee, 
+            ContentItem ci, Map<String,Object> enhProps,
+            String enhProp, Class<T> type) throws EnhancementPropertyException {
+        if(enhProp == null){
+            throw new NullPointerException("The parsed EnhancementProperty MUST NOT be NULL");
+        }
+        if(enhProps == null){
+            throw new NullPointerException("The parsed Map with the EnhancementProperties MUST NOT be NULL");
+        }
+        try {
+            return parseFirstConfigValue(enhProps.get(enhProp), type);
+        } catch(IllegalStateException e){
+            throw new EnhancementPropertyException(ee, ci, enhProp, e.getMessage(),e);
+        }
+    }
+    
     /**
      * Extracts a single Configuration values from the parsed Object value.
      * In case the parsed value is an Array or a Collection it will take the
@@ -1082,7 +1526,7 @@ public final class EnhancementEngineHelp
      * one of the parsed values is not a valid float.
      * @since 0.12.1
      */
-    public static final <T> T getFirstConfigValue(Object value, Class<T> type){
+    public static final <T> T parseFirstConfigValue(Object value, Class<T> type){
         if(value == null){
             return null;
         }
@@ -1114,7 +1558,7 @@ public final class EnhancementEngineHelp
         } else {
             first = value;
         }
-        return getConfigValue(first, type, getConstigTypeConstructor(type));
+        return parseConfigValue(first, type, getConfigTypeConstructor(type));
     }
 
     /**
@@ -1122,10 +1566,10 @@ public final class EnhancementEngineHelp
      * @param value
      * @param type
      * @param constructor the constructor typically retrieved by calling
-     * {@link #getConstigTypeConstructor(Class)} for the type
+     * {@link #getConfigTypeConstructor(Class)} for the type
      * @return the value
      */
-    private static <T> T getConfigValue(Object value, Class<T> type, final Constructor<T> constructor) {
+    private static <T> T parseConfigValue(Object value, Class<T> type, final Constructor<T> constructor) {
         if(value == null){
             return null;
         }
@@ -1157,7 +1601,7 @@ public final class EnhancementEngineHelp
      * @param type
      * @return
      */
-    private static <T> Constructor<T> getConstigTypeConstructor(Class<T> type) {
+    private static <T> Constructor<T> getConfigTypeConstructor(Class<T> type) {
         final Constructor<T> constructor;
         if(String.class.equals(type)){
             constructor = null;

Modified: stanbol/trunk/enhancer/generic/servicesapi/src/test/java/org/apache/stanbol/enhancer/serviceapi/helper/EnhancementEngineHelperTest.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/servicesapi/src/test/java/org/apache/stanbol/enhancer/serviceapi/helper/EnhancementEngineHelperTest.java?rev=1597711&r1=1597710&r2=1597711&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/servicesapi/src/test/java/org/apache/stanbol/enhancer/serviceapi/helper/EnhancementEngineHelperTest.java (original)
+++ stanbol/trunk/enhancer/generic/servicesapi/src/test/java/org/apache/stanbol/enhancer/serviceapi/helper/EnhancementEngineHelperTest.java Tue May 27 06:55:34 2014
@@ -19,6 +19,7 @@ package org.apache.stanbol.enhancer.serv
 import java.math.BigInteger;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.HashSet;
 
 import org.apache.clerezza.rdf.core.Language;
 import org.apache.clerezza.rdf.core.LiteralFactory;
@@ -119,132 +120,160 @@ public class EnhancementEngineHelperTest
             metadata, ta,Properties.ENHANCER_SELECTION_TAIL));
     }
     /**
-     * Tests positive cases for {@link EnhancementEngineHelper#getConfigValues(Object, Class, boolean)}
+     * Tests positive cases for {@link EnhancementEngineHelper#parseConfigValues(Object, Class, boolean)}
      */
     @Test
     public void testConfigValues(){
         Object value = new String[]{"23","27.25","-23"};
         Assert.assertEquals(
             Arrays.asList(Float.valueOf(23),Float.valueOf(27.25f),Float.valueOf(-23)), 
-            EnhancementEngineHelper.getConfigValues(value, Float.class));
+            EnhancementEngineHelper.parseConfigValues(value, Float.class));
         Assert.assertEquals(
             Arrays.asList(Double.valueOf(23),Double.valueOf(27.25f),Double.valueOf(-23)), 
-            EnhancementEngineHelper.getConfigValues(value, Double.class));
+            EnhancementEngineHelper.parseConfigValues(value, Double.class));
         Assert.assertEquals(
             Arrays.asList("23","27.25","-23"), 
-            EnhancementEngineHelper.getConfigValues(value, String.class));
+            EnhancementEngineHelper.parseConfigValues(value, String.class));
+        
         
         value = new float[]{23f,27.25f,-23f};
         Assert.assertEquals(
             Arrays.asList(Float.valueOf(23),Float.valueOf(27.25f),Float.valueOf(-23)), 
-            EnhancementEngineHelper.getConfigValues(value, Float.class));
+            EnhancementEngineHelper.parseConfigValues(value, Float.class));
         Assert.assertEquals(
             Arrays.asList(Double.valueOf(23),Double.valueOf(27.25f),Double.valueOf(-23)), 
-            EnhancementEngineHelper.getConfigValues(value, Double.class));
+            EnhancementEngineHelper.parseConfigValues(value, Double.class));
         Assert.assertEquals(
             Arrays.asList("23.0","27.25","-23.0"), 
-            EnhancementEngineHelper.getConfigValues(value, String.class));
+            EnhancementEngineHelper.parseConfigValues(value, String.class));
 
     
         value = new String[]{"23","27.25",null,"-23"};
         Assert.assertEquals(
             Arrays.asList(Float.valueOf(23),Float.valueOf(27.25f),Float.valueOf(-23)), 
-            EnhancementEngineHelper.getConfigValues(value, Float.class));
+            EnhancementEngineHelper.parseConfigValues(value, Float.class));
         Assert.assertEquals(
             Arrays.asList(Float.valueOf(23),Float.valueOf(27.25f),null,Float.valueOf(-23)), 
-            EnhancementEngineHelper.getConfigValues(value, Float.class,true));
+            EnhancementEngineHelper.parseConfigValues(value, Float.class,true));
 
         value = "23";
         Assert.assertEquals(Arrays.asList(Integer.valueOf(23)), 
-            EnhancementEngineHelper.getConfigValues(value, Integer.class));
+            EnhancementEngineHelper.parseConfigValues(value, Integer.class));
         Assert.assertEquals(Arrays.asList(Float.valueOf(23)), 
-            EnhancementEngineHelper.getConfigValues(value, Float.class));
+            EnhancementEngineHelper.parseConfigValues(value, Float.class));
         Assert.assertEquals(Arrays.asList("23"), 
-            EnhancementEngineHelper.getConfigValues(value, String.class));
+            EnhancementEngineHelper.parseConfigValues(value, String.class));
         
         value = null;
-        Assert.assertNull(EnhancementEngineHelper.getConfigValues(value, String.class));
-        Assert.assertNull(EnhancementEngineHelper.getConfigValues(value, Double.class));
+        Assert.assertNull(EnhancementEngineHelper.parseConfigValues(value, String.class));
+        Assert.assertNull(EnhancementEngineHelper.parseConfigValues(value, Double.class));
+
+        //This tests parsing an Set
+        value = new String[]{"23","27","-23","27"};
+        Assert.assertEquals(
+            new HashSet<Integer>(Arrays.asList(Integer.valueOf(23),Integer.valueOf(27),Integer.valueOf(-23))), 
+            EnhancementEngineHelper.parseConfigValues(value, Integer.class, new HashSet<Integer>(),false));
+        Assert.assertEquals(
+            new HashSet<String>(Arrays.asList("23","27","-23")), 
+            EnhancementEngineHelper.parseConfigValues(value, String.class, new HashSet<String>(),false));
+
+        //This tests parsing a Set the the config values method that allows to parse
+        //a custom collection
+        value = new String[]{"23","27",null,"-23","27", null};
+        Assert.assertEquals(
+            new HashSet<Integer>(Arrays.asList(Integer.valueOf(23),Integer.valueOf(27),Integer.valueOf(-23))), 
+            EnhancementEngineHelper.parseConfigValues(value, Integer.class, new HashSet<Integer>()));
+        Assert.assertEquals(
+            new HashSet<String>(Arrays.asList("23","27","-23")), 
+            EnhancementEngineHelper.parseConfigValues(value, String.class, new HashSet<String>()));
+
+        Assert.assertEquals(
+            new HashSet<Integer>(Arrays.asList(null, Integer.valueOf(23),Integer.valueOf(27),Integer.valueOf(-23))), 
+            EnhancementEngineHelper.parseConfigValues(value, Integer.class, new HashSet<Integer>(),true));
+        Assert.assertEquals(
+            new HashSet<String>(Arrays.asList(null,"23","27","-23")), 
+            EnhancementEngineHelper.parseConfigValues(value, String.class, new HashSet<String>(),true));
+
     }
     
     /**
-     * Tests positive cases for {@link EnhancementEngineHelper#getFirstConfigValue(Object, Class)}
+     * Tests positive cases for {@link EnhancementEngineHelper#parseFirstConfigValue(Object, Class)}
      */
     @Test
     public void testFirstConfigValue(){
         Object value = null;
-        Assert.assertNull(EnhancementEngineHelper.getFirstConfigValue(value, String.class));
-        Assert.assertNull(EnhancementEngineHelper.getFirstConfigValue(value, Double.class));
+        Assert.assertNull(EnhancementEngineHelper.parseFirstConfigValue(value, String.class));
+        Assert.assertNull(EnhancementEngineHelper.parseFirstConfigValue(value, Double.class));
         
         value = new String[]{null};
-        Assert.assertNull(EnhancementEngineHelper.getFirstConfigValue(value, String.class));
-        Assert.assertNull(EnhancementEngineHelper.getFirstConfigValue(value, Double.class));
+        Assert.assertNull(EnhancementEngineHelper.parseFirstConfigValue(value, String.class));
+        Assert.assertNull(EnhancementEngineHelper.parseFirstConfigValue(value, Double.class));
 
         value = new String[]{null,null,null};
-        Assert.assertNull(EnhancementEngineHelper.getFirstConfigValue(value, String.class));
-        Assert.assertNull(EnhancementEngineHelper.getFirstConfigValue(value, Double.class));
+        Assert.assertNull(EnhancementEngineHelper.parseFirstConfigValue(value, String.class));
+        Assert.assertNull(EnhancementEngineHelper.parseFirstConfigValue(value, Double.class));
 
         value = Arrays.asList((String)null);
-        Assert.assertNull(EnhancementEngineHelper.getFirstConfigValue(value, String.class));
-        Assert.assertNull(EnhancementEngineHelper.getFirstConfigValue(value, Double.class));
+        Assert.assertNull(EnhancementEngineHelper.parseFirstConfigValue(value, String.class));
+        Assert.assertNull(EnhancementEngineHelper.parseFirstConfigValue(value, Double.class));
 
         value = Arrays.asList(null,null,null);
-        Assert.assertNull(EnhancementEngineHelper.getFirstConfigValue(value, String.class));
-        Assert.assertNull(EnhancementEngineHelper.getFirstConfigValue(value, Double.class));
+        Assert.assertNull(EnhancementEngineHelper.parseFirstConfigValue(value, String.class));
+        Assert.assertNull(EnhancementEngineHelper.parseFirstConfigValue(value, Double.class));
 
         value = "23";
-        Assert.assertEquals("23", EnhancementEngineHelper.getFirstConfigValue(value, String.class));
-        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Integer.class));
-        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Double.class));
-        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, BigInteger.class));
+        Assert.assertEquals("23", EnhancementEngineHelper.parseFirstConfigValue(value, String.class));
+        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Integer.class));
+        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Double.class));
+        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, BigInteger.class));
         
         value = new String[]{"23"};
-        Assert.assertEquals("23", EnhancementEngineHelper.getFirstConfigValue(value, String.class));
-        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Integer.class));
-        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Double.class));
-        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, BigInteger.class));
+        Assert.assertEquals("23", EnhancementEngineHelper.parseFirstConfigValue(value, String.class));
+        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Integer.class));
+        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Double.class));
+        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, BigInteger.class));
 
         value = new int[]{23};
-        Assert.assertEquals("23", EnhancementEngineHelper.getFirstConfigValue(value, String.class));
-        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Integer.class));
-        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Double.class));
-        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, BigInteger.class));
+        Assert.assertEquals("23", EnhancementEngineHelper.parseFirstConfigValue(value, String.class));
+        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Integer.class));
+        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Double.class));
+        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, BigInteger.class));
 
         value = new String[]{"23","24"};
-        Assert.assertEquals("23", EnhancementEngineHelper.getFirstConfigValue(value, String.class));
-        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Integer.class));
-        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Double.class));
-        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, BigInteger.class));
+        Assert.assertEquals("23", EnhancementEngineHelper.parseFirstConfigValue(value, String.class));
+        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Integer.class));
+        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Double.class));
+        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, BigInteger.class));
 
         value = new int[]{23, 24};
-        Assert.assertEquals("23", EnhancementEngineHelper.getFirstConfigValue(value, String.class));
-        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Integer.class));
-        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Double.class));
-        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, BigInteger.class));
+        Assert.assertEquals("23", EnhancementEngineHelper.parseFirstConfigValue(value, String.class));
+        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Integer.class));
+        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Double.class));
+        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, BigInteger.class));
 
         value = new String[]{null,"23"};
-        Assert.assertEquals("23", EnhancementEngineHelper.getFirstConfigValue(value, String.class));
-        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Integer.class));
-        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Double.class));
-        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, BigInteger.class));
+        Assert.assertEquals("23", EnhancementEngineHelper.parseFirstConfigValue(value, String.class));
+        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Integer.class));
+        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Double.class));
+        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, BigInteger.class));
 
         value = Arrays.asList("23");
-        Assert.assertEquals("23", EnhancementEngineHelper.getFirstConfigValue(value, String.class));
-        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Integer.class));
-        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Double.class));
-        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, BigInteger.class));
+        Assert.assertEquals("23", EnhancementEngineHelper.parseFirstConfigValue(value, String.class));
+        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Integer.class));
+        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Double.class));
+        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, BigInteger.class));
 
         value = Arrays.asList("23","24");
-        Assert.assertEquals("23", EnhancementEngineHelper.getFirstConfigValue(value, String.class));
-        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Integer.class));
-        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Double.class));
-        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, BigInteger.class));
+        Assert.assertEquals("23", EnhancementEngineHelper.parseFirstConfigValue(value, String.class));
+        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Integer.class));
+        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Double.class));
+        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, BigInteger.class));
 
         value = Arrays.asList(null,"23");
-        Assert.assertEquals("23", EnhancementEngineHelper.getFirstConfigValue(value, String.class));
-        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Integer.class));
-        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, Double.class));
-        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.getFirstConfigValue(value, BigInteger.class));
+        Assert.assertEquals("23", EnhancementEngineHelper.parseFirstConfigValue(value, String.class));
+        Assert.assertEquals(Integer.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Integer.class));
+        Assert.assertEquals(Double.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, Double.class));
+        Assert.assertEquals(BigInteger.valueOf(23), EnhancementEngineHelper.parseFirstConfigValue(value, BigInteger.class));
     }
     
 }