/**
 * @class JsonRpcAbstract
 * @requires Class
 */
var JsonRpcAbstract = exports.JsonRpcAbstract = function () {
    this._jsonrpc = "2.0";

    var args = [].slice.call(arguments, 0);

    if (args.length) {
        if (args.length == 1) {
            if (args[0] && typeof args[0] == 'string' && args[0].constructor == String) {
                try {
                    args = this._parse(JSON.parse(args[0]));
                } catch (e) {
                    throw JsonRpcAbstract.Exceptions.INPROPER_JSON_STRING;
                }
            } else if (args[0] && typeof args[0] == "object" && args[0].constructor == Object) {
                try {
                    args = this._parse(args[0]);
                } catch (e) {
                    throw JsonRpcAbstract.Exceptions.INPROPER_JSON;
                }
            }
        }

        this._init(args);
    }
};

JsonRpcAbstract.prototype._init = function (args) {};

JsonRpcAbstract.prototype._parse = function (json) {
    return [];
};

JsonRpcAbstract.prototype.toJson = function () {
    return {};
};

JsonRpcAbstract.prototype.toString = function () {
    return JSON.stringify(this.toJson());
};

JsonRpcAbstract.Exceptions = {};
JsonRpcAbstract.Exceptions.INPROPER_JSON_STRING = 'Inproper JSON string given';
JsonRpcAbstract.Exceptions.INPROPER_JSON = 'Inproper JSON given';
JsonRpcAbstract.Exceptions.INVALID_JSON_RPC = 'Invalid JSON-RPC given';
