=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListUtils.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListUtils.java 2013-12-24 15:02:47 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListUtils.java 2014-02-21 11:45:25 +0000 @@ -209,4 +209,24 @@ } } } + + /** + * Returns the sub list of the given list avoiding exceptions, starting on + * the given start index and returning at maximum the given max number of items. + * + * @param list the list. + * @param start the start index. + * @param max the max number of items to return. + */ + public static List subList( List list, int start, int max ) + { + if ( list == null ) + { + return null; + } + + int end = start + max; + + return list.subList( Math.max( 0, start ), Math.min( list.size(), end ) ); + } }