2013-02-06 47 views
0

如何在scriptella中编写以下代码? 它看起来像认为我想比较Set和String,并且它不喜欢最后一个for循环。 什么是写逻辑表达式的方式,如& &。 谢谢。Scriptella:使用集合和每个循环

<connection id="java" driver="scriptella.driver.janino.Driver"/> 

<script connection-id="java> 

//some code 

if(finalOrderCounter &lt; numberOfEntries){ 
    Set &lt;String> set = new HashSet &lt;String>(); 
    for(int i = 0; i &lt; fieldNames.length; i++){ 
     set.add(fieldNames[i]); 
    } 
    for(int i = 0; i &lt; fieldNamesFromXML.length; i++){ 
     set.remove(fieldNamesFromXML[i]); 
    } 
    String exception = ""; 
    for(String element:set) 
     exception += element +"\n"; 
    throw new IOException("Field(s)\n" + exception + "do(es) not exits in the source database"); 
} 

回答

0

也许你可以试试 “经典” 'for' 循环语法?

StringBuffer exception = new StringBuffer(); 
for (int i = 0; i &lt; set.size(); ++i) { 
    String element = (String) set.get(i); 
    exception.append(element); 
    exception.append("\n"); 
} 
throw new IOException("Field(s)\n" + exception.toString() + "do(es) not exits in the source database"); 

顺便说一句,你有什么错误?