Java 8 Binder - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Binder class.

This code example shows how to use the following methods:setEventHandler, unmarshal
			 
			// OK, unmarshall to binder 
			binder = jc.createBinder();
			JaxbValidationEventHandler eventHandler = new JaxbValidationEventHandler();
			eventHandler.setContinue(false);
			binder.setEventHandler(eventHandler);
			jaxbElement =  binder.unmarshal( doc);
			 
			//log.debug("Clone: " + XmlUtils.marshaltoString(jaxbElement, true, true)); 
			 
			return jaxbElement; 
		} catch (JAXBException ex) {
			throw new IllegalArgumentException(ex);
		} 
	} 
	 
 
	private Binder<Node> binder;
	 
	 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setEventHandler, unmarshal
		 
	}	 
	 
	private void unwrapUsually(Binder<Node> binder, Node doc) throws JAXBException {
		 
		jaxbElement =  (E) XmlUtils.unwrap(binder.unmarshal( doc ));
		// Unwrap, so we have eg CTEndnotes, not JAXBElement 
	 
		// .. but we do need to leave it wrapped,  
		// if there is not @XmlRootElement annotation  
		if (jaxbElement instanceof org.docx4j.dml.chartDrawing.CTDrawing) { 
			// Check it 
			Object tmp = binder.unmarshal( doc );
			if (tmp instanceof javax.xml.bind.JAXBElement) {
				QName qname = ((javax.xml.bind.JAXBElement)tmp).getName();
				if (qname.equals( org.docx4j.dml.chart.ObjectFactory._UserShapes_QNAME)) {
					jaxbElement=(E)tmp;	 
				} 
			} 
		} 

5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getXMLNode, unmarshal, updateXML
 
        JAXBContext ctx = JAXBContextFactory.createContext(new Class[]{Employee.class}, null);
 
        Binder binder = ctx.createBinder();
         
        Employee emp = (Employee)binder.unmarshal(parser.parse(new StringReader(xml)));
         
        emp.setName(null);
         
        binder.updateXML(emp);
         
        JAXBXMLComparer comparer = new JAXBXMLComparer();
        assertTrue("Marshalled document does not match the control document.", comparer.isNodeEqual(controlDocument, ((Node)binder.getXMLNode(emp)).getOwnerDocument()));
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getXMLNode, unmarshal, updateXML
 
        JAXBContext ctx = JAXBContextFactory.createContext(new Class[]{EmployeeA.class}, null);
 
        Binder binder = ctx.createBinder();
         
        EmployeeA emp = (EmployeeA)binder.unmarshal(parser.parse(new StringReader(xml)));
         
        emp.setName(null);
         
        binder.updateXML(emp);
         
        JAXBXMLComparer comparer = new JAXBXMLComparer();
        assertTrue("Marshalled document does not match the control document.", comparer.isNodeEqual(controlDocument, ((Node)binder.getXMLNode(emp)).getOwnerDocument()));
    } 
     
    public void testXsiNilNullMarshal() throws Exception {
        String xml = "<employee><!-- Comment 1 --><name>Matt</name><age>32</age><!-- Comment 2 --><address>Kanata</address></employee>";
        String controlSource = "org/eclipse/persistence/testing/jaxb/binder/nullpolicy/xsinil.xml";
        Document controlDocument = parser.parse(Thread.currentThread().getContextClassLoader().getResource(controlSource));
 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getXMLNode, unmarshal, updateXML
 
        JAXBContext ctx = JAXBContextFactory.createContext(new Class[]{Employee.class}, null);
 
        Binder binder = ctx.createBinder();
         
        JAXBElement emp = binder.unmarshal(parser.parse(new StringReader(xml)), Employee.class);
        ((Employee)emp.getValue()).id = 456;
        binder.updateXML(emp);
         
        JAXBXMLComparer comparer = new JAXBXMLComparer();
        assertTrue("Marshalled document does not match the control document.", comparer.isNodeEqual(controlDocument, ((Node)binder.getXMLNode(emp)).getOwnerDocument()));
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:marshal
        Binder binder = jc.createBinder();
         
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document testDocument = db.newDocument();
        binder.marshal(getControlObject(), testDocument);
        assertXMLIdentical(getControlDocument(), testDocument);
    } 
 
    protected Object getControlObject() { 
        Customer customer = new Customer();
        customer.setFirstName(CONTROL_FIRST_NAME);
        customer.setLastName(CONTROL_LAST_NAME);
        customer.setSurname(CONTROL_SURNAME);
        customer.getNicknames().add("A");
        customer.getNicknames().add("B");
 
        Address address = new Address();
        address.setStreet(CONTROL_STREET);
        customer.setAddress(address);
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:marshal
This code example shows how to use the following methods:marshal
This code example shows how to use the following methods:marshal
This code example shows how to use the following methods:unmarshal
    } 
 
    public void testUnmarshal() throws Exception {
        JAXBContext jc = JAXBContextFactory.createContext(new Class[] {Customer.class}, null);
        Binder binder = jc.createBinder();
        Customer test = (Customer) binder.unmarshal(getControlDocument());
 
        assertEquals(getControlObject(), test);
    } 
/* 
    public void testMarshal() throws Exception {  
        JAXBContext jc = JAXBContextFactory.createContext(new Class[] {Customer.class}, null); 
        Binder binder = jc.createBinder(); 
 
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 
        DocumentBuilder db = dbf.newDocumentBuilder(); 
        Document testDocument = db.newDocument(); 
        binder.marshal(getControlObject(), testDocument); 
        assertXMLIdentical(getControlDocument(), testDocument); 
    } 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 Binder Methods: