@Test public void testReadArrayNullWithVirtualRoot() throws Exception { JsonXML config = JsonXMLVirtualSampleRootElement.class.getAnnotation(JsonXML.class); JAXBContext context = JAXBContext.newInstance(SampleType.class); Assert.assertNotNull(new JsonXMLBinder().readArray(SampleType.class, config, context, new StringReader("null"))); }
public <T> List<T> readArray(Class<? extends T> type, JsonXML config, JAXBContext context, Reader stream) throws XMLStreamException, JAXBException { checkBindable(type); XMLStreamReader reader = createXMLStreamReader(type, config, stream); List<T> result; if (reader.isCharacters() && reader.getText() == null) { result = null; } else { boolean documentArray = JsonXMLStreamConstants.MULTIPLE_PI_TARGET.equals(reader.getPITarget()); Unmarshaller unmarshaller = context.createUnmarshaller(); while (reader.hasNext() && !reader.isStartElement() && !reader.isCharacters()) { reader.next(); } result = new ArrayList<T>(); while (reader.hasNext() || reader.isCharacters() && reader.getText() == null) { if (reader.isCharacters() && reader.getText() == null) { result.add(null); if (reader.hasNext()) { reader.next(); } else { break; } } else { result.add(unmarshal(type, config, unmarshaller, reader)); if (documentArray && reader.hasNext()) { reader.next(); } } } } reader.close(); return result; }
JsonXMLBinder { public <T> List<T> readArray(Class<? extends T> type, JsonXML config, JAXBContext context, Reader stream) throws XMLStreamException, JAXBException { checkBindable(type); XMLStreamReader reader = createXMLStreamReader(type, config, stream); List<T> result; if (reader.isCharacters() && reader.getText() == null) { result = null; } else { boolean documentArray = JsonXMLStreamConstants.MULTIPLE_PI_TARGET.equals(reader.getPITarget()); Unmarshaller unmarshaller = context.createUnmarshaller(); while (reader.hasNext() && !reader.isStartElement() && !reader.isCharacters()) { reader.next(); } result = new ArrayList<T>(); while (reader.hasNext() || reader.isCharacters() && reader.getText() == null) { if (reader.isCharacters() && reader.getText() == null) { result.add(null); if (reader.hasNext()) { reader.next(); } else { break; } } else { result.add(unmarshal(type, config, unmarshaller, reader)); if (documentArray && reader.hasNext()) { reader.next(); } } } } reader.close(); return result; } }
JsonXMLBinder { public <T> List<T> readArray(Class<? extends T> type, JsonXML config, JAXBContext context, Reader stream) throws XMLStreamException, JAXBException { checkBindable(type); XMLStreamReader reader = createXMLStreamReader(type, config, stream); List<T> result; if (reader.isCharacters() && reader.getText() == null) { result = null; } else { boolean documentArray = JsonXMLStreamConstants.MULTIPLE_PI_TARGET.equals(reader.getPITarget()); Unmarshaller unmarshaller = context.createUnmarshaller(); while (reader.hasNext() && !reader.isStartElement() && !reader.isCharacters()) { reader.next(); } result = new ArrayList<T>(); while (reader.hasNext() || reader.isCharacters() && reader.getText() == null) { if (reader.isCharacters() && reader.getText() == null) { result.add(null); if (reader.hasNext()) { reader.next(); } else { break; } } else { result.add(unmarshal(type, config, unmarshaller, reader)); if (documentArray && reader.hasNext()) { reader.next(); } } } } reader.close(); return result; } JsonXMLBinder(); protected  JsonXMLBinder(boolean writeDocumentArray); protected  JsonXMLBinder(JsonXMLRootProvider rootProvider, boolean writeDocumentArray); }
JsonXMLBinder { public <T> List<T> readArray(Class<? extends T> type, JsonXML config, JAXBContext context, Reader stream) throws XMLStreamException, JAXBException { checkBindable(type); XMLStreamReader reader = createXMLStreamReader(type, config, stream); List<T> result; if (reader.isCharacters() && reader.getText() == null) { result = null; } else { boolean documentArray = JsonXMLStreamConstants.MULTIPLE_PI_TARGET.equals(reader.getPITarget()); Unmarshaller unmarshaller = context.createUnmarshaller(); while (reader.hasNext() && !reader.isStartElement() && !reader.isCharacters()) { reader.next(); } result = new ArrayList<T>(); while (reader.hasNext() || reader.isCharacters() && reader.getText() == null) { if (reader.isCharacters() && reader.getText() == null) { result.add(null); if (reader.hasNext()) { reader.next(); } else { break; } } else { result.add(unmarshal(type, config, unmarshaller, reader)); if (documentArray && reader.hasNext()) { reader.next(); } } } } reader.close(); return result; } 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 <T> List<T> readArray(Class<? extends T> type, JsonXML config, JAXBContext context, Reader stream) throws XMLStreamException, JAXBException { checkBindable(type); XMLStreamReader reader = createXMLStreamReader(type, config, stream); List<T> result; if (reader.isCharacters() && reader.getText() == null) { result = null; } else { boolean documentArray = JsonXMLStreamConstants.MULTIPLE_PI_TARGET.equals(reader.getPITarget()); Unmarshaller unmarshaller = context.createUnmarshaller(); while (reader.hasNext() && !reader.isStartElement() && !reader.isCharacters()) { reader.next(); } result = new ArrayList<T>(); while (reader.hasNext() || reader.isCharacters() && reader.getText() == null) { if (reader.isCharacters() && reader.getText() == null) { result.add(null); if (reader.hasNext()) { reader.next(); } else { break; } } else { result.add(unmarshal(type, config, unmarshaller, reader)); if (documentArray && reader.hasNext()) { reader.next(); } } } } reader.close(); return result; } 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);  }