2013-02-06 46 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"); 

順便說一句,你有什麼錯誤?