@SuppressWarnings("unchecked") @Override public void remove(String field, Object parsedValue) { if(field == null){ throw new IllegalArgumentException("The parsed field MUST NOT be NULL"); } else if(field.isEmpty()){ throw new IllegalArgumentException("The parsed field MUST NOT be Empty"); } Collection<Object> removeValues = new ArrayList<Object>(); ModelUtils.checkValues(valueFactory, parsedValue, removeValues); Object values = representation.get(field); if(values == null) { return; } else if(removeValues.contains(values)){ //in case this field has a single value and this values is part of //the values to remove -> remove the whole field representation.remove(field); } else if(values instanceof Collection<?>){ if(((Collection<Object>)values).removeAll(removeValues) && //remove all Elements ((Collection<Object>)values).size()<2){ //if removed check for size if(((Collection<Object>)values).size()==1){ //only one element remaining -> replace the collection with a Object representation.put(field, ((Collection<Object>)values).iterator().next()); } else { //if no element remains, remove the field representation.remove(field); } } } //else ignore (single value for field && value not to be removed) }
@SuppressWarnings("unchecked") @Override public void remove(String field, Object parsedValue) { if(field == null){ throw new IllegalArgumentException("The parsed field MUST NOT be NULL"); } else if(field.isEmpty()){ throw new IllegalArgumentException("The parsed field MUST NOT be Empty"); } Collection<Object> removeValues = new ArrayList<Object>(); ModelUtils.checkValues(valueFactory, parsedValue, removeValues); Object values = representation.get(field); if(values == null) { return; } else if(removeValues.contains(values)){ //in case this field has a single value and this values is part of //the values to remove -> remove the whole field representation.remove(field); } else if(values instanceof Collection<?>){ if(((Collection<Object>)values).removeAll(removeValues) && //remove all Elements ((Collection<Object>)values).size()<2){ //if removed check for size if(((Collection<Object>)values).size()==1){ //only one element remaining -> replace the collection with a Object representation.put(field, ((Collection<Object>)values).iterator().next()); } else { //if no element remains, remove the field representation.remove(field); } } } //else ignore (single value for field && value not to be removed) }
ModelUtils.checkValues(valueFactory, parsedValue, newValues); Object values = representation.get(field); if(values != null){
ModelUtils.checkValues(valueFactory, parsedValue, newValues); Object values = representation.get(field); if(values != null){
} else if(value instanceof Iterable<?>){ for(Object current : (Iterable<?>)value){ checkValues(valueFactory,current,results); checkValues(valueFactory,((Iterator<?>)value).next(),results); checkValues(valueFactory,((Enumeration<?>)value).nextElement(),results);
} else if(value instanceof Iterable<?>){ for(Object current : (Iterable<?>)value){ checkValues(valueFactory,current,results); checkValues(valueFactory,((Iterator<?>)value).next(),results); checkValues(valueFactory,((Enumeration<?>)value).nextElement(),results);
ModelUtils.checkValues(factory, value, values);
ModelUtils.checkValues(valueFactory, value, values);
ModelUtils.checkValues(factory, value, values);
ModelUtils.checkValues(factory, parsedValue, values); for(Object value : values){ if (value instanceof Value){ //native support for Sesame types!
ModelUtils.checkValues(valueFactory, value, values);
Collection<Object> removeValues = new ArrayList<Object>(); ModelUtils.checkValues(valueFactory, parsedValue, removeValues);
Collection<Object> removeValues = new ArrayList<Object>(); ModelUtils.checkValues(valueFactory, parsedValue, removeValues);
ModelUtils.checkValues(factory, parsedValue, values); for(Object value : values){ if (value instanceof Value){ //native support for Sesame types!