| | |
| | | String key = attribute.getKey().replaceAll("\\$", ""); |
| | | String value = attribute.getValue(); |
| | | |
| | | String result = attrValueFormat(value); |
| | | // @{} 为java表达式; ${}为需要注入的数据项 |
| | | if (value.startsWith("@{")) { |
| | | value = value.replaceAll("\\@\\{", "").replaceAll("}", ""); |
| | | value = result.replaceAll("\\@\\{", "").replaceAll("}", ""); |
| | | Binding binding = new Binding(); |
| | | for (Map.Entry<String, Object> entry : this.parserData.entrySet()) { |
| | | String fieldKey = entry.getKey(); |
| | | Map<String, Object> data = (Map<String, Object>) entry.getValue(); |
| | | binding.setProperty(fieldKey, data); |
| | | binding.setVariable(fieldKey + ".index", 1); |
| | | binding.setProperty(fieldKey, data.get("state")); |
| | | int index = (int) data.get("index"); |
| | | binding.setVariable( "index", index); |
| | | } |
| | | GroovyShell shell = new GroovyShell(binding); |
| | | String evaluate = (String) shell.evaluate(value); |
| | |
| | | this.element.removeAttr("class"); |
| | | this.element.attr("class", evaluate); |
| | | } else if (value.contains( "${")) { |
| | | String result = attrValueFormat(value); |
| | | if ("text".equals(key)) { |
| | | this.element.text(result); |
| | | } else if ("html".equals(key)) { |