class TextCodec implements ContentCodec {

    @Override
    public <T> T bytesToValue(byte[] body, DataSchema<T> schema, Map<String, String> parameters) {
        String charset = parameters.get("charset");

        String parsed;
        if (charset != null) {
            parsed = new String(body, Charset.forName(charset));
        }
        else {
            parsed = new String(body);
        }

        String type = schema.getType();
        // TODO: array, object
        switch (type) {
            case BooleanSchema
                    .TYPE:
                return (T) Boolean.valueOf(parsed);
            case IntegerSchema
                    .TYPE:
                return (T) Integer.valueOf(parsed);
            case NumberSchema
                    .TYPE:
                if (parsed.contains(".")) {
                    return (T) Double.valueOf(parsed);
                }
                else {
                    return (T) Long.valueOf(parsed);
                }
            case StringSchema
                    .TYPE:
                return (T) parsed;
            default:
                return null;
        }
    }

}