@Test public void testWriteObjectNullWithVirtualRoot() throws Exception { JsonXML config = JsonXMLVirtualSampleRootElement.class.getAnnotation(JsonXML.class); StringWriter writer = new StringWriter(); JAXBContext context = JAXBContext.newInstance(SampleType.class); new JsonXMLBinder().writeObject(SampleType.class, config, context, writer, null); Assert.assertEquals("null", writer.toString()); }
public void writeObject(Class<?> type, JsonXML config, JAXBContext context, Writer stream, Object value) throws XMLStreamException, JAXBException { checkBindable(type); XMLStreamWriter writer = createXMLStreamWriter(type, config, stream); if (value == null) { writer.writeCharacters(null); } else { Marshaller marshaller = context.createMarshaller(); marshal(type, config, marshaller, writer, value); } writer.close(); }
JsonXMLBinder { public void writeObject(Class<?> type, JsonXML config, JAXBContext context, Writer stream, Object value) throws XMLStreamException, JAXBException { checkBindable(type); XMLStreamWriter writer = createXMLStreamWriter(type, config, stream); if (value == null) { writer.writeCharacters(null); } else { Marshaller marshaller = context.createMarshaller(); marshal(type, config, marshaller, writer, value); } writer.close(); } }
JsonXMLBinder { public void writeObject(Class<?> type, JsonXML config, JAXBContext context, Writer stream, Object value) throws XMLStreamException, JAXBException { checkBindable(type); XMLStreamWriter writer = createXMLStreamWriter(type, config, stream); if (value == null) { writer.writeCharacters(null); } else { Marshaller marshaller = context.createMarshaller(); marshal(type, config, marshaller, writer, value); } writer.close(); } JsonXMLBinder(); protected  JsonXMLBinder(boolean writeDocumentArray); protected  JsonXMLBinder(JsonXMLRootProvider rootProvider, boolean writeDocumentArray); }
JsonXMLBinder { public void writeObject(Class<?> type, JsonXML config, JAXBContext context, Writer stream, Object value) throws XMLStreamException, JAXBException { checkBindable(type); XMLStreamWriter writer = createXMLStreamWriter(type, config, stream); if (value == null) { writer.writeCharacters(null); } else { Marshaller marshaller = context.createMarshaller(); marshal(type, config, marshaller, writer, value); } writer.close(); } JsonXMLBinder(); protected  JsonXMLBinder(boolean writeDocumentArray); protected  JsonXMLBinder(JsonXMLRootProvider rootProvider, boolean writeDocumentArray); boolean isBindable(Class<?> type); T readObject(Class<? extends T> type, JsonXML config, JAXBContext context, Reader stream); void writeObject(Class<?> type, JsonXML config, JAXBContext context, Writer stream, Object value); List<T> readArray(Class<? extends T> type, JsonXML config, JAXBContext context, Reader stream); void writeArray(Class<?> type, JsonXML config, JAXBContext context, Writer stream, Collection<?> collection); }
JsonXMLBinder { public void writeObject(Class<?> type, JsonXML config, JAXBContext context, Writer stream, Object value) throws XMLStreamException, JAXBException { checkBindable(type); XMLStreamWriter writer = createXMLStreamWriter(type, config, stream); if (value == null) { writer.writeCharacters(null); } else { Marshaller marshaller = context.createMarshaller(); marshal(type, config, marshaller, writer, value); } writer.close(); } JsonXMLBinder(); protected  JsonXMLBinder(boolean writeDocumentArray); protected  JsonXMLBinder(JsonXMLRootProvider rootProvider, boolean writeDocumentArray); boolean isBindable(Class<?> type); T readObject(Class<? extends T> type, JsonXML config, JAXBContext context, Reader stream); void writeObject(Class<?> type, JsonXML config, JAXBContext context, Writer stream, Object value); List<T> readArray(Class<? extends T> type, JsonXML config, JAXBContext context, Reader stream); void writeArray(Class<?> type, JsonXML config, JAXBContext context, Writer stream, Collection<?> collection);  }