List of usage examples for javax.xml.bind Marshaller JAXB_ENCODING
String JAXB_ENCODING
To view the source code for javax.xml.bind Marshaller JAXB_ENCODING.
Click Source Link
From source file:com.consol.citrus.admin.marshal.SpringBeanMarshaller.java
public SpringBeanMarshaller() { setContextPaths("com.consol.citrus.admin.model.spring", "com.consol.citrus.model.config.core", "com.consol.citrus.model.config.jms", "com.consol.citrus.model.config.ws", "com.consol.citrus.model.config.websocket", "com.consol.citrus.model.config.mail", "com.consol.citrus.model.config.ssh", "com.consol.citrus.model.config.vertx", "com.consol.citrus.model.config.ftp", "com.consol.citrus.model.config.mail", "com.consol.citrus.model.config.docker", "com.consol.citrus.model.config.rmi", "com.consol.citrus.model.config.jmx", "com.consol.citrus.model.config.http"); Map<String, Object> marshallerProperties = new HashMap<>(); marshallerProperties.put(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshallerProperties.put(Marshaller.JAXB_ENCODING, "UTF-8"); marshallerProperties.put(Marshaller.JAXB_FRAGMENT, true); marshallerProperties.put("com.sun.xml.bind.namespacePrefixMapper", new NamespacePrefixMapper()); setMarshallerProperties(marshallerProperties); try {//from www . j a va2s . c om afterPropertiesSet(); } catch (Exception e) { log.warn("Failed to setup configuration component marshaller", e); } }
From source file:eu.modaclouds.sla.mediator.Utils.java
public static <E> void print(E e, OutputStream os, Class<?>... classesToBeBound) throws JAXBException { JAXBContext jaxbContext;//from w w w. j a v a 2 s. c o m Marshaller jaxbMarshaller; jaxbContext = JAXBContext.newInstance(classesToBeBound); jaxbMarshaller = jaxbContext.createMarshaller(); jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); /* * http://stackoverflow.com/a/22756191 */ jaxbMarshaller.setProperty(Marshaller.JAXB_ENCODING, "utf-8"); jaxbMarshaller.marshal(e, os); }
From source file:controller.JaxbUtil.java
public Marshaller createMarshaller(String encoding) { try {/*from w w w . j av a 2 s . c o m*/ Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); if (StringUtils.isNotBlank(encoding)) { marshaller.setProperty(Marshaller.JAXB_ENCODING, encoding); } return marshaller; } catch (JAXBException ex) { throw new RuntimeException(ex); } }
From source file:com.evolveum.midpoint.cli.common.ToolsUtils.java
public static String serializeObject(Object object) throws JAXBException { if (object == null) { return null; }//w ww . j a v a2 s .com Marshaller marshaller = JAXB_CONTEXT.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_ENCODING, StandardCharsets.UTF_8.name()); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); StringWriter sw = new StringWriter(); marshaller.marshal(object, sw); return sw.toString(); }
From source file:net.sourceforge.subsonic.controller.JAXBWriter.java
private Marshaller createXmlMarshaller() throws JAXBException { Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_ENCODING, StringUtil.ENCODING_UTF8); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); return marshaller; }
From source file:com.common.util.mapper.JaxbMapper.java
/** * Marshallerencoding(?null).// ww w .ja va 2 s.c o m * ???pooling */ public static Marshaller createMarshaller(Class clazz, String encoding) throws JAXBException { JAXBContext jaxbContext = getJaxbContext(clazz); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); if (StringUtils.isNotBlank(encoding)) { marshaller.setProperty(Marshaller.JAXB_ENCODING, encoding); } return marshaller; }
From source file:com.androidwhy.modules.mapper.JaxbMapper.java
/** * Marshallerencoding(?null)./*w w w. j av a 2 s .c o m*/ * ???pooling */ public static Marshaller createMarshaller(Class clazz, String encoding) { try { JAXBContext jaxbContext = getJaxbContext(clazz); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); if (StringUtils.isNotBlank(encoding)) { marshaller.setProperty(Marshaller.JAXB_ENCODING, encoding); } return marshaller; } catch (JAXBException e) { throw Exceptions.unchecked(e); } }
From source file:com.plateform.common.util.JaxbMapper.java
/** * Marshallerencoding(?null).//from w ww . j a v a 2 s . c om * ???pooling */ public static Marshaller createMarshaller(Class clazz, String encoding) { try { JAXBContext jaxbContext = getJaxbContext(clazz); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); if (StringUtils.isNotBlank(encoding)) { marshaller.setProperty(Marshaller.JAXB_ENCODING, encoding); } return marshaller; } catch (JAXBException e) { throw ExceptionUtils.unchecked(e); } }
From source file:net.sourceforge.subsonic.controller.JAXBWriter.java
private Marshaller createJsonMarshaller() throws JAXBException { Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_ENCODING, StringUtil.ENCODING_UTF8); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, "application/json"); marshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT, true); return marshaller; }
From source file:com.topsem.common.mapper.JaxbMapper.java
/** * Marshallerencoding(?null)./* w w w. java2 s . c o m*/ * ???pooling */ public static Marshaller createMarshaller(Class clazz, String encoding) { try { JAXBContext jaxbContext = getJaxbContext(clazz); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); if (StringUtils.isNotBlank(encoding)) { marshaller.setProperty(Marshaller.JAXB_ENCODING, encoding); } return marshaller; } catch (JAXBException e) { throw Throwables.propagate(e); } }