private XMLReader getXMLReader(Class clazz) { if (null == xmlReader) { xmlReader = getNewXMLReader(clazz, xmlUnmarshaller.getMediaType()); } return xmlReader; }
private XMLReader getXMLReader(Class clazz) { if(null == xmlReader) { xmlReader = getNewXMLReader(clazz, xmlUnmarshaller.getMediaType() ); } return xmlReader; }
private MediaType getMediaType(BufferedReader br) { int READ_AHEAD_LIMIT = 25; try { br.mark(READ_AHEAD_LIMIT); try { char c = 0; for (int i = 0; c != -1 && i < READ_AHEAD_LIMIT; i++) { c = (char) br.read(); if (c == '[' || c == '{') { return Constants.APPLICATION_JSON; } else if (c == '<') { return Constants.APPLICATION_XML; } } } finally { br.reset(); } } catch (IOException ioException) { throw XMLMarshalException.unmarshalException(ioException); } return xmlUnmarshaller.getMediaType(); }
private MediaType getMediaType(BufferedReader br) { int READ_AHEAD_LIMIT = 25; try{ br.mark(READ_AHEAD_LIMIT); try { char c = 0; for (int i = 0; c != -1 && i < READ_AHEAD_LIMIT; i++) { c = (char) br.read(); if (c == '[' || c == '{') { return Constants.APPLICATION_JSON; }else if (c == '<'){ return Constants.APPLICATION_XML; } } } finally { br.reset(); } }catch(IOException ioException){ throw XMLMarshalException.unmarshalException(ioException); } return xmlUnmarshaller.getMediaType(); } }
if (xmlDescriptor == null || (unmarshaller.getMediaType() == MediaType.APPLICATION_JSON && unmarshaller.getJsonTypeConfiguration().getJsonTypeAttributeName() != null && !Constants.SCHEMA_TYPE_ATTRIBUTE.equals(unmarshaller.getJsonTypeConfiguration().getJsonTypeAttributeName()))) { boolean isPrimitiveType = false; if(xmlReader.isNamespaceAware()){ type = atts.getValue(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, Constants.SCHEMA_TYPE_ATTRIBUTE); } else if (unmarshaller.getMediaType() != MediaType.APPLICATION_JSON || unmarshaller.getJsonTypeConfiguration().useJsonTypeCompatibility()) { type = atts.getValue(Constants.EMPTY_STRING, Constants.SCHEMA_TYPE_ATTRIBUTE); } else if (unmarshaller.getMediaType() == MediaType.APPLICATION_JSON && unmarshaller.getJsonTypeConfiguration().getJsonTypeAttributeName() != null) { type = atts.getValue(Constants.EMPTY_STRING, unmarshaller.getJsonTypeConfiguration().getJsonTypeAttributeName());
if(xmlReader.isNamespaceAware()){ type = atts.getValue(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, Constants.SCHEMA_TYPE_ATTRIBUTE); } else if (unmarshaller.getMediaType() != MediaType.APPLICATION_JSON || unmarshaller.getJsonTypeConfiguration().useJsonTypeCompatibility()) { type = atts.getValue(Constants.EMPTY_STRING, Constants.SCHEMA_TYPE_ATTRIBUTE);