Example usage for io.vertx.core.json DecodeException DecodeException

List of usage examples for io.vertx.core.json DecodeException DecodeException

Introduction

In this page you can find the example usage for io.vertx.core.json DecodeException DecodeException.

Prototype

public DecodeException(String message) 

Source Link

Usage

From source file:com.tesco.mewbase.bson.Bson.java

License:Open Source License

public static <T> T decodeValue(InputStream inputStream, Class<T> clazz) throws DecodeException {
    try {// w ww . j  a v  a 2 s .  c  o  m
        return mapper.readValue(inputStream, clazz);
    } catch (Exception e) {
        throw new DecodeException("Failed to decode BSON:" + e.getMessage());
    }
}

From source file:io.apiman.gateway.platforms.vertx3.common.verticles.Json.java

License:Apache License

public static <C extends Collection<? super T>, T> C decodeValue(String str, Class<C> collectionClazz,
        Class<T> targetClazz) throws DecodeException {
    try {//from   w w w .  j  ava 2  s  .c o  m
        return mapper.readValue(str,
                TypeFactory.defaultInstance().constructCollectionType(collectionClazz, targetClazz));
    } catch (Exception e) {
        throw new DecodeException("Failed to decode:" + e.getMessage()); //$NON-NLS-1$
    }
}

From source file:io.knotx.knot.service.service.ServiceEngine.java

License:Apache License

private JsonObject buildResultObject(AdapterResponse adapterResponse) {
    JsonObject object = new JsonObject();

    String rawData = adapterResponse.getResponse().getBody().toString().trim();

    if (rawData.charAt(0) == '[') {
        object.put(RESULT_NAMESPACE_KEY, new JsonArray(rawData));
    } else if (rawData.charAt(0) == '{') {
        object.put(RESULT_NAMESPACE_KEY, new JsonObject(rawData));
    } else {/*from ww w  . j  a  v  a  2  s .  com*/
        throw new DecodeException("Result is neither Json Array nor Json Object");
    }
    object.put(RESPONSE_NAMESPACE_KEY, new JsonObject().put("statusCode",
            Integer.toString(adapterResponse.getResponse().getStatusCode())));
    return object;
}