JSONArrayIteratingUberspector.java [src/java/reports] Revision: default Date:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package reports;
import java.util.Iterator;
import org.apache.velocity.util.introspection.Info;
import org.apache.velocity.util.introspection.SecureUberspector;
import org.codehaus.jettison.json.JSONArray;
/**
* Used by Apache Velocity to allow the "#foreach( $management in $managements
* )" notation to understand JSONArrays.
*/
public final class JSONArrayIteratingUberspector extends SecureUberspector {
@Override
@SuppressWarnings("rawtypes")
public Iterator getIterator(Object obj, Info i) {
if (obj instanceof JSONArray) {
return new JSONArrayIterator((JSONArray) obj);
} else {
return super.getIterator(obj, i);
}
}
}