/** * Construct a JettisonMappedXmlDriver with configuration. This constructor has been added * by special request of Jettison users to support JSON generated by older Jettison * versions. if the driver is setup to ignore the XStream hints for JSON arrays, there is * neither support from XStream's side nor are there any tests to ensure this mode. * * @param config the Jettison configuration * @param useSerializeAsArray flag to use XStream's hints for collections and arrays * @since 1.4 */ public JettisonMappedXmlDriver(final Configuration config, final boolean useSerializeAsArray) { mof = new MappedXMLOutputFactory(config); mif = new MappedXMLInputFactory(config); convention = new MappedNamespaceConvention(config); this.useSerializeAsArray = useSerializeAsArray; }
public HierarchicalStreamReader createReader(File in) { InputStream instream = null; try { instream = new FileInputStream(in); return new StaxReader(new QNameMap(), mif.createXMLStreamReader(in .toURI() .toASCIIString(), instream), getNameCoder()); } catch (final XMLStreamException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } finally { if (instream != null) { try { instream.close(); } catch (IOException e) { // ignore } } } }
/** * Gives the StAX reader using the "Mapped" formatted input JSON String. * * @return The XMLStreamReader according to the JSON String. * @throws javax.xml.stream.XMLStreamException if there is an error while making the StAX reader. */ public javax.xml.stream.XMLStreamReader getReader() throws javax.xml.stream.XMLStreamException { Map<String, String> nsMap = new HashMap<String, String>(); nsMap.put("", ""); // input factory for "Mapped" convention MappedXMLInputFactory inputFactory = new MappedXMLInputFactory(nsMap); String jsonString = this.getJSONString(); return inputFactory.createXMLStreamReader(new JSONTokener(jsonString)); }
public XMLStreamReader createXMLStreamReader(JSONTokener tokener) throws XMLStreamException { try { JSONObject root = createJSONObject(tokener); return new MappedXMLStreamReader(root, convention); } catch (JSONException e) { int column = e.getColumn(); if (column == -1) { throw new XMLStreamException(e); } else { throw new XMLStreamException(e.getMessage(), new ErrorLocation(e.getLine(), e.getColumn()), e); } } }
/** {@inheritDoc} */ @Override public XmlObject readFrom(Class<XmlObject> type, Type genericType, Annotation[] annotations, MediaType m, MultivaluedMap<String, String> headers, InputStream is) throws IOException { XmlObject result = null; try { Map<String, String> nstojns = new HashMap<String, String>(); MappedXMLInputFactory factory = new MappedXMLInputFactory(nstojns); XMLStreamReader xsr = factory.createXMLStreamReader(is); Reader r = (Reader)xsr; result = parseXmlBean(type, r); xsr.close(); } catch (XMLStreamException e) { throw ExceptionUtils.toBadRequestException(e, null); } return result; }
public HierarchicalStreamReader createReader(URL in) { InputStream instream = null; try { instream = in.openStream(); return new StaxReader(new QNameMap(), mif.createXMLStreamReader( in.toExternalForm(), instream), getNameCoder()); } catch (final XMLStreamException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } finally { if (instream != null) { try { instream.close(); } catch (IOException e) { // ignore } } } }
public MappedDOMDocumentParser(Configuration con) { super(new MappedXMLInputFactory(con)); }
/** * Unmarshal data from the request. * * @param unmarshaller The unmarshaller. * @param request The request. * @return The data. */ @Override protected Object unmarshal(Unmarshaller unmarshaller, HttpServletRequest request) throws Exception { XMLStreamReader reader; JsonSerializationMethod method = JsonUtil.loadSerializationMethod(request, getDefaultSerializationMethod()); switch (method) { case xmlMapped: reader = new MappedXMLInputFactory(getNamespacesToPrefixes()).createXMLStreamReader(request.getInputStream()); break; case badgerfish: reader = new BadgerFishXMLInputFactory().createXMLStreamReader(request.getInputStream()); break; default: throw new UnsupportedOperationException(); } return unmarshaller.unmarshal(reader); }
public HierarchicalStreamReader createReader(final InputStream input) { try { return new StaxReader(new QNameMap(), mif.createXMLStreamReader(input), getNameCoder()); } catch (final XMLStreamException e) { throw new StreamException(e); } }
public JettisonMappedXmlDriver() { final HashMap nstjsons = new HashMap(); mof = new MappedXMLOutputFactory(nstjsons); mif = new MappedXMLInputFactory(nstjsons); }
/** * Unmarshal data from the request. * * @param unmarshaller The unmarshaller. * @param request The request. * @return The data. */ @Override protected Object unmarshal(Unmarshaller unmarshaller, HttpServletRequest request) throws Exception { XMLStreamReader reader; JsonSerializationMethod method = JsonUtil.loadSerializationMethod(request, getDefaultSerializationMethod()); switch (method) { case xmlMapped: reader = new MappedXMLInputFactory(getNamespacesToPrefixes()).createXMLStreamReader(request.getInputStream()); break; case badgerfish: reader = new BadgerFishXMLInputFactory().createXMLStreamReader(request.getInputStream()); break; default: throw new UnsupportedOperationException(); } return unmarshaller.unmarshal(reader); }
public HierarchicalStreamReader createReader(final Reader reader) { try { return new StaxReader(new QNameMap(), mif.createXMLStreamReader(reader), getNameCoder()); } catch (final XMLStreamException e) { throw new StreamException(e); } }
public JsonDataFormat() { final Map<?, ?> nstjsons = new HashMap<>(); mof = new MappedXMLOutputFactory(nstjsons); mif = new MappedXMLInputFactory(nstjsons); }
/** * Unmarshal data from the request. * * @param unmarshaller The unmarshaller. * @param request The request. * @return The data. */ @Override protected Object unmarshal(Unmarshaller unmarshaller, HttpServletRequest request, Class typeConstraint) throws Exception { XMLStreamReader reader; JsonSerializationMethod method = JsonUtil.loadSerializationMethod(request, getDefaultSerializationMethod()); switch (method) { case xmlMapped: reader = new MappedXMLInputFactory(getNamespacesToPrefixes()).createXMLStreamReader(request.getInputStream()); break; case badgerfish: reader = new BadgerFishXMLInputFactory().createXMLStreamReader(request.getInputStream()); break; default: throw new UnsupportedOperationException(); } if (typeConstraint != null) { return unmarshaller.unmarshal(reader, typeConstraint).getValue(); } else { return unmarshaller.unmarshal(reader); } }
public HierarchicalStreamReader createReader(File in) { try { return new StaxReader(new QNameMap(), mif.createXMLStreamReader(in .toURI() .toASCIIString(), new FileInputStream(in)), getNameCoder()); } catch (final XMLStreamException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
public XStreamConverter() { this.classMapper = new DefaultClassMapper(); Map nstjsons = new HashMap(); this.outputFactory = new MappedXMLOutputFactory(nstjsons); this.inputFactory = new MappedXMLInputFactory(nstjsons); this.objectMapper = new XStream(); }
protected HierarchicalStreamReader createHierarchicalStreamReader(Exchange exchange, InputStream stream) throws XMLStreamException { return new StaxReader(new QNameMap(), mif.createXMLStreamReader(stream)); } }
public XStreamConverter() { this.classMapper = new DefaultClassMapper(); Map nstjsons = new HashMap(); this.outputFactory = new MappedXMLOutputFactory(nstjsons); this.inputFactory = new MappedXMLInputFactory(nstjsons); this.objectMapper = new XStream(); }
public HierarchicalStreamReader createReader(URL in) { try { return new StaxReader(new QNameMap(), mif.createXMLStreamReader( in.toExternalForm(), in.openStream()), getNameCoder()); } catch (final XMLStreamException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
@Override protected AbstractXMLInputFactory getXMLInputFactory() throws XMLStreamException { AxisService service = messageContext.getAxisService(); if (service == null) { throw new XMLStreamException("AxisService not yet set; unable to create namespace map"); } //input factory for "Mapped" convention return new MappedXMLInputFactory(JSONUtil.getNS2JNSMap(service)); } }