在java项目中执行groovy脚本,为什么运算符“>”被转换为“>”?

Execute groovy script in java project, why the operator “>” is converted to ">"?

这是我的 groovy 脚本:

def map = ["curr_dept":codes.get("ICU_DEPT").value];
def list = getActLists(visit,"TRAN",map,[]);
boolean flag = false;
if(null!=list && list.size()>=1){
    return true;
}
return false;

这是我的 java 执行脚本的代码,在 class "SingleDiseaseAction" 方法中 "testConfig()":

GroovyClassLoader loader = new GroovyClassLoader();
Map<String, Class<?>> totalMap = new HashMap<String, Class<?>>();
Class<?> newClazz = loader.parseClass(hsdqTargetConfig.getTarget_compute());
totalMap.put(hsdqTargetConfig.getTarget_compute(), newClazz);
Object obj = newClazz.newInstance();
Script script = (Script) obj;
Object[] paramters = new Object[] { script, getTestVisit(), hsdqRecord, map };
GroovyUtils.newInstance().invokeMethod("initScript", paramters);
value = script.run();

在上面的代码中,我的groovy脚本可以通过代码"hsdqTargetConfig.getTarget_compute()"获得。

"initScript" 方法仅用于导入一些实用程序 class:

def initScript(Script dslScript,Object obj,Object record,Map codes){
    dslScript.setProperty('codes', codes);
    def rootName =  obj.getClass().getSimpleName();
    def recordName = record.getClass().getSimpleName();
    dslScript.setProperty(rootName.substring(0,1).toLowerCase() + rootName.substring(1), obj);
    dslScript.setProperty(recordName.substring(0,1).toLowerCase() + recordName.substring(1), record);
    dslScript.setProperty('HLRUtils', HLRUtils);
    dslScript.setProperty('DateUtils', DateUtils);
    dslScript.setProperty('EnumUtils', EnumUtils);
}

感谢您阅读本文。抱歉我的英语不好。
这是错误报告

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
script1440555137250324574603.groovy: 4: expecting ')', found ';' @ line 4, column 32.
if(null!=list && list.size()&gt;=1){
                              ^
1 error
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:309)
at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:149)
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:119)
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:131)
at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:359)
at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:142)
at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:108)
at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:236)
at org.codehaus.groovy.control.CompilationUnit.call(CompilationUnit.java:162)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:574)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:550)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:527)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:244)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:202)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:212)
at com.goodwill.hdeap.web.console.record.singleDisease.SingleDiseaseAction.testConfig(SingleDiseaseAction.java:699)

我的 groovy jar 是 "groovy-all-2.1.6.jar"
我检查了 groovy 的语法。 Groovy 应该支持 ">" 运算符。
但是现在不知道为什么会报错
是因为转换操作从 ">""&gt;" 吗? 如果可以,我能为这个问题做什么?

哇,真奇怪。它看起来像一个 HTML 编码错误,但这没有意义。

尝试 safe dereference 运算符:

def map = ["curr_dept":codes.get("ICU_DEPT").value];
def list = getActLists(visit,"TRAN",map,[]);
boolean flag = false;
return list?.size() != 0