Example usage for com.fasterxml.jackson.jaxrs.base ProviderBase locateMapper

List of usage examples for com.fasterxml.jackson.jaxrs.base ProviderBase locateMapper

Introduction

In this page you can find the example usage for com.fasterxml.jackson.jaxrs.base ProviderBase locateMapper.

Prototype

public MAPPER locateMapper(Class<?> type, MediaType mediaType) 

Source Link

Document

Method called to locate ObjectMapper to use for serialization and deserialization.

Usage

From source file:com.github.parisoft.resty.utils.JacksonUtils.java

public static <T> T read(HttpEntity entity, Class<T> someClass, MediaType contentType) throws IOException {
    for (ProviderBase<?, ?, ?, ?> provider : DataProcessors.getInstance().values()) {
        if (provider.isReadable(someClass, null, null, contentType)) {
            return provider.locateMapper(someClass, contentType).readValue(entity.getContent(), someClass);
        }/*w w w  . j  a  v  a2  s .c o m*/
    }

    throw new IOException(String.format("no processors found for class=%s and Content-Type=%s",
            someClass.getName(), contentType));
}

From source file:com.github.parisoft.resty.utils.JacksonUtils.java

public static <T> T read(String content, Class<T> someClass, MediaType contentType) throws IOException {
    for (ProviderBase<?, ?, ?, ?> provider : DataProcessors.getInstance().values()) {
        if (provider.isReadable(someClass, null, null, contentType)) {
            return provider.locateMapper(someClass, contentType).readValue(content, someClass);
        }/*from   w ww . j  a v  a 2  s  .c  o m*/
    }

    throw new IOException(String.format("no processors found for class=%s and Content-Type=%s",
            someClass.getName(), contentType));
}

From source file:com.github.parisoft.resty.utils.JacksonUtils.java

public static String write(Object object, MediaType contentType) throws IOException {
    for (ProviderBase<?, ?, ?, ?> provider : DataProcessors.getInstance().values()) {
        if (provider.isWriteable(object.getClass(), null, null, contentType)) {
            return provider.locateMapper(object.getClass(), contentType).writeValueAsString(object);
        }/*from  w  w w  . j av  a2 s.c o m*/
    }

    throw new IOException(String.format("no processors found for class=%s and Content-Type=%s",
            object.getClass(), contentType));
}

From source file:com.github.parisoft.resty.utils.JacksonUtils.java

public static <T> T read(String content, TypeReference<T> reference, MediaType contentType) throws IOException {
    for (ProviderBase<?, ?, ?, ?> provider : DataProcessors.getInstance().values()) {
        if (provider.isReadable(reference.getClass(), reference.getType(), null, contentType)) {
            return provider.locateMapper(reference.getClass(), contentType).readValue(content, reference);
        }// www.  j ava  2 s .  co  m
    }

    throw new IOException(String.format("no processors found for type=%s and Content-Type=%s",
            reference.getType(), contentType));
}

From source file:com.github.parisoft.resty.utils.JacksonUtils.java

public static <T> T read(HttpEntity entity, TypeReference<T> reference, MediaType contentType)
        throws IOException {
    for (ProviderBase<?, ?, ?, ?> provider : DataProcessors.getInstance().values()) {
        if (provider.isReadable(reference.getClass(), reference.getType(), null, contentType)) {
            return provider.locateMapper(reference.getClass(), contentType).readValue(entity.getContent(),
                    reference);/*  w  w  w .  j a v  a  2 s . c o m*/
        }
    }

    throw new IOException(String.format("no processors found for type=%s and Content-Type=%s",
            reference.getType(), contentType));
}