All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ding.template-excel.2.0.1-RELEASE.source-code.init.js Maven / Gradle / Ivy

var Picture = Java.type('com.gitee.beiding.template_excel.Picture');

function objToString(obj) {
    if (obj == null) {
        return null;
    }
    if (typeof obj === 'object') {
        return JSON.stringify(obj);
    } else {
        return obj;
    }
}

function concat() {
    if (arguments.length === 0) {
        return null;
    }
    if (arguments.length === 1) {
        return arguments[0];
    }
    var flag = true;
    var s = "";
    for (var i = 0; i < arguments.length; i++) {
        if (arguments[i]) {
            s += arguments[i];
            flag = false;
        }
    }
    if (flag) {
        return null;
    } else {
        return s;
    }
}

function cas(obj, from, to) {
    if (obj === from) {
        return to;
    } else {
        return obj;
    }
}

function extract(obj, regex) {
    if (!obj) {
        return obj;
    }
    var reg = new RegExp(regex);
    var s = obj.toString();
    var list = s.match(reg);
    if (list && list.length > 0) {
        return list[0];
    } else {
        return null;
    }
}

function indexOf(arr, obj) {
    return arr.indexOf(obj);
}

function $index(n) {
    return _java.createIndex(n,_index) ;
}

function $globalIndex(n) {
    return _java.createIndex(n,_globalIndex) ;
}

var _blankArgCacheMap = {};

var _oneArgCacheMap = {};

function _clearCache() {
    _blankArgCacheMap = {};
    _oneArgCacheMap = {};
    _java.clearCache();
}

function _cachePut(args, result) {
    if (args.length === 0) {
        _blankArgCacheMap[args.callee.name] = result;
        return result
    }
    if (args.length === 1) {
        var map = _oneArgCacheMap[args.callee.name];
        if (map == null) {
            map = {};
            _oneArgCacheMap[args.callee.name] = map;
        }
        map[args[0]] = result;
        return result;
    }
    var arg = [];
    for (var i = 0; i < args.callee.length; i++) {
        arg[i] = args[i];
    }
    _java.cachePut(args.callee.name, arg, result);
    return result
}

function _cacheGet(args) {
    if (args.length === 0) {
        return _blankArgCacheMap[args.callee.name]
    }
    if (args.length === 1) {
        var map = _oneArgCacheMap[args.callee.name];
        if (map == null) {
            return null;
        }
        return map[args[0]];
    }
    var arg = [];
    for (var i = 0; i < args.callee.length; i++) {
        arg[i] = args[i];
    }
    return _java.cacheGet(args.callee.name, arg);
}

function reversal(list) {
    var r = _cacheGet(arguments);
    if (r != null) {
        return r;
    }
    if (list == null) {
        return null;
    }
    r = [];
    for (var i = 0; i < list.length; i++) {
        r[i] = list[list.length - 1 - i];
    }
    return _cachePut(arguments, r);
}

function array(len, value) {
    var r = _cacheGet(arguments);
    if (r != null) {
        return r;
    }
    r = [];
    if (!len) {
        return r;
    }
    if (value == null) {
        value = '';
    }
    for (var i = 0; i < len; i++) {
        r[i] = value;
    }
    return _cachePut(arguments, r);
}

function align(list, value) {
    var r = _cacheGet(arguments);
    if (r != null) {
        return r;
    }
    if (list == null) {
        return null;
    }
    if (value == null) {
        value = ""
    }
    r = [];
    for (var i = 0; i < list.length; i++) {
        r[i] = value;
    }
    return _cachePut(arguments, r);
}

function fill(arr, value) {
    var r = _cacheGet(arguments);
    if (r != null) {
        return r;
    }
    if (arr == null) {
        return arr;
    }
    if (value == null) {
        value = '';
    }
    for (var i = 0; i < arr.length; i++) {
        if (!arr[i]) {
            arr[i] = value;
        }
    }
    return _cachePut(arguments, arr);
}

function change(arr, from, to) {
    var r = _cacheGet(arguments);
    if (r != null) {
        return r;
    }
    if (arr == null) {
        return arr;
    }
    if (from == null) {
        return arr;
    }
    if (to == null) {
        to = '';
    }
    for (var i = 0; i < arr.length; i++) {
        if (arr[i] === from) {
            arr[i] = to;
        }
    }
    return _cachePut(arguments, arr);
}

function picture(data) {
    var p = new Picture();
    p.setData(data);
    return p;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy