dscId = dscId.substring(marker.length());
// Try to get data source from pool
// If conflicts with other data source collections, consider the fisrt DataSourceCollectionAnimator
DataSourceCollection existingDsc=null;
if (pool != null){
try {
existingDsc = pool.getCollectionForDataSourceId(id);
} catch (DuplicateIdException e) {
// Eliminates the collections that are not TimeStamped
for (Iterator it = e.conflicts.iterator(); it.hasNext();) {
DataSourceCollection d = (DataSourceCollection) it.next();
if (!(d instanceof DataSourceCollectionAnimator)){
it.remove();
continue;
}
}
if (e.conflicts.size() == 0)
existingDsc = null;
else if (e.conflicts.size() > 0)
existingDsc = (DataSourceCollectionAnimator) e.conflicts.get(0);
}
}
if ( (existingDsc!=null) && (existingDsc instanceof DataSourceCollectionAnimator)){
if (chooseUseCollection(existingDsc, dscId, id)==YES_OPTION)
return existingDsc.get(id);
}
// Otherwise create a new collection
long period = ((Long)(((Object[])optionalInformation)[1])).longValue();
boolean autostop = ((Boolean)(((Object[])optionalInformation)[2])).booleanValue();
Object realOption = ((Object[])optionalInformation)[3];
DataSourcePool poolToSearch = pool;
if (pool==null) poolToSearch=DataSourcePool.global;
// Do not add the result in the datapool yet, but rather add this object on success
DataSource ds = poolToSearch.provide(id,dscId,realOption,false);
if (ds==null) return null;
if (ds instanceof EmptyDataSource){
DefaultEmptyDataSource emptyDs = new DefaultEmptyDataSource(id, marker + dscId, optionalInformation);
EmptyDataSourcePool.global.addEmptyDaSource(id, emptyDs);
return emptyDs;
}
if (ds instanceof BufferedDataSource) ds = ((BufferedDataSource)ds).dataSource;
if (!(ds instanceof CollectiveDataSource)) return null;
DataSourceCollection dsc = ((CollectiveDataSource)ds).getCollection();
int i = ((CollectiveDataSource)ds).getPosition();
DataSourceCollectionAnimator dsca = new DataSourceCollectionAnimator(dsc);
dsca.setPeriod(period);
dsca.setAutoStop(autostop);