List of usage examples for javax.xml.bind Marshaller JAXB_FORMATTED_OUTPUT
String JAXB_FORMATTED_OUTPUT
To view the source code for javax.xml.bind Marshaller JAXB_FORMATTED_OUTPUT.
Click Source Link
From source file:org.mule.module.apikit.leagues.Teams.java
@Transformer(resultMimeType = "text/xml") public String toXml(Teams teams) throws IOException, JAXBException { JAXBContext context = JAXBContext.newInstance(getClass()); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); ByteArrayOutputStream boas = new ByteArrayOutputStream(); m.marshal(teams, boas);/*from w w w .ja v a 2 s .c om*/ return new String(boas.toByteArray()); }
From source file:edu.htwm.vsp.phone.services.XmlMappingTest.java
@Before public void prepareXmlMarshalling() throws JAXBException { /*/*from w w w. j a va 2 s. c o m*/ * Code Duplizierung vermeiden * (DRY -> http://de.wikipedia.org/wiki/Don%E2%80%99t_repeat_yourself) und * aufwndige, immer wieder verwendete Objekte nur einmal erzeugen * */ JAXBContext context = JAXBContext.newInstance(PhoneUser.class, PhoneNumber.class); marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); unmarshaller = context.createUnmarshaller(); }
From source file:cz.muni.fi.editor.typemanager.TypeServiceImpl.java
public TypeServiceImpl() throws JAXBException { JAXBContext context = JAXBContext.newInstance(Type.class); this.unmarshaller = context.createUnmarshaller(); this.marshaller = context.createMarshaller(); this.marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); }
From source file:com.photon.phresco.plugins.util.WarConfigProcessor.java
public void save() throws JAXBException { JAXBContext jaxbContext = JAXBContext.newInstance(Assembly.class); Marshaller marshal = jaxbContext.createMarshaller(); marshal.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshal.marshal(assembly, file);//from w ww . ja va 2s . co m }
From source file:org.pmedv.jake.JakeUtil.java
/** * Updates the {@link RecentFileList} with a new file * //from w w w . java 2 s . co m * @param filename the name to append to the list */ public static void updateRecentFiles(String filename) { RecentFileList fileList = null; try { String inputDir = System.getProperty("user.home") + "/." + AppContext.getName() + "/"; String inputFileName = "recentFiles.xml"; File inputFile = new File(inputDir + inputFileName); if (inputFile.exists()) { Unmarshaller u = JAXBContext.newInstance(RecentFileList.class).createUnmarshaller(); fileList = (RecentFileList) u.unmarshal(inputFile); } if (fileList == null) fileList = new RecentFileList(); } catch (JAXBException e) { e.printStackTrace(); } if (fileList.getRecentFiles().size() >= 5) { fileList.getRecentFiles().remove(0); } if (!fileList.getRecentFiles().contains(filename)) fileList.getRecentFiles().add(filename); Marshaller m; try { String outputDir = System.getProperty("user.home") + "/." + AppContext.getName() + "/"; String outputFileName = "recentFiles.xml"; m = JAXBContext.newInstance(RecentFileList.class).createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); File output = new File(outputDir + outputFileName); m.marshal(fileList, output); } catch (JAXBException e) { e.printStackTrace(); } }
From source file:com.evolveum.midpoint.cli.common.ToolsUtils.java
public static void serializeObject(Object object, Writer writer) throws JAXBException { if (object == null) { return;//from w ww . ja va 2s.c o m } Marshaller marshaller = JAXB_CONTEXT.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_ENCODING, StandardCharsets.UTF_8.name()); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); if (object instanceof ObjectType) { object = new JAXBElement(C_OBJECT, Object.class, object); } marshaller.marshal(object, writer); }
From source file:org.mule.module.apikit.leagues.Leagues.java
@Transformer(resultMimeType = "text/xml") public String toXml(Leagues leagues) throws IOException, JAXBException { JAXBContext context = JAXBContext.newInstance(getClass()); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); ByteArrayOutputStream boas = new ByteArrayOutputStream(); m.marshal(leagues, boas);/*from w ww .java 2 s . c o m*/ return new String(boas.toByteArray()); }
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 w w w .j av a2s.c o m*/ afterPropertiesSet(); } catch (Exception e) { log.warn("Failed to setup configuration component marshaller", e); } }
From source file:es.caib.sgtsic.xml.XmlManager.java
private ByteArrayOutputStream marshal(T item, boolean formattedOutput) throws JAXBException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, formattedOutput); jaxbMarshaller.marshal(item, baos);/*from w w w . j a va2s . c om*/ return baos; }
From source file:org.sonarqube.shell.services.JsonContext.java
public Marshaller getMarshaller() { try {//from w w w . ja va 2s . c o m Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); return marshaller; } catch (JAXBException e) { throw new IllegalStateException("Bad configuration", e); } }