protected Marshaller createMarshaller(Object obj, Class<?> cls, Type genericType, String enc) throws JAXBException { Class<?> objClazz = JAXBElement.class.isAssignableFrom(cls) ? ((JAXBElement<?>)obj).getDeclaredType() : cls; JAXBContext context = getJAXBContext(objClazz, genericType); Marshaller marshaller = context.createMarshaller(); if (enc != null) { marshaller.setProperty(Marshaller.JAXB_ENCODING, enc); } if (marshallerListener != null) { marshaller.setListener(marshallerListener); } validateObjectIfNeeded(marshaller, cls, obj); return marshaller; }
protected Marshaller createMarshaller(Object obj, Class<?> cls, Type genericType, String enc) throws JAXBException { Class<?> objClazz = JAXBElement.class.isAssignableFrom(cls) ? ((JAXBElement<?>)obj).getDeclaredType() : cls; JAXBContext context = getJAXBContext(objClazz, genericType); Marshaller marshaller = context.createMarshaller(); if (enc != null) { marshaller.setProperty(Marshaller.JAXB_ENCODING, enc); } if (marshallerListener != null) { marshaller.setListener(marshallerListener); } validateObjectIfNeeded(marshaller, cls, obj); return marshaller; }