List list = new ArrayList();
if( matcher.matches() )
{
int minId = Integer.parseInt(matcher.group(1));
if( minId == 0 )
throw new AzureusCoreException("lower range must be greater than 0");
if( minId > torrents.size() )
throw new AzureusCoreException("lower range specified (" + minId + ") is outside number of torrents (" + torrents.size() + ")");
if( matcher.group(2) == null )
{
// received a single number. eg: 3
list.add(torrents.get(minId-1));
return list;
}
int maxId;
if( matcher.group(3) == null )
// received bound range. eg: 3-5
maxId = Integer.parseInt(matcher.group(5));
else
// received open ended range. eg: 3-
maxId = torrents.size();
if( minId > maxId )
throw new AzureusCoreException("when specifying a range, the max value must be greater than or equal to the min value");
for( int i = (minId-1) ; i < maxId && i < torrents.size() ; i++ )
{
list.add(torrents.get(i));
}