Refine search
private Unmarshaller getUnmarshaller(Class type) throws JAXBException { final ContextResolver<Unmarshaller> resolver = mtUnmarshaller.get(); if (resolver != null) { Unmarshaller u = resolver.getContext(type); if (u != null) { return u; } } final JAXBContext ctx = getJAXBContext(type); return (ctx == null) ? null : ctx.createUnmarshaller(); }
protected final Unmarshaller getUnmarshaller(Class type) throws JAXBException { if (unmarshaller != null) { Unmarshaller u = unmarshaller.getContext(type); if (u != null) { return u; } } return getJAXBContext(type).createUnmarshaller(); }
/** * Get the JAXB unmarshaller for the given class and media type. * <p> * In case this provider instance has been {@link #AbstractJaxbProvider(Providers, MediaType) * created with a fixed resolver media type}, the supplied media type argument will be ignored. * </p> * * @param type Java type to be unmarshalled. * @param mediaType entity media type. * @return JAXB unmarshaller for the requested Java type, media type combination. * @throws JAXBException in case retrieving the unmarshaller fails with a JAXB exception. */ protected final Unmarshaller getUnmarshaller(Class type, MediaType mediaType) throws JAXBException { if (fixedResolverMediaType) { return getUnmarshaller(type); } final ContextResolver<Unmarshaller> unmarshallerResolver = jaxrsProviders.getContextResolver(Unmarshaller.class, mediaType); if (unmarshallerResolver != null) { Unmarshaller u = unmarshallerResolver.getContext(type); if (u != null) { return u; } } final JAXBContext ctx = getJAXBContext(type, mediaType); return (ctx == null) ? null : ctx.createUnmarshaller(); }
private Marshaller getMarshaller(Class type) throws JAXBException { final ContextResolver<Marshaller> resolver = mtMarshaller.get(); if (resolver != null) { Marshaller u = resolver.getContext(type); if (u != null) { return u; } } final JAXBContext ctx = getJAXBContext(type); if (ctx == null) { return null; } Marshaller m = ctx.createMarshaller(); if (formattedOutput.get()) { m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, formattedOutput.get()); } return m; }
final ContextResolver<Marshaller> mcr = jaxrsProviders.getContextResolver(Marshaller.class, mediaType); if (mcr != null) { Marshaller m = mcr.getContext(type); if (m != null) { return m; Marshaller m = ctx.createMarshaller(); if (formattedOutput.get()) { m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, formattedOutput.get());
protected final Marshaller getMarshaller(Class type, MediaType mt) throws JAXBException { if (fixedMediaType) return getMarshaller(type); final ContextResolver<Marshaller> mcr = ps.getContextResolver(Marshaller.class, mt); if (mcr != null) { Marshaller m = mcr.getContext(type); if (m != null) return m; } Marshaller m = getJAXBContext(type, mt).createMarshaller(); if(formattedOutput) m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, formattedOutput); return m; }
private JAXBContext getJAXBContext(Class<?> type, MediaType mediaType) throws JAXBException { ContextResolver<JAXBContext> resolver = providers.getContextResolver(JAXBContext.class, mediaType); JAXBContext jaxbContext; if(null == resolver || null == (jaxbContext = resolver.getContext(type))) { return JAXBContext.newInstance(type); } else { return jaxbContext; } }
private Marshaller getMarshaller(Class type) throws JAXBException { if (mtMarshaller != null) { Marshaller u = mtMarshaller.getContext(type); if (u != null) return u; } Marshaller m = getJAXBContext(type).createMarshaller(); if(formattedOutput) m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, formattedOutput); return m; }
protected JAXBContext getJaxbContext(Class<?> type) throws JAXBException { // NICE perhaps caching the JAXBContext if (this.contextResolver != null) { JAXBContext jaxbContext = this.contextResolver.getContext(type); if (jaxbContext != null) { return jaxbContext; } } try { return JAXBContext.newInstance(type); } catch (NoClassDefFoundError e) { throw new WebApplicationException(Response.serverError() .entity(e.getMessage()).build()); } }
/** * Helper method that is called if no config has been explicitly configured. */ protected FastJsonConfig locateConfigProvider(Class<?> type, MediaType mediaType) { if (providers != null) { ContextResolver<FastJsonConfig> resolver = providers.getContextResolver(FastJsonConfig.class, mediaType); if (resolver == null) { resolver = providers.getContextResolver(FastJsonConfig.class, null); } if (resolver != null) { return resolver.getContext(type); } } return fastJsonConfig; }
@Override public Object getContext(final Class objectType) { for (final ContextResolver cr : cra) { @SuppressWarnings("unchecked") final Object c = cr.getContext(objectType); if (c != null) { return c; } } return null; }
private JAXBContext getJAXBContext(Class type) throws JAXBException { final ContextResolver<JAXBContext> resolver = mtContext.get(); if (resolver != null) { JAXBContext c = resolver.getContext(type); if (c != null) { return c; } } return getStoredJaxbContext(type); }
private Unmarshaller getUnmarshaller(Class type) throws JAXBException { if (mtUnmarshaller != null) { Unmarshaller u = mtUnmarshaller.getContext(type); if (u != null) return u; } return getJAXBContext(type).createUnmarshaller(); }
protected final Unmarshaller getUnmarshaller(Class type, MediaType mt) throws JAXBException { if (fixedMediaType) return getUnmarshaller(type); final ContextResolver<Unmarshaller> uncr = ps.getContextResolver(Unmarshaller.class, mt); if (uncr != null) { Unmarshaller u = uncr.getContext(type); if (u != null) return u; } return getJAXBContext(type, mt).createUnmarshaller(); }
private Marshaller getMarshaller(Class type) throws JAXBException { final ContextResolver<Marshaller> resolver = mtMarshaller.get(); if (resolver != null) { Marshaller u = resolver.getContext(type); if (u != null) { return u; } } final JAXBContext ctx = getJAXBContext(type); if (ctx == null) { return null; } Marshaller m = ctx.createMarshaller(); if (formattedOutput.get()) { m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, formattedOutput.get()); } return m; }
protected final Marshaller getMarshaller(Class type, MediaType mt) throws JAXBException { if (fixedMediaType) return getMarshaller(type); final ContextResolver<Marshaller> mcr = ps.getContextResolver(Marshaller.class, mt); if (mcr != null) { Marshaller m = mcr.getContext(type); if (m != null) return m; } Marshaller m = getJAXBContext(type, mt).createMarshaller(); if(formattedOutput) m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, formattedOutput); return m; }
private Marshaller getMarshaller(Class type) throws JAXBException { if (mtMarshaller != null) { Marshaller u = mtMarshaller.getContext(type); if (u != null) return u; } Marshaller m = getJAXBContext(type).createMarshaller(); if(formattedOutput) m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, formattedOutput); return m; }
/** * Helper method that is called if no config has been explicitly configured. */ protected FastJsonConfig locateConfigProvider(Class<?> type, MediaType mediaType) { if (providers != null) { ContextResolver<FastJsonConfig> resolver = providers.getContextResolver(FastJsonConfig.class, mediaType); if (resolver == null) { resolver = providers.getContextResolver(FastJsonConfig.class, null); } if (resolver != null) { return resolver.getContext(type); } } return fastJsonConfig; }
@Override public Object getContext(final Class objectType) { for (final ContextResolver cr : cra) { @SuppressWarnings("unchecked") final Object c = cr.getContext(objectType); if (c != null) { return c; } } return null; }
private JAXBContext getJAXBContext(Class type) throws JAXBException { final ContextResolver<JAXBContext> jaxbContextContextResolver = mtContext.get(); if (jaxbContextContextResolver != null) { JAXBContext c = jaxbContextContextResolver.getContext(type); if (c != null) { return c; } } return getStoredJAXBContext(type); }