Example usage for javax.websocket DecodeException DecodeException

List of usage examples for javax.websocket DecodeException DecodeException

Introduction

In this page you can find the example usage for javax.websocket DecodeException DecodeException.

Prototype

public DecodeException(String encodedString, String message) 

Source Link

Usage

From source file:de.kaojo.chat.TextMessageDecoder.java

@Override
public Message decode(String s) throws DecodeException {
    ObjectMapper mapper = new ObjectMapper();
    try {//from w w  w  .  jav a2s .c om
        return mapper.readValue(s, Message.class);
    } catch (IOException ex) {
        Logger.getLogger(TextMessageDecoder.class.getName()).log(Level.SEVERE, null, ex);
        throw new DecodeException(s, "Encoded message could not be parsed to Message.class");
    }
}

From source file:ws.util.AbstractJSONCoder.java

@Override
public T decode(String json) throws DecodeException {
    //            logger.log(Level.INFO, new StringBuilder()
    //                  .append("[coder] decoding.. ")
    //                  .append(json)
    //                  .toString());
    try {//w w w  .  j  av  a  2 s  . c  o  m
        // TODO: ?????Jacson Jr????Jr??????
        T pojo = JSON.std.beanFrom(type, json);
        //                  logger.log(Level.INFO, new StringBuilder()
        //                        .append("[coder] done ")
        //                        .append(message)
        //                        .toString());
        return pojo;
    } catch (IOException e) {
        logger.log(Level.SEVERE, e.toString());
        throw new DecodeException(json, e.getMessage());
    }
}