private Value preservedValues(HashMap<String, String> sampleMetadata,
HashMap<String, String> resultMetadata, Scale scale) {
int numMissing = 0;
int numChanged = 0;
BooleanValue v = (BooleanValue)scale.createValue();
StringBuilder comment = new StringBuilder();
for (String key : sampleMetadata.keySet()) {
String sampleValue = sampleMetadata.get(key);
String resultValue = resultMetadata.get(key);
if (resultValue == null) {
numMissing ++;
comment.append(" - " + key + "\n");
} else if (!resultValue.equals(sampleValue)) {
numChanged++;
comment.append(" ~ " + key + ": sample="+sampleValue+", result="+resultValue+"\n");
}
}
if ((numChanged == 0)&&(numMissing == 0)) {
v.bool(true);
v.setComment("result contains complete metadata of sample");
} else {
v.bool(false);
comment.insert(0, "following differences found: (- .. missing, ~ .. altered):\n");
v.setComment(comment.toString());
}
return v;
}