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:esg.node.components.registry.AzsWhitelistGleaner.java
public synchronized boolean saveAzsWhitelist(AzsWhitelist azss) { boolean success = false; if (azss == null) { log.error("azss (whitelist) is null ? [" + azss + "]"); return success; }/*from w ww . j a va 2 s . c o m*/ log.trace("Saving AZS Whitelist information to " + azsWhitelistPath + azsWhitelistFile); try { JAXBContext jc = JAXBContext.newInstance(AzsWhitelist.class); Marshaller m = jc.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(azss, new FileOutputStream(azsWhitelistPath + azsWhitelistFile)); success = true; } catch (Exception e) { log.error(e); } return success; }
From source file:esg.node.components.registry.IdpWhitelistGleaner.java
public synchronized boolean saveIdpWhitelist(IdpWhitelist idps) { boolean success = false; if (idps == null) { log.error("idps (whitelist) is null ? [" + idps + "]"); return success; }//ww w.j ava 2s. c om log.trace("Saving IDP Whitelist information to " + idpWhitelistPath + idpWhitelistFile); try { JAXBContext jc = JAXBContext.newInstance(IdpWhitelist.class); Marshaller m = jc.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(idps, new FileOutputStream(idpWhitelistPath + idpWhitelistFile)); success = true; } catch (Exception e) { log.error(e); } return success; }
From source file:org.apache.lens.regression.util.Util.java
public static Marshaller getMarshaller(Class clazz) { JAXBContext jaxbContext = null; try {/*w ww .j ava 2 s . c o m*/ jaxbContext = new LensJAXBContext(clazz); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); return jaxbMarshaller; } catch (JAXBException e) { log.error("Error : ", e); } return null; }
From source file:at.ac.tuwien.dsg.cloud.salsa.engine.smartdeployment.main.SmartDeploymentService.java
@POST @Path("/requirement/{serviceName}") @Consumes(MediaType.APPLICATION_XML)//from ww w . j a va 2 s .c om public void submitQuelleRequirementForService(MultiLevelRequirements requirements, @PathParam("serviceName") String serviceName) { String saveAs = SalsaConfiguration.getToscaTemplateStorage() + File.separator + serviceName + requirementExt; JAXBContext jaxbContext; try { jaxbContext = JAXBContext.newInstance(MultiLevelRequirements.class); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); jaxbMarshaller.marshal(requirements, new File(saveAs)); } catch (JAXBException ex) { EngineLogger.logger.error("Cannot marshall the multilevel requirements that you submitted !"); ex.printStackTrace(); } }
From source file:edu.harvard.hms.dbmi.i2b2.api.ont.ONTCell.java
/** * Sets up the system without any parameters of the Ontology Management Cell * //from w w w . j a v a 2 s. c o m * @throws JAXBException */ public void setup() throws JAXBException { // Setup System ontOF = new ObjectFactory(); ontJC = JAXBContext.newInstance("edu.harvard.hms.dbmi.i2b2.api.ont.xml"); ontMarshaller = ontJC.createMarshaller(); ontMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); }
From source file:mx.bigdata.sat.cfd.CFDv22.java
public void guardar(OutputStream out) throws Exception { Marshaller m = context.createMarshaller(); m.setProperty("com.sun.xml.bind.namespacePrefixMapper", new NamespacePrefixMapperImpl(localPrefixes)); m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, "http://www.sat.gob.mx/cfd/2 " + "http://www.sat.gob.mx/sitio_internet/cfd/2/cfdv22.xsd"); byte[] xmlHeaderBytes = XML_HEADER.getBytes("UTF8"); out.write(xmlHeaderBytes);//from w w w . j av a2 s . co m m.marshal(document, out); }
From source file:labr_client.xml.ObjToXML.java
public static void saveProfile(Component[] comps, String profile) { try {/*from w w w. j ava 2 s . com*/ if (comps != null) { JAXBContext context = JAXBContext.newInstance(LabrRequest.class); Marshaller m = context.createMarshaller(); //for pretty-print XML in JAXB m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); LabrRequest request = new LabrRequest(); for (Component comp : comps) { if (comp.getName() != null) { if (comp.getName().equals("name")) { request.patient.name.setValue(((JTextField) comp).getText()); request.patient.name.setX(comp.getX()); request.patient.name.setY(comp.getY()); request.patient.name.setWidth(comp.getWidth()); } else if (comp.getName().equals("firstName")) { request.patient.firstName.setValue(((JTextField) comp).getText()); request.patient.firstName.setX(comp.getX()); request.patient.firstName.setY(comp.getY()); request.patient.firstName.setWidth(comp.getWidth()); } else if (comp.getName().equals("birthDate")) { request.patient.birthDate.setValue(((JFormattedTextField) comp).getText()); request.patient.birthDate.setX(comp.getX()); request.patient.birthDate.setY(comp.getY()); request.patient.birthDate.setWidth(comp.getWidth()); } else if (comp.getName().equals("gender")) { request.patient.gender.setValue((String) (((JComboBox) comp).getSelectedItem())); request.patient.gender.setX(comp.getX()); request.patient.gender.setY(comp.getY()); } else if (comp.getName().equals("straatAndNumber")) { request.patient.straatAndNumber.setValue(((JTextField) comp).getText()); request.patient.straatAndNumber.setX(comp.getX()); request.patient.straatAndNumber.setY(comp.getY()); request.patient.straatAndNumber.setWidth(comp.getWidth()); } else if (comp.getName().equals("zip")) { request.patient.zip.setValue(((JTextField) comp).getText()); request.patient.zip.setX(comp.getX()); request.patient.zip.setY(comp.getY()); request.patient.zip.setWidth(comp.getWidth()); } else if (comp.getName().equals("city")) { request.patient.city.setValue(((JTextField) comp).getText()); request.patient.city.setX(comp.getX()); request.patient.city.setY(comp.getY()); request.patient.city.setWidth(comp.getWidth()); } else if (comp.getName().equals("country")) { request.patient.country.setValue((String) (((JComboBox) comp).getSelectedItem())); request.patient.country.setX(comp.getX()); request.patient.country.setY(comp.getY()); } else if (comp.getName().equals("nationalNumber")) { request.patient.nationalNumber.setValue(((JTextField) comp).getText()); request.patient.nationalNumber.setX(comp.getX()); request.patient.nationalNumber.setY(comp.getY()); request.patient.nationalNumber.setWidth(comp.getWidth()); } else if (comp.getName().equals("Save")) { JButton jbut = (JButton) comp; ImageIcon icon = (ImageIcon) jbut.getIcon(); request.buttons.save.setX(comp.getX()); request.buttons.save.setY(comp.getY()); request.buttons.save.setValue("Save"); if (icon != null) { request.buttons.save.setIcon(icon.getDescription()); } } else if (comp.getName().equals("Search")) { } else if (comp.getName().equals("saveAndSend")) { request.patient.nationalNumber.setValue(((JTextField) comp).getText()); request.patient.nationalNumber.setX(comp.getX()); request.patient.nationalNumber.setY(comp.getY()); request.patient.nationalNumber.setWidth(comp.getWidth()); } else if (comp.getName().equals("print")) { request.patient.nationalNumber.setValue(((JTextField) comp).getText()); request.patient.nationalNumber.setX(comp.getX()); request.patient.nationalNumber.setY(comp.getY()); request.patient.nationalNumber.setWidth(comp.getWidth()); } else { Class<? extends Component> c = comp.getClass(); if (c.getSimpleName().equals("JLabel")) { JLabel lbl = (JLabel) comp; LabrXMLLabel l = new LabrXMLLabel(); l.setColor(String.valueOf(lbl.getForeground().getRGB())); l.setSize(lbl.getFont().getSize()); l.setId(lbl.getName()); l.setValue(lbl.getText()); l.setX(lbl.getX()); l.setY(lbl.getY()); request.labels.getLabel().add(l); } ; if (c.getSimpleName().equals("JCheckBox")) { JCheckBox chbx = (JCheckBox) comp; LabrXMLRequest req = new LabrXMLRequest(); req.setX(chbx.getX()); req.setY(chbx.getY()); req.setLoinc(chbx.getName()); req.setValue(chbx.getText()); req.setSelected(chbx.isSelected()); request.requests.getRequest().add(req); } ; if (c.getSimpleName().equals("JTextBox")) { } ; } } } m.marshal(request, new File(PublicVars.getUserData()[9] + "\\" + profile + ".xml")); } } catch (JAXBException e) { e.printStackTrace(); } }
From source file:org.javelin.sws.ext.bind.SweJaxbMarshaller.java
@Override public void setProperty(String name, Object value) throws PropertyException { if (Marshaller.JAXB_FORMATTED_OUTPUT.equals(name)) this.formatting = (Boolean) value; else if (Marshaller.JAXB_FRAGMENT.equals(name)) this.fragment = (Boolean) value; else if (Marshaller.JAXB_ENCODING.equals(name)) this.encoding = (String) value; else if (SweJaxbConstants.SWE_MARSHALLER_PROPERTY_JAXB_MULTIREFS.equals(name)) this.multiRefEncoding = (Boolean) value; else if (SweJaxbConstants.SWE_MARSHALLER_PROPERTY_SEND_TYPES.equals(name)) this.sendTypes = (Boolean) value; else//from w ww . j a va 2 s.c om this.properties.put(name, value); }
From source file:dk.statsbiblioteket.doms.licensemodule.integrationtest.LicenseModuleRestWSTester.java
@SuppressWarnings("all") private static void testGetUsersLicenses() throws Exception { // GetUserLicensesOutputDTO getUserLicenses GetUsersLicensesInputDTO input = new GetUsersLicensesInputDTO(); input.setAttributes(createUserObjAttributeDTO()); input.setLocale("da"); JAXBContext context = JAXBContext.newInstance(GetUsersLicensesInputDTO.class); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(input, outputStream);/*from w w w .j ava 2 s.c om*/ // serialize to XML String inputXML = outputStream.toString(); System.out.println("input xml:\n" + inputXML); ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); WebResource service = client .resource(UriBuilder.fromUri("http://localhost:8080/licensemodule/services/").build()); // Call with XML //GetUsersLicensesOutputDTO output = service.path("getUserLicenses").type(MediaType.TEXT_XML).accept(MediaType.TEXT_XML).entity(inputXML).post(GetUsersLicensesOutputDTO.class); // Call with @XmlRootElement GetUsersLicensesOutputDTO output = service.path("getUserLicenses").type(MediaType.TEXT_XML) .accept(MediaType.TEXT_XML).entity(input).post(GetUsersLicensesOutputDTO.class); context = JAXBContext.newInstance(GetUsersLicensesOutputDTO.class); outputStream = new ByteArrayOutputStream(); m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(output, outputStream); // serialize to XML String outputXML = outputStream.toString(); System.out.println(outputXML); System.out.println("output, licensenames:" + output.getLicenses()); }
From source file:org.jellycastle.maven.Maven.java
/** * Serialize Maven POM object tree.//w w w . j a v a2s. c o m * @param outputStream */ public void serialize(Project project, OutputStream outputStream) { StreamResult stream = new StreamResult(outputStream); Map<String, Object> marshallerProperties = new HashMap<String, Object>(); marshallerProperties.put(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshallerProperties.put(Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION, ""); marshaller.setMarshallerProperties(marshallerProperties); marshaller.marshal(project, stream); }