Name
sn_itom_pattern.PatternJSUtil
Description
No description available
Script
/**
* JavaScript utility functions.
*
* Aakash Umeshbhai Bhagat aakashumeshbh.bhagat@service-now.com
*/
var PatternJSUtil = Class.create();
PatternJSUtil.prototype = {
initialize: function() {},
/*
* Returns true if the given item is null, undefined, or evaluates to the empty string.
*/
nil: function(item) {
if (this.isJavaObj(item))
return (item.toString() == null) || (item.toString() == '');
return (item == null) || (typeof item == 'undefined') || ('' == '' + item);
},
/*
* Returns true if the given item exists and is not empty (the logical inverse of .nil(), above).
*/
notNil: function(item) {
return !this.nil(item);
},
/*
* Returns true if the given value is an instance of a Java object.
*/
isJavaObj: function(value) {
if (value == null)
return false;
if (typeof value != 'object')
return false;
if (typeof value.hashCode != 'function')
return false;
if (typeof value.equals != 'function')
return false;
if (typeof value.getClass != 'function')
return false;
if (typeof value.notify != 'function')
return false;
if (typeof value.notifyAll != 'function')
return false;
if (typeof value.toString != 'function')
return false;
return true;
},
type: "PatternJSUtil"
};
Sys ID
d38dfa80b7e110107b32edfbce11a9f5