/** * 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> * value contained in the parsed value will be silently removed. * @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. * @return the configuration values as parsed from the parsed value * @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){ return parseConfigValues(value, type, false); }
/** * 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> * value contained in the parsed value will be silently removed. * @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. * @return the configuration values as parsed from the parsed value * @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){ return parseConfigValues(value, type, false); }
/** * 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); }
/** * 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 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 * @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, boolean preseveNullValues){ return parseConfigValues(value,type, null, preseveNullValues); } /**
/** * 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 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 * @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, boolean preseveNullValues){ return parseConfigValues(value,type, null, preseveNullValues); } /**
/** * 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); }
return parseConfigValues(config.get(property),type); } catch (IllegalStateException e){ throw new ConfigurationException(property, e.getMessage(),e);
return parseConfigValues(config.get(property),type, preserveNullValues); } catch (IllegalStateException e){ throw new ConfigurationException(property, e.getMessage(),e);
return parseConfigValues(enhProps.get(enhProp), type, configValues); } catch(IllegalStateException e){ throw new EnhancementPropertyException(ee, ci, enhProp, e.getMessage(),e);
return parseConfigValues(config.get(property),type, configValues); } catch (IllegalStateException e){ throw new ConfigurationException(property, e.getMessage(),e);
return parseConfigValues(enhProps.get(enhProp), type); } catch(IllegalStateException e){ throw new EnhancementPropertyException(ee, ci, enhProp, e.getMessage(),e);
return parseConfigValues(config.get(property),type, configValues, preserveNullValues); } catch (IllegalStateException e){ throw new ConfigurationException(property, e.getMessage(),e);
return parseConfigValues(config.get(property),type, preserveNullValues); } catch (IllegalStateException e){ throw new ConfigurationException(property, e.getMessage(),e);
return parseConfigValues(config.get(property),type); } catch (IllegalStateException e){ throw new ConfigurationException(property, e.getMessage(),e);
return parseConfigValues(enhProps.get(enhProp), type, configValues, preserveNullValues); } catch(IllegalStateException e){ throw new EnhancementPropertyException(ee, ci, enhProp, e.getMessage(),e);
return parseConfigValues(config.get(property),type, configValues); } catch (IllegalStateException e){ throw new ConfigurationException(property, e.getMessage(),e);
return parseConfigValues(enhProps.get(enhProp), type, preserveNullValues); } catch(IllegalStateException e){ throw new EnhancementPropertyException(ee, ci, enhProp, e.getMessage(),e);
return parseConfigValues(config.get(property),type, configValues, preserveNullValues); } catch (IllegalStateException e){ throw new ConfigurationException(property, e.getMessage(),e);
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<IRI>(getConfig().getEntityReferences()); if(entityRefProps != null && !entityRefProps.isEmpty()){ NamespacePrefixService nps = engine.getConfig().getNsPrefixService(); for(String prop : entityRefProps){ if(!StringUtils.isBlank(prop)){ try { entityReferences.add(new IRI( NamespaceMappingUtils.getConfiguredUri(nps, prop))); } catch(IllegalArgumentException e){ throw new DereferenceConfigurationException(e, engine.getDereferencer().getClass(), DereferenceConstants.ENTITY_REFERENCES); } } } } } /**
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<IRI>(getConfig().getEntityReferences()); if(entityRefProps != null && !entityRefProps.isEmpty()){ NamespacePrefixService nps = engine.getConfig().getNsPrefixService(); for(String prop : entityRefProps){ if(!StringUtils.isBlank(prop)){ try { entityReferences.add(new IRI( NamespaceMappingUtils.getConfiguredUri(nps, prop))); } catch(IllegalArgumentException e){ throw new DereferenceConfigurationException(e, engine.getDereferencer().getClass(), DereferenceConstants.ENTITY_REFERENCES); } } } } } /**