return sampleObject;
}
private FormatInfo getFormatInfo(Element sample, String mime) {
FormatInfo info = new FormatInfo();
info.setMimeType(mime);
String uid = sample.attributeValue("uid");
List<Element> records = sample.elements("record");
List<Element> formats = new ArrayList<Element>();
List<Element> versions = new ArrayList<Element>();
List<Element> puids = new ArrayList<Element>();
for (Element rec : records) {
if (rec.attributeValue("name").equals("format")) {
formats.add(rec);
}
if (rec.attributeValue("name").equals("format_version")) {
versions.add(rec);
}
if (rec.attributeValue("name").equals("puid")) {
puids.add(rec);
}
}
if (formats.size() > 1) {
info.setName("Conflict");
} else if (formats.size() == 1) {
Element format = (Element) formats.get(0);
info.setName(format.attributeValue("value"));
}
if (versions.size() > 1) {
info.setVersion("Conflict");
} else if (versions.size() == 1) {
Element version = (Element) versions.get(0);
info.setVersion(version.attributeValue("value"));
}
if (puids.size() > 1) {
info.setPuid("Conflict");
} else if (puids.size() == 1) {
Element puid = (Element) puids.get(0);
info.setPuid(puid.attributeValue("value"));
}
return info;
}