protected XMLStreamWriter createWriter(Object actualObject, Class<?> actualClass,
Type genericType, String enc, OutputStream os, boolean isCollection) throws Exception {
QName qname = getQName(actualClass, genericType, actualObject, true);
Configuration c = new Configuration(namespaceMap);
MappedNamespaceConvention convention = new MappedNamespaceConvention(c);
AbstractXMLStreamWriter xsw = new MappedXMLStreamWriter(
convention,
new OutputStreamWriter(os, enc));
if (serializeAsArray) {
if (arrayKeys != null) {
for (String key : arrayKeys) {
xsw.seriliazeAsArray(key);
}
} else {
String key = getKey(convention, qname);
xsw.seriliazeAsArray(key);
}
}
return isCollection || dropRootElement ? new JSONCollectionWriter(xsw, qname) : xsw;
}