}
XBELHeader header = source.getHeader();
HeaderConverter hConverter = new HeaderConverter();
// Defer to HeaderConverter
Document dest = new Document(hConverter.convert(header), stmtGroups);
if (source.isSetAnnotationDefinitionGroup()) {
XBELAnnotationDefinitionGroup adGroup =
source.getAnnotationDefinitionGroup();
List<XBELInternalAnnotationDefinition> internals =
adGroup.getInternalAnnotationDefinition();
List<XBELExternalAnnotationDefinition> externals =
adGroup.getExternalAnnotationDefinition();
int size = internals.size() + externals.size();
List<AnnotationDefinition> l2 = sizedArrayList(size);
// Defer to converters
InternalAnnotationDefinitionConverter iConverter =
new InternalAnnotationDefinitionConverter();
for (final XBELInternalAnnotationDefinition iad : internals) {
l2.add(iConverter.convert(iad));
}
ExternalAnnotationDefinitionConverter eConverter =
new ExternalAnnotationDefinitionConverter();
for (final XBELExternalAnnotationDefinition ead : externals) {
l2.add(eConverter.convert(ead));
}
dest.setDefinitions(l2);
}
if (source.isSetNamespaceGroup()) {
XBELNamespaceGroup namespaceGroup = source.getNamespaceGroup();
NamespaceGroupConverter ngConverter = new NamespaceGroupConverter();
// Defer to DocumentHeaderConverter
dest.setNamespaceGroup(ngConverter.convert(namespaceGroup));
}
// Resolve any property references to instances
dest.resolveReferences();
return dest;
}