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; }
protected Unmarshaller createUnmarshaller(Class<?> cls, Type genericType, boolean isCollection) throws JAXBException { JAXBContext context = isCollection ? getCollectionContext(cls) : getJAXBContext(cls, genericType); Unmarshaller unmarshaller = context.createUnmarshaller(); if (validateInputIfPossible) { Schema theSchema = getSchema(cls); if (theSchema != null) { unmarshaller.setSchema(theSchema); } } if (eventHandler != null) { unmarshaller.setEventHandler(eventHandler); } if (unmarshallerListener != null) { unmarshaller.setListener(unmarshallerListener); } if (uProperties != null) { for (Map.Entry<String, Object> entry : uProperties.entrySet()) { unmarshaller.setProperty(entry.getKey(), entry.getValue()); } } return unmarshaller; }
protected Unmarshaller createUnmarshaller(Class<?> cls, Type genericType, boolean isCollection) throws JAXBException { JAXBContext context = isCollection ? getCollectionContext(cls) : getJAXBContext(cls, genericType); Unmarshaller unmarshaller = context.createUnmarshaller(); Schema theSchema = getSchema(cls); if (theSchema != null) { unmarshaller.setSchema(theSchema); } if (eventHandler != null) { unmarshaller.setEventHandler(eventHandler); } if (unmarshallerListener != null) { unmarshaller.setListener(unmarshallerListener); } if (uProperties != null) { for (Map.Entry<String, Object> entry : uProperties.entrySet()) { unmarshaller.setProperty(entry.getKey(), entry.getValue()); } } return unmarshaller; }