博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
js创建javaMap
阅读量:4648 次
发布时间:2019-06-09

本文共 2624 字,大约阅读时间需要 8 分钟。

/**  * Simple Map  * var m = new Map();  * m.put('key','value');  * var v_otherMap = v_m.toMapString();* * alert(v_otherMap );  */ (function(){    var _common = {        Map :function () {            Array.prototype.remove = function(val) {                var index = this.indexOf(val);                if (index > -1) {                    this.splice(index, 1);                }            };            this.keys = new Array(); /** 存放键的数组(遍历用到) */                 this.data = new Object();/** 存放数据 */                /**                * 放入一个键值对                * @param {String} key                * @param {Object} value                */                this.put = function(key, value) {                     if(this.data[key] == null){                         this.keys.push(key);                }                this.data[key] = value;            };                 /**                * 获取某键对应的值                * @param {String} key                * @return {Object} value                */                this.get = function(key) {                return this.data[key];            };            /**                * 删除一个键值对                * @param {String} key                */                this.remove = function(k) {                this.keys.remove(k);                //delete this.keys[k];                this.data[k] = null;                 };            /**                * 遍历Map,执行处理函数                *                 * @param {Function} 回调函数 function(key,value,index){..}                */                this.each = function(fn){                     if(typeof fn != 'function'){                         return;                     }                     var len = this.keys.length;                     for(var i=0;i
@SuppressWarnings("rawtypes")    public static void main(String[] args) throws EvalError {        StringBuffer sb = new StringBuffer();        String tt ="201503";        Map  map =    makeupDynamicMap("java.util.Map map = new java.util.HashMap();map.put(\"result\",\"to\");map.put(\"result1\",\"to111\"); return map;");        System.out.println(map.get("result1"));    }    @SuppressWarnings("rawtypes")    public static Map makeupDynamicMap(String otherParam) throws EvalError    {        Map variables = new HashMap();        if(StringUtils.isEmpty(otherParam))            return variables;        if(StringUtils.isNotEmpty(otherParam))        {            Interpreter it = new Interpreter();            Object obj = null;            obj = it.eval(otherParam);            variables.putAll((Map)obj);        }        return variables;    }
 

 

 

 

 

 

转载于:https://www.cnblogs.com/yy123/p/4795171.html

你可能感兴趣的文章
SurfaceView+MediaPlay的bug们
查看>>
网络表示学习总结
查看>>
完成评论功能
查看>>
far和near
查看>>
Python爬虫实战四之抓取淘宝MM照片
查看>>
2015 Multi-University Training Contest 1
查看>>
C#判断一个字符串是否是数字或者含有某个数字
查看>>
SVN使用指南
查看>>
【转载】掌 握 3 C ‧ 迎 接 亮 丽 职 涯
查看>>
爬取网站附件
查看>>
java基础图形界面和IO系统
查看>>
javascript学习笔记
查看>>
hdu 3996
查看>>
python第三十九课——面向对象(二)之初始化属性
查看>>
python学习笔记之函数装饰器
查看>>
FEM计算2D瞬态热传导方程
查看>>
四年时光,匆匆而过
查看>>
【php】【psr】psr1 基础编码规范
查看>>
WAF SSI
查看>>
LDAP & it's implementation
查看>>