/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
/** @module vertx-js/json_event */
var utils = require('vertx-js/util/utils');
var Buffer = require('vertx-js/buffer');
var Promise = require('vertx-js/promise');
var io = Packages.io;
var JsonObject = io.vertx.core.json.JsonObject;
var JsonArray = io.vertx.core.json.JsonArray;
var JJsonEvent = Java.type('io.vertx.core.parsetools.JsonEvent');
/**
@class
*/
var JsonEvent = function(j_val) {
var j_jsonEvent = j_val;
var that = this;
var __super_type = this.type;
var __super_fieldName = this.fieldName;
var __super_value = this.value;
var __super_isNumber = this.isNumber;
var __super_integerValue = this.integerValue;
var __super_longValue = this.longValue;
var __super_floatValue = this.floatValue;
var __super_doubleValue = this.doubleValue;
var __super_isBoolean = this.isBoolean;
var __super_booleanValue = this.booleanValue;
var __super_isString = this.isString;
var __super_stringValue = this.stringValue;
var __super_binaryValue = this.binaryValue;
var __super_isNull = this.isNull;
var __super_isObject = this.isObject;
var __super_objectValue = this.objectValue;
var __super_isArray = this.isArray;
var __super_arrayValue = this.arrayValue;
var __super_mapTo = this.mapTo;
/**
@public
@return {Object} the type of the event
*/
this.type = function() {
var __args = arguments;
if (__args.length === 0) {
return utils.convReturnEnum(j_jsonEvent["type()"]()) ;
} else if (typeof __super_type != 'undefined') {
return __super_type.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
@public
@return {string} the name of the field when the event is emitted as a JSON object member
*/
this.fieldName = function() {
var __args = arguments;
if (__args.length === 0) {
return j_jsonEvent["fieldName()"]() ;
} else if (typeof __super_fieldName != 'undefined') {
return __super_fieldName.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
@public
@return {Object} the json value for events
*/
this.value = function() {
var __args = arguments;
if (__args.length === 0) {
return utils.convReturnTypeUnknown(j_jsonEvent["value()"]()) ;
} else if (typeof __super_value != 'undefined') {
return __super_value.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
@public
@return {boolean} true when the JSON value is a number
*/
this.isNumber = function() {
var __args = arguments;
if (__args.length === 0) {
return j_jsonEvent["isNumber()"]() ;
} else if (typeof __super_isNumber != 'undefined') {
return __super_isNumber.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
@public
@return {number} the <code>Integer</code> value or <code>null</code> if the event has no JSON value
*/
this.integerValue = function() {
var __args = arguments;
if (__args.length === 0) {
return j_jsonEvent["integerValue()"]() ;
} else if (typeof __super_integerValue != 'undefined') {
return __super_integerValue.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
@public
@return {number} the <code>Long</code> value or <code>null</code> if the event has no JSON value
*/
this.longValue = function() {
var __args = arguments;
if (__args.length === 0) {
return utils.convReturnLong(j_jsonEvent["longValue()"]()) ;
} else if (typeof __super_longValue != 'undefined') {
return __super_longValue.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
@public
@return {number} the <code>Float</code> value or <code>null</code> if the event has no JSON value
*/
this.floatValue = function() {
var __args = arguments;
if (__args.length === 0) {
return j_jsonEvent["floatValue()"]() ;
} else if (typeof __super_floatValue != 'undefined') {
return __super_floatValue.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
@public
@return {number} the <code>Double</code> value or <code>null</code> if the event has no JSON value
*/
this.doubleValue = function() {
var __args = arguments;
if (__args.length === 0) {
return j_jsonEvent["doubleValue()"]() ;
} else if (typeof __super_doubleValue != 'undefined') {
return __super_doubleValue.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
@public
@return {boolean} true when the JSON value is a boolean
*/
this.isBoolean = function() {
var __args = arguments;
if (__args.length === 0) {
return j_jsonEvent["isBoolean()"]() ;
} else if (typeof __super_isBoolean != 'undefined') {
return __super_isBoolean.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
@public
@return {boolean} the <code>Boolean</code> value or <code>null</code> if the event has no JSON value
*/
this.booleanValue = function() {
var __args = arguments;
if (__args.length === 0) {
return j_jsonEvent["booleanValue()"]() ;
} else if (typeof __super_booleanValue != 'undefined') {
return __super_booleanValue.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
@public
@return {boolean} true when the JSON value is a string
*/
this.isString = function() {
var __args = arguments;
if (__args.length === 0) {
return j_jsonEvent["isString()"]() ;
} else if (typeof __super_isString != 'undefined') {
return __super_isString.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
@public
@return {string} the string value or <code>null</code> if the event has no JSON value
*/
this.stringValue = function() {
var __args = arguments;
if (__args.length === 0) {
return j_jsonEvent["stringValue()"]() ;
} else if (typeof __super_stringValue != 'undefined') {
return __super_stringValue.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
Return the binary value.
<p>
JSON itself has no notion of a binary, this extension complies to the RFC-7493, so this method assumes there is a
String value with the key and it contains a Base64 encoded binary, which it decodes if found and returns.
@public
@return {Buffer} the binary value or <code>null</code> if the event has no JSON value
*/
this.binaryValue = function() {
var __args = arguments;
if (__args.length === 0) {
return utils.convReturnVertxGen(Buffer, j_jsonEvent["binaryValue()"]()) ;
} else if (typeof __super_binaryValue != 'undefined') {
return __super_binaryValue.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
@public
@return {boolean} true when the JSON value is null
*/
this.isNull = function() {
var __args = arguments;
if (__args.length === 0) {
return j_jsonEvent["isNull()"]() ;
} else if (typeof __super_isNull != 'undefined') {
return __super_isNull.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
@public
@return {boolean} true when the JSON value is a JSON object
*/
this.isObject = function() {
var __args = arguments;
if (__args.length === 0) {
return j_jsonEvent["isObject()"]() ;
} else if (typeof __super_isObject != 'undefined') {
return __super_isObject.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
@public
@return {Object} the JSON object value or <code>null</code> if the event has no JSON value
*/
this.objectValue = function() {
var __args = arguments;
if (__args.length === 0) {
return utils.convReturnJson(j_jsonEvent["objectValue()"]()) ;
} else if (typeof __super_objectValue != 'undefined') {
return __super_objectValue.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
@public
@return {boolean} true when the JSON value is a JSON array
*/
this.isArray = function() {
var __args = arguments;
if (__args.length === 0) {
return j_jsonEvent["isArray()"]() ;
} else if (typeof __super_isArray != 'undefined') {
return __super_isArray.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
@public
@return {Array} the JSON array value or <code>null</code> if the event has no JSON value
*/
this.arrayValue = function() {
var __args = arguments;
if (__args.length === 0) {
return utils.convReturnJson(j_jsonEvent["arrayValue()"]()) ;
} else if (typeof __super_arrayValue != 'undefined') {
return __super_arrayValue.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
/**
Decodes and returns the current value as the specified <code>type</code>.
@public
@param type {todo} the type to decode the value to
@return {Object} the decoded value
*/
this.mapTo = function(type) {
var __args = arguments;
if (__args.length === 1 && typeof __args[0] === 'function') {
return utils.get_jtype(__args[0]).wrap(j_jsonEvent["mapTo(java.lang.Class)"](utils.get_jclass(type))) ;
} else if (typeof __super_mapTo != 'undefined') {
return __super_mapTo.apply(this, __args);
}
else throw new TypeError('function invoked with invalid arguments');
};
// A reference to the underlying Java delegate
// NOTE! This is an internal API and must not be used in user code.
// If you rely on this property your code is likely to break if we change it / remove it without warning.
this._jdel = j_jsonEvent;
};
JsonEvent._jclass = utils.getJavaClass("io.vertx.core.parsetools.JsonEvent");
JsonEvent._jtype = {accept: function(obj) {
return JsonEvent._jclass.isInstance(obj._jdel);
},wrap: function(jdel) {
var obj = Object.create(JsonEvent.prototype, {});
JsonEvent.apply(obj, arguments);
return obj;
},
unwrap: function(obj) {
return obj._jdel;
}
};
JsonEvent._create = function(jdel) {var obj = Object.create(JsonEvent.prototype, {});
JsonEvent.apply(obj, arguments);
return obj;
}
module.exports = JsonEvent;